When I disconnect a device, I can't rescan to the device on Android 8.0
When I disconnect, I can't rescan to the device on Android8
- react-native-ble-manager v7.5.0
- react-native v0.63.4
- Android v8
Steps to reproduce:
- BleManager.scan()
- Discover attributes (Services, characteristics, etc) for device.
- BleManager.connect() At this point, if I read / write to characteristic, the library acts as expected and performs the procedure.
- BleManager.disconnect()
- BleManager.scan() Unable to scan the device again,It's not actually disconnected from that device.
Please tell me how to solve this problem?
Can u add your ble code here
ble code
I don't have any error messages, I'm showing a successful disconnect.But, in fact, there is no disconnect.
@linfeizhang probably is a device bug.
I tested it and found out why. On Android8.0, the underlying connection cannot be disconnected when there is data interaction with the device. How to solve this problem?
Any updates on this?
Running into a similar issue. Any updates on how you resolved this?
What helped for me was removePeripheral : https://github.com/innoveit/react-native-ble-manager#removeperipheralperipheralid-android-only
I'm not sure if this is the way to go, but it fixed my issue (for now)
Edit: I call this function when disconnecting
@LazloN5 Do you by chance have a snippet of what you did? I tried a few combinations but seems to not disconnect properly still.
I don't have any error messages, I'm showing a successful disconnect.But, in fact, there is no disconnect.Because after again rescan then device not show in the list
We are also seeing this on a customer's Note 20 Ultra on Android 13. Customer can connect fine initially, but after the app is closed or the device is manually disconnected they are unable to reconnect (device doesn't show in scan). We aren't able to reproduce this on any of our test devices unfortunately.
I also got similare issue with Pixel 8 on Android 14, first scan attemps work fine, I'm able to connect, then if I disconnect and trigger a scan again I will not have any "BleManagerDiscoverPeripheral" signal for this peripheral.
I tried calling removePeripheral on disconnection but didn't change anything. Look like peripheral is cached somewhere but didn't find out how to clean this cache to be able to discover it again.
I tried tu run a ble scan via nrfConnect in parallele and my peripheral was in reach. Also find out that triggering a scan with nrf in parallele allowed me to find my device in my app again.
As work around I loop on discovered peripherals before my new scan (getDiscoveredPeripherals) to get my device information as my peripheral is still present via this function, but would be better to get it via scan again to make sure he's still at reach.