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

HID Keyboard Example - how to create new bond without deleting old bond

I'm learning whitelisting with the HID Keyboard Example nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_hids_keyboard\

Question - is there a way to create a new bond without deleting an old one?

Using the vanilla example, if I bond it to my laptop, then tell my laptop to remove device, then try reconnecting, then press button 2 to turn off the whitelist advertising, my laptop sees it and attempts to connect but the app throws a bonding error (peer_manager_handler: Connection security failed:) and disconnects.

To reconnect, I have to delete old bonds first (hold button 2 while reset).

How would I best modify this example so it will accept a new bonding without deleting the old one?

nRF52840, SDK_17.0.2, SES, s140_nrf52_7.2.0_softdevice

Many thanks

Parents
  • Please ignore, I've just found the answer here

    https://devzone.nordicsemi.com/f/nordic-q-a/51274/bonding-doesn-t-work-after-deleting-bond-info-on-nrf-connect

    What I had missed is that the peer manager recognises the pairing request as from an already bonded peer (i.e. same laptop), so rejects it (to avoid attacks that update bonding info). Solution is to to enable allow_repairing. I just added following to pm_evt_handler()

            case PM_EVT_CONN_SEC_CONFIG_REQ:
                pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};
                pm_conn_sec_config_reply(p_evt->conn_handle, &conn_sec_config);
                break;
    

    For my application I'll maybe just do that once it has been put back in pairing mode (i.e. I keep the old bond, but accept new ones)

  • Ah, doesn't work, this "allow_repairing" allows the new bonded connection to be established, but if I then restart the nodes they fail to connect.

    To help debug I've copied this whitelist advertising stuff to the hrs example so I can debug both ends. The central node reports "<info> peer_manager_handler: Connection security failed: role: Central, conn_handle: 0x0, procedure: Encryption, error: 4352"

    From what I can tell, the new bonded connection is not saved to flash (after repair). Any clues as to why the original bonded connection is saved fine (and whitelist advertising works for it), but the "repaired" connection is not saved?

    I must admit I'm struggling to debug peer manager stuff - are there any tricks I'm missing? I'm mainly relying on debug logging (using RTT NRF_LOG stuff) and breakpoints in pm_evt_handler()

    Thanks

Reply
  • Ah, doesn't work, this "allow_repairing" allows the new bonded connection to be established, but if I then restart the nodes they fail to connect.

    To help debug I've copied this whitelist advertising stuff to the hrs example so I can debug both ends. The central node reports "<info> peer_manager_handler: Connection security failed: role: Central, conn_handle: 0x0, procedure: Encryption, error: 4352"

    From what I can tell, the new bonded connection is not saved to flash (after repair). Any clues as to why the original bonded connection is saved fine (and whitelist advertising works for it), but the "repaired" connection is not saved?

    I must admit I'm struggling to debug peer manager stuff - are there any tricks I'm missing? I'm mainly relying on debug logging (using RTT NRF_LOG stuff) and breakpoints in pm_evt_handler()

    Thanks

Children
Related