cordova-plugin-ble-central
                                
                                
                                
                                    cordova-plugin-ble-central copied to clipboard
                            
                            
                            
                        scan with a service UUID
When I start scan with an empty array of service ids the scan callback returns results When enter the service UUID explicitly I get nothing What's the proper syntax? The device has a 128 bit service UUID so I use
ble.startScanWithOptions(['00007A35-0000-1000-8000-00805F9B34FB'], { reportDuplicates : true }, function(data) { _this.scanCallback(data, null); }, function(err) { _this.scanCallback(null, err); }); Thanks
That's the correct syntax. You're using the long form of a 16 bit UUID. Some Android devices are finicky and might want '7A35' as the UUID.
Thank you! Andy
On Mon, Jun 22, 2020 at 8:11 AM Don Coleman [email protected] wrote:
That's the correct syntax. You're using the long form of a 16 bit UUID. Some Android devices are finicky and might want '7A35' as the UUID.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/don/cordova-plugin-ble-central/issues/778#issuecomment-647580190, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQEF57D5267TUIWSJCUHDDRX5YDJANCNFSM4OAWODMQ .
FLATT-Dev did that work for you? I'm having the same problem. Could it be because the Android code makes a call to bluetoothAdapter.startLeScan() in BLECentralPlugin.java which is now deprecated? https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#startLeScan(java.util.UUID%5B%5D,%2520android.bluetooth.BluetoothAdapter.LeScanCallback)
Could be. No, passing the shorter form of the UUID did not work on Android. I ended up using an empty array .It does work on iOS
This worked on a Pixel 1 with Android 10.
const NORDIC_THINGY52_UUID = 'ef680100-9b35-4933-9b10-52ffa9740042';
ble.startScanWithOptions(
     [ NORDIC_THINGY52_UUID ], 
     { reportDuplicates: true }, 
     peripheral => console.log(JSON.stringify(peripheral)),
     errorMessage => console.log(`ERROR ${errorMessage}`)
 )
I need to find a device advertising a 16-bit UUID. You might try to toLowerCase() on your UUID. It didn't make a difference for me but I real having a problem with UUID case in the past.
I've seen some people say they needed to remove the hyphens for it to work on certain android devices. I can't verify that, but it might be worth a shot if you're still having problems.