how can i initiate unbonding on the peripheral side?

I'd like to call a function on the peripheral (by pressing a button or sending a command from the terminal) that performs unbonding from a central. I'm able to bond using two different samples, peripheral_bms and peripheral_hids_mouse, but neither mention unbonding. Note that I am able to unbond from the central side by unpairing. 

I've read online that unbonding requires a sequence of events, such as: 

  1. Disable scanning on the central and advertising on the peripheral
  2. Sever the BLE connection between the two devices
  3. Delete the bond information from flash memory
  4. Re-enable scanning on the central and advertising on the peripheral

So I'd rather utilize clean, tested functions to avoid creating a ticking timebomb in my code.

Thank you

Parents
  • Hi are you using nRF Connect SDK or nRF5 SDK?

    Assuming that you are using ncs, you can take a look at lesson 5 exercise 2 on our Dev Academy BLE Fundamentals course and the associated github to see how bt_unpair() is implemented to perform unbonding.

    Please note that if only the peripheral deletes the bond, the next connection attempt will typically fail (the link cannot be re-encrypted) until the central also forgets the device in its Bluetooth settings. This is a limitation of how Bluetooth bonding works: both sides must remove the bond for a new pairing to the same device to succeed.

    Please give me more details if you still have questions (what sdk are you using, version,...)


  • Daniel,

    Thank you for this information. Lesson 5 Exercise 2 did the trick. Unfortunately I recently found out that my peripheral will need to pair and bond without access to the terminal, so I can't use the six digit key. So what's needed is the pairing method of Exercise 1 (through Step 7) with the bonding and white listing capabilities of Exercise 2. 

    I attempted to accomplish this by changing the characteristics (in exercise 2) from 

    BT_GATT_PERM_WRITE_AUTHEN to 
    BT_GATT_PERM_WRITE_ENCRYPT, but I'm still getting the passkey display on the terminal and request on my phone. Is there something I can remove from Exercise 2 that will make it only require security Level 2 but still perform bonding and whitelisting?
    Thank you
  • I got it by eliminating the call to bt_conn_auth_cb_register() in main().

Reply Children
No Data
Related