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

whitelisting using HIDS Keyboard example

I am trying to understand the whitelist feature by following the HID Key board peripheral example on S140 v5.0.0.-2_aplha on nRF52840 dev kit. I am using iPhone SE with nRF Connect App.

These are the steps I follow and captured the serial log messages (see below). In step 3, I erase the bond information on my phone (under iPhone Settings > Bluetooth and select info button "i" for the Nordic_Keyboard to "Forget this device"). The nrf52840 disconnects and starts advertising with whitelist and then I press the button 2 to turn off whitelisting. After I turn off the whitelist, my phone cannot still connect to nrf52840 (it does not allow me to pair). Only way is to erase the bonds on the nRF52840 and then it allows me to pair.

My question is - Unless we have capability on my device to erase the bonds, device cannot pair to the same phone(with bond info erased on mobile device also)? Also, the steps (10 and 11) under "Testing" in infocenter.nordicsemi.com/.../ble_sdk_app_hids_keyboard.html

states that mobile device should be discoverable after it switches to advertising mode - this refers to windows platform, but I think it should not matter. This does not match with the behavior I see (steps 5 and 6 below).

Help me understand this behavior.

1. Press button 2 and reset
<info> app: HID Keyboard example started.
<info> app: Erase bonds!
<info> app: Fast advertising.
2. Select the Nordic_Keyboard on Bluetooth Settings and Pair
<info> app: Connected
<info> app: Connection secured: role: 1, conn_handle: 0x0, procedure: 1.
<info> app: New Bond, add the peer to the whitelist if possible
<info> app:     m_whitelist_peer_cnt 1, MAX_PEERS_WLIST 8
3. Forget this device
<info> app: Directed advertising.
<info> app: Disconnected
<info> app: Fast advertising with whitelist.
4.Select the Nordic_Keyboard on Bluetooth Settings - Pairing Unsuccessful mesage on my phone
<info> app: Connected to a previously bonded device.
<info> app: Connected
<info> app: Directed advertising.
<info> app: Disconnected
<info> app: Fast advertising with whitelist.
5.Hold button 2 to turn off whitelist
<info> app: Fast advertising.
6. Select the Nordic_Keyboard on Bluetooth Settings - Pairing Unsuccessful mesage on my phone
<info> app: Connected to a previously bonded device.
<info> app: Connected
<info> app: Directed advertising.
<info> app: Disconnected
<info> app: Fast advertising with whitelist.
7. Hold button 2 to turn off whitelist
<info> app: Fast advertising.
8. Press button 2 and reset
<info> app: HID Keyboard example started.
<info> app: Erase bonds!
<info> app: Fast advertising.
9. Select the Nordic_Keyboard on Bluetooth Settings and Pair (my phone allows me to pair)
<info> app: Connected
<info> app: Connection secured: role: 1, conn_handle: 0x0, procedure: 1.
<info> app: New Bond, add the peer to the whitelist if possible
<info> app:     m_whitelist_peer_cnt 1, MAX_PEERS_WLIST 8
  • There is a flag you can set to allow bond re-fresh. However this is disabled by default because it represents a security issue. i.e. any device can use "your address" to connect to the hid device and refresh the bond information, so I usually recommend not to use it. Anyway this flag must be set to true:

    pm_conn_sec_config_t conn_sec_config = {.allow_repairing = false};
    
Related