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

How to make bonding work in this scenario

Hi,

I plan to have my device without any forms of external user input, like buttons serial ports, and similar. You can only replace the battery, that's it.

I'd also like to bond my device with a single master only. Once the bonding is made, other devices should not be able to discover or connect to it.

  1. Well, I need to understand how to achieve this. I guess I need to change the advertising mode depending on whether the device is bonded or not. I see both a discovery mode and filter policy in the API, which of these do I need to use, and do I need both?

However, what happens if I loose the master...

  1. I then need a way to clear the bonding and make the device discoverable and available again. The only thing I can think of is to have a button that will enable me to clear the bonding. But due to the environment the device will be exposed to, I'd like to avoid the button. So are any of you having another way of doing this - like putting the device into the freezer and measure if the temperature goes below -30, register that the battery is re-inserted (don't know how to do that), using a hall effect sensor and a magnet, or similar "cunning" and "clever" ways to register that the device needs to reset the bonding?

AFAIK I could also bond with two or more masters, but if the user only bonds with 1 master, how can I then avoid that another master (like a foreign master) bonds with the device.

  1. If I wrote a key on the device, could I then use it to protect it from foreign masters trying to bond with it. Well, it's not that I require a very secure device, it's just to avoid complete openness and confusion with other peoples devices. So if I wrote the address (or IRK) of the device, I could maybe have the device not responding to scans, but require that the key is used when trying to reach the device and make a new bond. Is that possible?
  • Hi,

    1. Regarding limiting only one master to connect, you can use either whitelist ( with only 1 master) or directed advertising. In the SDK we provided the bondmngr library that supports both options.

    It's not possible to avoid other masters to discover your device, since advertising is broadcasting, anyone can receive the packets. However, only the master in the whitelist or with the matched directed advertising address, is able to connect to your device.

    1. The way of reading internal temperature could be an option. However, it will only work if you really have the control of what environment the device will operate in.

    I would suggest an easier solution is to use a pattern of short power on time. For example, user can clear the bond information by plug in the battery for 1 second, then remove it, do it again for 2nd time and the bond information will be cleared. This can done easily by a timer and a byte written on flash. When the device start, after 1 second it can write to a byte in flash. If it still operates after 2 seconds , the byte will be cleared.

    Next time the device turned on, it can check for the byte and decide what to do.

    You can add more pattern to avoid unintended action.

    1. When you bond to a master, there is a LTK (Long Term Key) will be exchanged between the master and slave. Next time when the 2 get connected, they will use that LTK to encrypt the link. If the master lose this LTK it will not be able to reconnect.

    Other master will be filtered out using whitelist (IRK or address) or directed advertising.

    You can have a look at the training videos on Bluetooth.org website to have more understanding of security and how bonding and pairing work in BLE.

    To find a complete information you would need to have a look into the Core Bluetooth Spec v4.0 that can be downloaded from the same website.

  • Thank you so much for this very elaborate answer. I have now watched all the videos, and besides bonding and security, I also got a lot of information in other areas. I think Nordic should link to these videos in a more prominent spot/place.

    I will try to implement the whitelisting as you suggest, and thank you for the battery tip.

  • Totally agree about linking to the videos in a more prominent place :P

  • This might be a little late as your original post was a year ago- but one possibility to clear out bonding information would be to add a NFC chip in your device. Then you could just hold your device near a smart phone equipped with NFC, or some other device with NFC. Your device could then when it detects the NFC erase bonding information.

    NFC can also be used for bonding, if your application allows that your device (peripheral) and the Central can be placed near each other when you wish to bond. This method is sometimes used to avoid the MITM.

Related