react-native-ble-plx: Endless scanning sometimes.
Using following version “react-native”: “0.62.2”, “react-native-ble-plx”: “^1.1.1”, I want to know reason of below scenario:
When Mobile app is in connected status with ble device, and I turn off the device app goes to disconnected mode and re-scan and then connect. (I repeat this) It happens regular 2-3 time successfully, after this sometime app goes to endless scanning (Scanning…) mode so in this case I have to kill and re-launch the app.
And sometime (after 2-3 time) it continuously says BleError : can not start scanning operation
so in this case I have to kill and re-launch the app or need to again turn-off or turn on the device.
My code below
this.manager.startDeviceScan(null,{ScanMode : "Balanced" }, (error, device) => { console.log("Scanning..."); if (null) { console.log('null'); return; } if (error) { console.log("Error in scan=> "+error) this.scanAndConnect() return } if(device.name == 'mydevice'){ this.manager.connectToDevice(device.id, {autoConnect:true}).then((device) => { (async () => { //listener for disconnection device.onDisconnected((error, disconnectedDevice) => { console.log('Disconnected ', disconnectedDevice.name); this.scanAndConnect(); // to start scanning again }); })(); }); } })
may I know the reason or any mistake if I made here in code ?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16
FWIW the quick start instructions pretty much guarantee a new developer will encounter this throttle error. It would be nice if the instructions guided ‘best practice’ instead of ‘rough and ready’.
You scan too often. Android allows only 5 scans in every 30 seconds window.