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

How can I reduce time between sd_ble_gatts_hvx() to BLE_GATT_EVT_HVN_TX_COMPLETE event

When I send hid data using below function. (length of data is just 5)

        err_code = ble_hids_inp_rep_send(p_hids,
            index,
            len,
            pattern,
            m_conn_handle);
 
And I measured the time between sd_ble_gatts_hvx() to BLE_GATT_EVT_HVN_TX_COMPLETE event: using gpio toggle.
It takes 50ms....
I want to reduce this time.. because of this time there is delay.
How can I reduce??
Ps. I am using freertos.
  • Hi,

    Maybe you have 50ms connection interval for the BLE link.

    You should try to reduce the connection interval.

  • Thank you for your answer~! How can I change that interval time???

    my gatt define is below 

    #define MIN_CONN_INTERVAL                   MSEC_TO_UNITS(7.5UNIT_1_25_MS)           /**< Minimum connection interval (7.5 ms) */
    #define MAX_CONN_INTERVAL                   MSEC_TO_UNITS(30UNIT_1_25_MS)            /**< Maximum connection interval (30 ms). */
    #define SLAVE_LATENCY                       6                                          /**< Slave latency. */
    #define CONN_SUP_TIMEOUT                    MSEC_TO_UNITS(430UNIT_10_MS)             /**< Connection supervisory timeout (430 ms). */
    and my init function
    static void gap_params_init(void)
    {
        ret_code_t              err_code;
        ble_gap_conn_params_t   gap_conn_params;
        ble_gap_conn_sec_mode_t sec_mode;

        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

        err_code = sd_ble_gap_device_name_set(&sec_mode,
                                              (const uint8_t *)DEVICE_NAME,
                                              strlen(DEVICE_NAME));
        APP_ERROR_CHECK(err_code);

        err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_HID_KEYBOARD);
        APP_ERROR_CHECK(err_code);

        memset(&gap_conn_params0sizeof(gap_conn_params));

        gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
        gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
        gap_conn_params.slave_latency     = SLAVE_LATENCY;
        gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;

        err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
        APP_ERROR_CHECK(err_code);
    }
  • Your defines looks correct.

    I recommend checking what parameters the link is actually using, by using the nRF Sniffer to take a on-air sniffer trace. https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Sniffer-for-Bluetooth-LE

Related