-
Notifications
You must be signed in to change notification settings - Fork 552
Description
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 ?