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

Disconnected: 0 BLEHci.remote_user_terminated_connection [using pc_ble_driver_py]

Hello,

I am using the nordic nRF52840-DK and trying to connect to a nRF52840-Dongle and sending/receiving data to custom services and characteristics using pc_ble_driver_py. I modified the heart rate collector.

But the problem is that when I am connected to the Dongle the connection last 25 to 30 secondes and I receive a message : "Disconnected: 0 BLEHci.remote_user_terminated_connection" and the error message is : "line 477, in write_req attr_handle = self.db_conns[conn_handle].get_char_value_handle(uuid) KeyError: 0". However, when I use the nRF connect mobile/PC version I don't have this problem so I think it is a problem with my code. I check it out if there is some time out equal to like 25_30 secondes but I didn't find any solution.

Could someone help me please to find some solution.

Thanks in advance.

Cordially

Joe

Parents
  • Disconnected: 0 BLEHci.remote_user_terminated_connectio

    This means that  sd_ble_gap_disconnect() was called on the peer, with the reason BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION. If you can debug your peer you should be able to find where this is called.

    Kenneth

  • Hello,

    I edited the function connect() and I added a tag = 1 = CFG_TAG (the macro in the line number 33), I don't have anymore the problem BLEHci.remote_user_terminated_connection neither the errors.

    However, after like 250~253 secondes the connection will stop and I receive the message below :

    ---> Disconnected: 0 BLEHci.conn_interval_unacceptable

    Does anyone have any solution?

    Thanks in advance.

    Joe

  • I can only assume that the dongle (operating in the central role) will be receiving an BLE_GAP_EVT_CONN_PARAM_UPDATE request from the peer device (operating in peripheral device). See here for an example:

    https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___g_a_p___c_e_n_t_r_a_l___c_p_u___m_s_c.html

    If this event is unhandled or not accepted, it is likely that the peer device may disconnect based on the configuration set during ble_conn_params_init().

  • Hello,

    I tested the blinky example in the SDK on the dongle :

    • nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_blinky\hex\pca10059\hex\ble_app_blinky_pca10059_s140.hex

    I can send data to the dongle from nrfconnect PC app, and it still connected to it as long as you don’t disconnect it. However, when using the python library, I will receive the same error and the connection will lost.

    Could you please try to run the last python script modifying the adress mac corresponding to the dongle with the blinky firmware and the serial communication port corresponding to the nrf52840-DK board.

    thanks

    Joe

  • We check with the enginneer who developped the firmware in debug mode, it appears the dongle get a BLE_GAP_EVT_DISCONNECTED when I get the error
    Disconnected: 0 BLEHci.conn_interval_unacceptable from python.
    Then we added a break point in this function
    static void on_conn_params_evt(ble_conn_params_evt_t * p_evt)
    {
    uint32_t err_code;
    if (p_evt->evt_type == BLE_CONN_PARAMS_EVT_FAILED)
    {
    err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
    APP_ERROR_CHECK(err_code);
    }
    }
    and as you previously mentionned
    sd_ble_gap_disconnect(conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE); is called.
    We check cp_init.disconnect_on_fail, it is already set "false"

    in fact we have this setting for 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;
    with
    #define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000)
    #define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(30000)
    #define MAX_CONN_PARAMS_UPDATE_COUNT 3
    #define BLE_GATT_HANDLE_INVALID 0x0000
  • we tried to add in the connect() function --> self.adapter.connect(peer_addr, conn_params=conn_params, tag=1) with conn_params = BLEGapConnParams(min_conn_interval_ms=125, max_conn_interval_ms=250, conn_sup_timeout_ms=4000, slave_latency=0)

    as it was in the dongle. But we still have the same error.

    Thanks

  • I need the sniffer log to help you further.

    Kenneth

Reply Children
Related