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

connect interval

SDK: nRF5_SDK_11.0.0 Softdevice: s132_nrf52_2.0.0_softdevice

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(20, UNIT_1_25_MS)             /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(20, UNIT_1_25_MS)             /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */

In the program I set the maximum minimum connection interval of 20ms, and then use the Android to connect the device, but in my capture of the Broadcast packets: ADV_CONNECT_REQ - LLData - Interval - 0x0028, Calculate the connection interval is 50ms, by observing the following data packet found that the connection event interval is 50ms. I know the connection interval decision is the phone, but the phone can set the connection interval beyond the setting range of the slave?

  • Please use the code button, otherwise the hash tag makes the code into a heading

  • Hi,

    When initializing the Connection Parameters module you have the option to decide if a failed connection parameters update shall cause an automatic disconnection or not. This is done by setting the disconnect_on_fail flag. A connection parameters update is here considered failed if the central and peripheral have not agreed upon the connection parameters after MAX_CONN_PARAMS_UPDATE_COUNT number of connection parameter update attempts.

    Code snippet:

        /**@brief Function for initializing the Connection Parameters module.
     */
    static void conn_params_init(void)
    {
        ret_code_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    = m_hrs.hrm_handles.cccd_handle;
        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);
    }
    

    Note that you will get a BLE_CONN_PARAMS_EVT_FAILED event after a failed connection parameters update. This allows you to directly disconnect, and/or take other actions in the Connection Parameters event handler, even if you have set the disconnect_on_fail flag to false.

    Code snippet:

     * @param[in] p_evt  Event received from the Connection Parameters Module.
     */
    static void on_conn_params_evt(ble_conn_params_evt_t * p_evt)
    {
        ret_code_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);
        }
    }
    
Related