I am trying to connect to Arduino Uno through an Android app using Bluetooth Low Energy (BLE).
I am developing on Android Studio, testing with Samsung Galaxy S4 and with Android version 5.0.1
I followed this link: http://www.truiton.com/2015/04/android-bluetooth-low-energy-ble-example/
I scan devices, and when I found it, I would like to get its UUID before connecting it, to make sure that it is the correct type of device:
mScanCallback = new ScanCallback() { @Override @TargetApi(21) public void onScanResult(int callbackType, ScanResult result) { BluetoothDevice btDevice = result.getDevice(); ParcelUuid[] uuids = btDevice.getUuids(); //<-- this is always null!! :( Log.d(TAG, ""+btDevice.fetchUuidsWithSdp()); //<-- prints true. Log.d(TAG, "result : " + result.toString()); //<-- prints a bunch of relevant info that contains the UUID I want to check. Log.d(TAG, "uuids : " + uuids); //<-- prints null. /* for (ParcelUuid u : uuids) { //Compare with the UUID of my device, and connect if ok. } */ }
However, btDevice.getUuids (); always returns null without errors ...
How can I get the UUID of the scanned device?
The brute force method will use regexp with the result .toString () to grab what I want, but there should be a better way, right?
thanks
source share