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

Overwriting bond information reliably

Hi,

I have a situation where our central device needs to be paired atmost with 1 peripheral. I can put a central device into repairing mode for 3 minutes. Within this time if another peripheral is found it shud connect and store bond information. If within 3 minutes it cannot find a new peripheral it will retain bond information of old peripheral it was connected to.

In device manager I have set DEVICE_MANAGER_MAX_BONDS to 1 since I can at max have one bonded device. But during repairing mode I won`t be able to overwrite the bond information since dm_security_setup_req does not allow. How can I solve this issue. I am using SDK 10.

Thanks in Advance.

  • You will have to use dm_device_delete or dm_device_delete_all to delete the old bonding information, then wait for the DM_EVT_DEVICE_CONTEXT_DELETED event and then call dm_security_setup_req() to to bond with the new device.

    Alternatively, you could increase DEVICE_MANAGER_MAX_BONDS to 2 so that you can bond to both devices. After the new device has bonded successfully you can delete the bonding information to the old device. This requires some “bookkeeping” as you will have to make sure that you only allow two devices to be bonded to the central when it’s in “repair-mode” and only one when it’s in its normal operating mode.

    I suggest that you take a look at this GitHub repo, it contains an example on how to delete the oldest bond information.

    -Bjørn

Related