I'm using some Red Bear Beacons (that in Android are charged as bluetooth
devices) into an Android application and I want to get the UUID stored in the beacon, as they do in their native app.
Using the samples they provide I have not ben able to get it.
What I have tried:
First approach
BluetoothManager mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = mBluetoothManager.getAdapter(); mBluetoothAdapter.startLeScan(mLeScanCallback); BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) { runOnUiThread(new Runnable() { @Override public void run() { if (mDevice.indexOf(device) == -1){ mDevice.add(device); byte[] serviceUuidBytes = new byte[16]; String serviceUuid = ""; for (int i = 32, j = 0; i >= 17; i--, j++) { serviceUuidBytes[j] = scanRecord[i]; } serviceUuid = bytesToHex(serviceUuidBytes); Log.i(TAG, "UUID is: " + serviceUuid); //This is the result 420903bf01004915e79610a7f5d060b0 } } }); } };
Second approach
BluetoothLeScanner mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner(); mBluetoothLeScanner.startScan(mScanCallback); ScanCallback mScanCallback = new ScanCallback() { public void onScanResult(int callbackType, android.bluetooth.le.ScanResult result) { Log.i(TAG, "scan result" + result.toString()); //this contains something like [...] mServiceUuids=[b0702980-a295-a8ab-f734-031a98a512de][....] }; };
None of these results 420903bf01004915e79610a7f5d060b0
OR b0702980-a295-a8ab-f734-031a98a512de
is what I'm looking for, that should be like this: (screenshot from RedBear BeaconTool
app )
After some tests with my beacons I could see that this UUID is somehow linked with the one found by my mBluetoothLeScanner
-> b0702980-a295-a8ab-f734-031a98a512de
that makes me think that is the same but encoded(displayed) in a different manner.
Has anyone experience with redbear
beacons and could tell me how can I obtain the beacon's UUID
(E2C56DB5-DFFB-48D2-B060-D0F5A71096E0) in my app?
OR
can anybody tell me if E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
and b0702980-a295-a8ab-f734-031a98a512de
represents the same thing encoded in a different manner and if yes, how can be converted ?
Hope I was clear enough, please help me; any help will be highly appreciated! Thanks.