Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

connection interval setup issue

Our project uses nRF52832, and the bluetooth connection has two modes as follows:

one is low-power standby mode connection interval=1000ms;

One is data transmission mode, connection interval=7.5ms;

We call sd_ble_gap_conn_param_update to set up the connection interval on the peripheral side, and we find that sd_ble_gap_conn_param_update is often incorrectly return as "NRF_ERROR_BUSY", and the retry setup also fails. Below is the setup source code, please help how to handle NRF_ERROR_BUSY to ensure that we can setup the connection interval successful, to enter the desired pattern every time. thank you!

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(7.5, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(7.5, UNIT_1_25_MS)
#define MIN_CONN_INTERVAL_LP               MSEC_TO_UNITS(1000, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL_LP               MSEC_TO_UNITS(1000, UNIT_1_25_MS)
static void gap_conn_param_update(int mode)
{
    uint32_t                err_code;
    ble_gap_conn_params_t   gap_conn_params;
    if(mode) {
        NRF_LOG_ERROR("Updating connection parameters as low power mode..");
        gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL_LP;
        gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL_LP;
        gap_conn_params.slave_latency     = SLAVE_LATENCY;
        gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;
    } else {
        NRF_LOG_ERROR("Updating connection parameters as fast mode..");
        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;
    } else {
        return;
    }
    err_code = sd_ble_gap_conn_param_update(m_conn_handle, &gap_conn_params);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR("sd_ble_gap_conn_param_update() failed: 0x%x.", err_code);
    }
}
Related