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

Problem with pm_conn_secure (error 0x08)

Hi,

I'm trying to connect my phone ober BLE with the nrf52840. The first x attemps always work (connect, disconnect, connect, disconnect, ...) but after some time no further connection can be established. I walked through the code and found that the function "sm_link_secure" called from the function "pm_conn_secure" returns with the error code 0x08:

ret_code_t pm_conn_secure(uint16_t conn_handle, bool force_repairing)
{
    VERIFY_MODULE_INITIALIZED();

    ret_code_t err_code;

    err_code = sm_link_secure(conn_handle, force_repairing);

    if (err_code == NRF_ERROR_INVALID_STATE)
    {
        err_code = NRF_ERROR_BUSY;
    }

    return err_code;
}

When I restart the phone everything works again as expected. Do you have any idea how to escape from this?

Thanks and best regards!

  • Hi,

    Which phone do you use to reproduce this? Do you see it on other phones as well (for instance both iOS and Android)?

    I walked through the code and found that the function "sm_link_secure" called from the function "pm_conn_secure" returns with the error code 0x08:

    I do not immediately understand what is going on. That said, assuming the nRF is the peripheral and sm_link_secure() returned NRF_ERROR_INVALID_STATE, that return code comes from the call to sd_ble_gap_authenticate() in link_secure_authenticate(). As you can see from the documentation, sd_ble_gap_authenticate() will return NRF_ERROR_INVALID_STATE when either no link has been established or encryption is already executing or queued. Could that one of those be the case?

    When I restart the phone everything works again as expected. Do you have any idea how to escape from this?
    • Do you need to restart the phone in order to recover in this case?
    • What happens if you instead reset the nRF?
    • Or if you instead toggle Bluetooth off and on again?
    • Or if you instead just disconnect and reconnect (without resetting either phone or nRF or toggle Bluetooth off and on)?
Related