React-native-ble-plx: IOS :-scanning Error - BluetoothLE is in unknown state

Created on 19 Feb 2019  路  7Comments  路  Source: Polidea/react-native-ble-plx

Here is my code :

startDeviceScan(scanTimeout) {
var me = this;
// first destroy BLE manager object and re-initialize it
this.manager.destroy();
this.manager = new BleManager();
this.manager.startDeviceScan(null, null, (error, device) => {
if (error) {
// Handle error (scanning will be stopped automatically)
console.log("scanning Error - " + error.message);
me.startDeviceScan();
return;
}
if (device)
me.emit('startScanSuccess', device);
});
}

previously it was working fine for both IOS and Android but after using destroy() it is working fine on android but giving the error in case of IOS.

Most helpful comment

@Cierpliwy @roysG, I can confirm, looks like the Unknown state is always the first response, no matter how long the app has been running. Once Unknown State error has been thrown, state changes to Powered On.
update
only an issue when the remote debugger is enabled

All 7 comments

Once a BLEManager instance is created, CBCentralManager is instantiated on iOS. For small period of time BLE stack is in Unknown state, after which it transitions to "PoweredOn" or other one. There is a function which allows you to monitor BLE state. Check code snippet on introduction page.

Closing as this behaviour is expected.

I get this message even when i wait 10 minutes!

'error blueee', [BleError: BluetoothLE is in unknown state]
[68047:2469569] 'error blueee', [BleError: BluetoothLE is in unknown state]

@Cierpliwy @roysG, I can confirm, looks like the Unknown state is always the first response, no matter how long the app has been running. Once Unknown State error has been thrown, state changes to Powered On.
update
only an issue when the remote debugger is enabled

@NN01010101 You're right it's only an issue when the remote debugger is enabled.
@Cierpliwy I don't understand why it is NOT documented. It would have earn me a lot of crucial time....

@ad-boschung how do you disable the remote debugger? is it something in xcode or react native?

It's a React Native feature. It's explained here.

I think remote debugging is off by default. At least on my build, when I shake my device, it is showing ' Debug ' as an option, meaning it hasn't started debugging yet. I have already tried turning that on, then off again to see if it would produce a different result. Not sure what is happening.

Was this page helpful?
0 / 5 - 0 ratings