android - getting STATE_DISCONNECTED while connecting using bluetooth smart -
i trying create advertiser on android l , other android device scanning device , trying make connection it.
but every time call connectgatt
getting bluetoothprofile.state_disconnected
in gatt callback.
this how have created advertisement
// advertisement settings advertisesettings.builder buildersetting= new advertisesettings.builder(); buildersetting.setadvertisemode(advertisesettings.advertise_mode_balanced); buildersetting.setconnectable(true); buildersetting.settimeout(0); buildersetting.settxpowerlevel(advertisesettings.advertise_tx_power_high); //advertisement data advertisedata.builder builderdata = new advertisedata.builder(); builderdata.addserviceuuid(new parceluuid(uuid.fromstring("00002a29-0000-1000-8000-00805f9b34fb"))); byte mservicedata[] = { (byte)0xff, (byte)0xfe, (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04 }; // tried addding service data builderdata.addservicedata(new parceluuid(uuid.fromstring("00002a29-0000-1000-8000-00805f9b34fb")), mservicedata); //start advertising mbtadvertiser.startadvertising( buildersetting.build(), builderdata.build(), madvcallback);
since can't comment yet ill try make answer.
in example see advertising enabled. offer gatt services, need create gatt-server handles requests.
check out documentation bluetoothmanager.opengattserver(...).
good luck!
Comments
Post a Comment