bluetooth lowenergy - android device.getUuids returns null -
i'm trying connect arduino uno via android app using bluetooth low energy (ble).
i'm developing on android studio, testing samsung galaxy s4, , android version 5.0.1
i followed link: http://www.truiton.com/2015/04/android-bluetooth-low-energy-ble-example/
i'm scanning devices , when found one, it's uuid before connecting it, make sure it's right type of device:
mscancallback = new scancallback() { @override @targetapi(21) public void onscanresult(int callbacktype, scanresult result) { bluetoothdevice btdevice = result.getdevice(); parceluuid[] uuids = btdevice.getuuids(); //<-- null!! :( log.d(tag, ""+btdevice.fetchuuidswithsdp()); //<-- prints true. log.d(tag, "result : " + result.tostring()); //<-- prints bunch of relevant info contains uuid want check. log.d(tag, "uuids : " + uuids); //<-- prints null. /* (parceluuid u : uuids) { //compare uuid of device, , connect if ok. } */ }
however, btdevice.getuuids(); returning null no error...
how can uuid of scanned device?
brute force method use regexp result.tostring() grab want there must better way isn't it?
thanks
bluetoothlescanner scanner = mbluetoothadapter.getbluetoothlescanner(); // scan devices scanner.startscan(new scancallback() { @targetapi(build.version_codes.lollipop) @override public void onscanresult(int callbacktype, scanresult result) { list<parceluuid> uuids = result.getscanrecord().getserviceuuids(); } }
this worked me in android 6.0.1
Comments
Post a Comment