NordicSemiconductor / Android-BLE-Library

A library that makes working with Bluetooth LE on Android a pleasure. Seriously.
BSD 3-Clause "New" or "Revised" License
1.99k stars 414 forks source link

Incorrect bond state of already bonded BluetoothDevice #495

Open david-gettins opened 1 year ago

david-gettins commented 1 year ago

I would like to be able to press a button in an app and bond with a BLE device. Next time I open the app and reconect the BLE device I would like to see if it is already bonded and hide the button. Unfortuntely the ObservableBleManager bondingState is incorrectly reported as NOT_BONDED when it actually is bonded. android.bluetooth.BluetoothDevice shows it as being bonded.

To Reproduce

  1. Connect to a BLE device
  2. Call ensureBond().enqueue()
  3. Disconnect BLE device
  4. Close and re-open app
  5. Connect BLE device
  6. BondState is NOT_BONDED but bluetoothDevice.bondState == BluetoothDevice.BOND_BONDED the Android OS reports it as bonded also.

Notes

After bonding for the first time, BondState is correct. BondState is also correct if I remove bond and ensure bond again.

philips77 commented 1 year ago

I'll check that soon. Thank you for raising the issue

roopeshtek commented 1 year ago

We are also facing similar issue on our Android 13 devices. Its not connecting with BLE peripherals. Do you have any insight on this? We dont see google is working on it as the issue is open for more than 6 months.

https://issuetracker.google.com/issues/242755161

@philips77 Could you please look into this ?

BurgerSzilard commented 10 months ago

Any news on this ? Will this be fixed / is this fixed in one of the new releases ?

philips77 commented 10 months ago

Sorry, I missed that. I'll come back to you soon.