Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BLE_APP_KEYBOARD QUESTION

Dear Nordic engineers

I made some modifications to the keyboard examples in the SDK based on the NRF5 17.0.2 version. I changed to use a static password for pairing and connection, but I currently encounter a problem. After my mobile phone and my device have been paired and bound, I have phone is disconnected from the device. Then I use my mobile phone to connect my device again. At this time, there will be an error in the BLE_GAP_EVT_CONNECTED event. I checked the log, and the error code is 8. I think it is because the mobile phone has been paired with the device, and the connection is disconnected at this time. After connecting to the BLE_GAP_EVT_CONNECTED event again, the BLE_GAP_EVT_CONNECTED event will send the request for binding and pairing again, which will cause this error.

Although I tested with my phone, this error will not affect the connection. But I am worried that this problem will cause some other models of mobile phones to be disconnected and unable to connect to the device again, and the binding must be deleted before they can be connected again. I think it is necessary to add a judgment here to determine whether the connected mobile phone has been bound and paired. If it has not been bound and paired, send a binding and pairing request. But I didn't find the definition of the relevant state, please help me, how should I judge in the BLE_GAP_EVT_CONNECTED event whether the phone has completed the pairing and binding before.

Best regards

  • Hi 

    Is there any particular reason you are calling sd_ble_gap_authenticate(..) from the connected event? 

    This is not really the recommended way to handle pairing and bonding. Normally encryption is requested by the client (phone) when it tries to access a protected services, such as HID over GATT, and when you use the peer manager the encryption related events will be handled by this module directly. 

    For an example of how to handle pairing with passkey you can have a look at the ble_app_gls example. The only difference if you use static passkey is that you need to remember to set the static passkey during initialization. 

    Best regards
    Torbjørn

Related