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

Error 8 occurred when calling sd_ble_gap_conn_param_update when disconnected

The customer requested that pairing be prohibited under certain circumstances, so I called API

sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);

under BLE_GAP_EVT_SEC_PARAMS_REQUEST event to reject the pairing request.

After that, I will receive the BLE_GAP_EVT_AUTH_STATUS event, and I get that the encrypted connection cannot be established, so I call disconnect, such as the following code

case BLE_GAP_EVT_AUTH_STATUS:
    if(p_ble_evt->evt.gap_evt.params.auth_status.auth_status == BLE_GAP_SEC_STATUS_SUCCESS)
    {
        NRF_LOG_INFO("pair success\r\n");
    }
    else
    {
        sd_ble_gap_disconnect(p_ble_evt->evt.gap_evt.conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    }
    break;

I have four mobile phones, three of which can be disconnected normally, but one of the Samsung Galaxy N10 phones will have problems in the following places. Does anyone know how I can solve this problem?

Parents
  • Hi,

    Which SDK version do you use?

    Error code 8 is NRF_ERROR_INVALID_STATE, and that is expected as sd_ble_gap_conn_param_update() is called for a connection that is not active. There could be a bug in some library, or in your application causing a race condition.

    Normally, when there is a disconnect, the app timer that will request connection parameter updates will be stopped, as you can see from the implementation in ble_conn_params.c. If this does not happen for some reason and the SoftDevice call is made for an invalid connection, it will return NRF_ERROR_INVALID_STATE. How do you process SoftDevice interrupts? Specifically, what is the value of NRF_SDH_DISPATCH_MODEL in your sdk_config.h? And what is the value of APP_TIMER_CONFIG_IRQ_PRIORITY?

  • Thank you for your help.

    According to your reply, you mean that the update_timeout_handler event should not appear after the sd_ble_gap_disconnect call?

    The SDK I use is nRF5_SDK_17.0.2_d674dde

    And I use ble_app_uart to treat it as a base modification, but the related IRQ_PRIORITY has not been modified

    Secure parameters have been modified

    #define SEC_PARAM_BOND 1 /**< Perform bonding. */
    #define SEC_PARAM_MITM 1 /**< Man In The Middle protection required (applicable when display module is detected). */
    #define SEC_PARAM_LESC 1 /**< LE Secure Connections enabled. */
    #define SEC_PARAM_KEYPRESS 0 /**< Keypress notifications not enabled. */
    #define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_DISPLAY_ONLY /**< Display I/O capabilities. */
    #define SEC_PARAM_OOB 0 /**< Out Of Band data not available. */
    #define SEC_PARAM_MIN_KEY_SIZE 7 /**< Minimum encryption key size. */
    #define SEC_PARAM_MAX_KEY_SIZE 16 /**< Maximum encryption key size. */

    The settings you asked for are as follows

    NRF_SDH_DISPATCH_MODEL 0
    APP_TIMER_CONFIG_IRQ_PRIORITY 6

    In fact, I found that as long as you call

    sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);

    This problem happens sometimes, but when using this Samsung phone, the problem always happens 100% under the same mode of operation.

  • I see. There could be a race condition here, but your app timer interrupt priority is sensible so I would not see this as something that is likely to happen. Perhaps we need to look in a different direction. Can you share your code? Is it possible to reproduce on a DK so that I could test on my side?

Reply Children
No Data
Related