This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to bond devices using the Android BLE library

Hi there,

This is actually a question re. the Android BLE library (https://github.com/NordicSemiconductor/Android-BLE-Library), so please re-direct me if necessary.

My question is in relation to bonding. I use the BLE library to connect to another Android device with the peripheral role. The GATT service on the peripheral has a characteristic requiring encryption. Therefore, when I use the BLE library to read the peripheral's characteristics, a pairing UI sequence ensues. However... the peripheral first displays a pairing dialog without the central device displaying one. If I then accept the peripheral's pairing request dialog then both the peripheral and the central (BLE library) devices display a dialog.

I experienced this behaviour prior to using the BLE library, when I used the Android APIs directly on the central device, so I don't think this is an issue with the BLE library per se.

I'm left wondering how others go about the process of bonding though. I've been working on getting bonding to work nicely on Android for a couple of weeks now, and Android is winning. Do people rely on users using the Android pairing UI of settings, or are they successful in using the BLE library to bond from the central device?

Thanks for any guidance.

Cheers,

-C

Parents
  • Thanks Aleksander for the comprehensive reply. 

    I should add that I understand that devices must be bonded to be able to successfully reconnect given the presence then of a stable MAC address. Do I have this correct?

    If so then I’m still interested to learn how most central Android devices should go about bonding. Thanks. 

  • Bonded devices may use private resolvable address, which seems random and changes in time, but the central can assume that it's the bonded device that advertises, as its generated based on the shared keys. It may be that some random device would use an address that matches, but that's not very likely and still resuming bonding would fail if it wasn't the one. However, as I wrote above, in my opinion Android would not disconnect in such case, but would remain connected with unencrypted link giving no hint that it is not the same device that was bonded. I would really like someone corrected me here. I'll try to replicate and verify that today. 

Reply
  • Bonded devices may use private resolvable address, which seems random and changes in time, but the central can assume that it's the bonded device that advertises, as its generated based on the shared keys. It may be that some random device would use an address that matches, but that's not very likely and still resuming bonding would fail if it wasn't the one. However, as I wrote above, in my opinion Android would not disconnect in such case, but would remain connected with unencrypted link giving no hint that it is not the same device that was bonded. I would really like someone corrected me here. I'll try to replicate and verify that today. 

Children
No Data
Related