In this blog, I would like to show the demo how to bond with another central (host B) while the device is connecting to the bonded central (host A).

user_scenario

Scenario:

A device is paired / bonded with the central (host A).  Also, this device is using the advertising with whitelist.  Thus, the device can only connect with bonded host.

If the device needs to bond with another central (host B) during the connection with host A, this requirement or scenario is quite common particular on the HID application.

In the original Nordic SDK, if the device needs to pair with the new host, it needs to remove all the bonding record first by pressing button 2 during power up. It needs to disconnect the existing link and do the bonding with new host.

Requirement

  • Device bonds with host A (using the advertising with whitelist for reconnection)
  • Press button to trigger the device in the discovery mode (other host can discover and bond)
  • During the discovery mode, the existing link between device and host A is still there and continuous functioning with host A.
  • The device does not disconnect with host A until a new bonding with host B is success.
  • The new bonding record with host B would be automatic replaced the bonding with host A when the new bonding is success.

Test Procedure:

Step 1:  Remove the all the bonding information by pressing button 1 at NRF52 DK.

The device is advertising without whitelist.

Step 2: Bonding with Host A

Bonding with Host A

Step 3 : Press button 2 to start advertising without whitelist (device is in discovery mode)

Step 4: Bond with Host B and remove the bond record with Host A.

The source code is placed at https://github.com/jimmywong2003/nrf5-bond-with-2nd-central-example.