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

Issue in pairing in ble_app_hids_keyboard example code

I am working on ble_app_hids_keyboard example code. I downloaded the bin file in my eval kit and tried to connect the Nordic_keyboard device with my android device. Then, i forget the device while the eval kit is powered ON then after that now the device is not showing when i search for all bluetooth device but when do the same thing through nrf_connect app, it is showing the device but i am not able to pair with the device.

Finally, i observed 1 more thing that when i connect the device using j-link and select Erase all option and then flash the code, it starts working.

Parents
  • Hi,

    I assume that you are using SDK version 15.0. The default behavior is to reject pairing request from an already bonded peer. You can change this by setting .allow_repairing to true. You need to do this in pm_evt_handler() for the event PM_EVT_CONN_SEC_CONFIG_REQ.

            case PM_EVT_CONN_SEC_CONFIG_REQ:
            {
                //  pairing request from an already bonded peer.
                pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true}; //Now changed from false to true.
                pm_conn_sec_config_reply(p_evt->conn_handle, &conn_sec_config);
            } break;

  • Yes i am using SDK version 15 and there is no event of PM_EVT_CONN_SEC_CONFIG_REQ type defined in pm_evt_handler(). And when i have already unpaired the device then why it is not able to pair again. What happens after erase all command.

  • Try adding the event for PM_EVT_CONN_SEC_CONFIG_REQ in your pm_evt_handler(), and add the code I posted.

    And when i have already unpaired the device then why it is not able to pair again

    As mentioned, the default behavior is to reject pairing request from an already bonded peer. From the nRF side, the phone is still bonded, but the phone don't have the bond data anymore.

    What happens after erase all command.

    If you erase the flash, the bond information about the phone stored on the nRF is also deleted. Note that if you reset the device while pressing Button 2, the bond information is also deleted.

Reply
  • Try adding the event for PM_EVT_CONN_SEC_CONFIG_REQ in your pm_evt_handler(), and add the code I posted.

    And when i have already unpaired the device then why it is not able to pair again

    As mentioned, the default behavior is to reject pairing request from an already bonded peer. From the nRF side, the phone is still bonded, but the phone don't have the bond data anymore.

    What happens after erase all command.

    If you erase the flash, the bond information about the phone stored on the nRF is also deleted. Note that if you reset the device while pressing Button 2, the bond information is also deleted.

Children
Related