react-native-ble-manager icon indicating copy to clipboard operation
react-native-ble-manager copied to clipboard

When I disconnect a device, I can't rescan to the device on Android 8.0

Open linfeizhang opened this issue 4 years ago • 7 comments

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:

  1. BleManager.scan()
  2. Discover attributes (Services, characteristics, etc) for device.
  3. BleManager.connect() At this point, if I read / write to characteristic, the library acts as expected and performs the procedure.
  4. BleManager.disconnect()
  5. BleManager.scan() Unable to scan the device again,It's not actually disconnected from that device.

Please tell me how to solve this problem?

linfeizhang avatar Aug 25 '21 05:08 linfeizhang

Can u add your ble code here

vish188 avatar Aug 27 '21 08:08 vish188

ble code

I don't have any error messages, I'm showing a successful disconnect.But, in fact, there is no disconnect.

linfeizhang avatar Aug 30 '21 03:08 linfeizhang

@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?

linfeizhang avatar Sep 01 '21 02:09 linfeizhang

Any updates on this?

LazloN5 avatar Dec 06 '21 09:12 LazloN5

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 avatar Dec 10 '21 10:12 LazloN5

@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

dsnarwariya0102 avatar Dec 02 '22 04:12 dsnarwariya0102

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.

dmacpro91 avatar Jan 12 '23 14:01 dmacpro91

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.

benedicksteve avatar Nov 29 '23 15:11 benedicksteve