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

Disconnection after BLE_GAP_EVT_LESC_DHKEY_REQUEST error 19 (0x13)

Hi all,

after call inside the BLE_GAP_EVT_LESC_DHKEY_REQUEST I got error 8, what can cause it? a CONNECTION_SUPERVISED_TIMEOUT? 

		static nrf_value_length_t peer_public_key_raw = { 0 };

		peer_public_key_raw.p_value = &p_ble_evt->evt.gap_evt.params.lesc_dhkey_request.p_pk_peer->pk[0];
		peer_public_key_raw.length = BLE_GAP_LESC_P256_PK_LEN;

		error = nrf_crypto_ecc_public_key_from_raw(NRF_CRYPTO_BLE_ECDH_CURVE_INFO,
			&peer_public_key_raw,
			&m_peer_public_key);
		APP_ERROR_CHECK(error);
		NRF_LOG_INFO("nrf_crypto_ecc_public_key_from_raw %d\r\n", error);

		error = nrf_crypto_ecdh_shared_secret_compute(NRF_CRYPTO_BLE_ECDH_CURVE_INFO,
			&m_private_key,
			&m_peer_public_key,
			&m_dh_key);
		APP_ERROR_CHECK(error);
		NRF_LOG_INFO("nrf_crypto_ecdh_shared_secret_compute %d\r\n", error);

		error = sd_ble_gap_lesc_dhkey_reply(connectionhandle, &m_lesc_dh_key);
		APP_ERROR_CHECK(error);
		NRF_LOG_INFO("sd_ble_gap_lesc_dhkey_reply %d\r\n", error);

device nRF52, SDK13

Thanks

  • Hi Ed, sure I can. But can you test the project a project made on visualgdb? And is there a way to share it private instead posting here?

  • Hey Ed, I think I found the problem, but it is still very disconcerting.... how I said above I am getting random disconnections since the connection is established I am always getting disconnection reason 0x19[BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION]

    If I change the values for MIN_CONN_INTERVAL and MAX_CONN_INTERVAL to bigger numbers it does not happen anymore, for example, I was working with MIN_CONN_INTERVAL =7.5 and MAX_CONN_INTERVAL =25 and I was getting random disconnections. I changed the values respectively to 100 and 200 and it is now working fine.

    What could be the cause of this behavior?

  • What are you trying to connect to? Is it something you have made yourself, or is it a phone, or what is it?

    It looks like you have conflicting connection intervals on the two connected devices. Do you know what the preferred connection interval settings is for the central?

    Basically, the central decides the connection interval. If the peripheral is not satisfied with the connection interval (if it is not between MIN and MAX), it can decide to disconnect. You can try to set a breakpoint in ble_conn_params.c, on line 106, and see if that is the place where it disconnects.

    If that is the place, and you don't care about the connection interval, you can try to change the conn_params setup. I don't know what your setup looks like, but if you set disconnect_on_fail to false, then you should not disconnect even if the conn_params you desire is not met.

    static void conn_params_init(void)
    {
        uint32_t               err_code;
        ble_conn_params_init_t cp_init;
    
        memset(&cp_init, 0, sizeof(cp_init));
    
        cp_init.p_conn_params                  = NULL;
        cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
        cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
        cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
        cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
        cp_init.disconnect_on_fail             = false;
        cp_init.evt_handler                    = on_conn_params_evt;
        cp_init.error_handler                  = conn_params_error_handler;
    
        err_code = ble_conn_params_init(&cp_init);
        APP_ERROR_CHECK(err_code);
    }

    However, the best solution would be to set the desired max and min connection interval to something that is supported by the central.

    Best regards,

    Edvin

  • Hi Ed, I am trying to connect between two nRF52 one central and a peripheral, but where I was getting the problem is with the central, I apologize I thought I said it before.

    both have the same setup for MIN and MAX connection interval, 7.5 and 25 respectively. when the MAX connection interval is above 100 it works fine but, when it is lower I get the random disconnect.

    I am going to test using the breakpoint in ble_conn_params.c

    I solved my issue in this way. But I am still wondering why it was disconnecting and from where it was disconnecting. Because on neither central or peripheral run into my breakpoint on ble_conn_params and I also commented the sd_disconnection command for both

Related