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

S110 - Bonding with static PIN, incorrect PIN causes assert/error

I've created a BT peripheral based on the app_proximity example (SDK 8.0) and added code to implement paring with a static PIN per examples posted here. It works as expected if/when the correct PIN is entered at the client. However (after clearing all the bonds at the peripheral and on an iOS client) attempting to bind using the wrong PIN causes the device manager throw an event 0x14 (DM_EVT_SECURITY_SETUP_COMPLETE) result 0x84 (BLE_GAP_SEC_STATUS_CONFIRM_VALUE) that generates an exception/assert error when checked at the DM event handler. As far as I can tell the event/result doesn't necessarily indicate anything wrong has happened. See error log attached. I can provide additional info if needed. I can't figure why this is an error. Thanks.

INCORRECT PIN ENTERED.txt

  • @gwayne: You are correct, it may not be considered as an error. But it's purely design choice. You can change this behaviour by modifying the device manager event handler in main.c

    Currently we will assert with any call back that doesn't return NRF_SUCCESS. I think it's make sense to disconnect when the bonding is fail, so that end user can re-connect.

    But it seems the current behaviour is that we reset in the app_error_handler() when the bonding is failed, which may be not the best.

  • Thank-you for responding. I did create an exception in the device manager event handler to avoid the assert. The ble GAP event handler receives a similar notification (BLE_GAP_EVT_AUTH_STATUS), but doesn't not attempt to run the status through APP_ERROR_CHECK. I simply have it disconnect on any status except BLE_GAP_SEC_STATUS_SUCCESS.

    Also of note, I had some trouble getting sd_ble_gap_disconnect() to work properly. It wasn't until I researched the forum here that I realized it only accepts BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION as the status code. Other codes don't return "NRF_SUCCESS", in-turn also causing an assert.

  • @gwayne: If you have a look at the description of the sd_ble_gap_disconnect() function you can find this:

    @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES (accepted values are @ref BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION and @ref BLE_HCI_CONN_INTERVAL_UNACCEPTABLE).
    

    It's always good to check the return err_code when you call a function, make sure all the parameter is accepted by the softdevice.

    If the answer is correct, could you mark it as correct so that we can close the case ?

  • I agree with respect to checking a return err_code. However a result_code isn't the same thing and thus should be handled differently.

    Thanks again for your time.

  • @gwayne: I agree. I mentioned the err_code just in relation to your note about sd_ble_gap_disconnect() that you got issue. Because if you check the err_code, and if you use incorrect status code, it will return NRF_ERROR_INVALID_PARAM that will help you to find the cause of the error.

Related