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

How to send connection parameters update request from peripheral

Hello,

I want to update the connection parameters once the nrf52x (peripheral) is connected with the android (master). I tried the following:

In connection event i called ble_conn_params_change_conn_params () as :

/* new connection parameters*/
static ble_gap_conn_params_t new_conn_parameters;

case BLE_GAP_EVT_CONNECTED:

new_conn_parameters.min_conn_interval = MSEC_TO_UNITS(6, UNIT_1_25_MS);
new_conn_parameters.max_conn_interval = MSEC_TO_UNITS(40, UNIT_1_25_MS);
new_conn_parameters.slave_latency = SLAVE_LATENCY;
new_conn_parameters.conn_sup_timeout = MSEC_TO_UNITS(100, UNIT_10_MS);
ble_conn_params_change_conn_params(&new_conn_parameters);

but i cannot see any parameters update request on the sniffer.

Can you please help me what is the correct way of sending the connection parameter update request?
Can i send the connection parameter update request immediately after the connection establishment?

Waiting for your kind reply.

Parents
  • Hi,

    new_conn_parameters.min_conn_interval = MSEC_TO_UNITS(6, UNIT_1_25_MS);

    You are converting to milliseconds here, so 6 ms is not a valid value. 7.5 ms (6 in units of 1.25 ms) is the lowest connection interval allowed by the BLE spec. The function ble_conn_params_change_conn_params() will with 6ms return the value NRF_ERROR_INVALID_PARAM, and the connection parameter update request will not be sent. You should also check the return value from the function. Snippet:

    ble_gap_conn_params_t  updated_cnxn_param;
    uint32_t               retval;
    // Update in Connection parameters preferred by the application.
    updated_cnxn_param.min_conn_interval = MIN_CONN_INTERVAL;
    updated_cnxn_param.max_conn_interval = MAX_CONN_INTERVAL;
    updated_cnxn_param.slave_latency     = SLAVE_LATENCY;
    updated_cnxn_param.conn_sup_timeout  = CONN_SUP_TIMEOUT;
    // Initialize and set-up connection parameter negotiation module.
    retval = ble_conn_params_change_conn_params(&updated_cnxn_param);
    
    if(retval == NRF_SUCCESS)
    {
       // Procedure request succeeded. Connection parameters will be negotiated as requested.
       // BLE_CONN_PARAMS_EVT_SUCCEEDED will be notified if parameter negotiation is successful.
       NRF_LOG_INFO("Procedure request succeeded. Connection parameters will be negotiated as requested");
    }
    else
    {
        // Procedure request failed.
        NRF_LOG_INFO("Procedure request failed: %d",retval);
    }

    See this page for more information about the Connection Parameters Negotiation module.
  • Hi,

    thanks for your reply. Can use the code upon connection event? When the connection is successful then I can immediately send the parameter update request?

    waiting for your reply.

Reply Children
Related