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);
    }
}
Parents Reply Children
  • Yes, setup again after a few seconds, will success.

    And another question is, from 1000ms to 7.5 ms connection interval, from setup to setup success, it will be take more than 6s(Please refer the below log). In our project, we need the quick response if we setup the connection interval from 1000ms to 7.5ms.

    Please help  how to optimize the response delay.

    [00279475] <error> app: Updating connection parameters as low power mode..
    [00279475可能是电话号码,是否拨号?] <info> app: sd_ble_gap_conn_param_update(): min=0x320, max=0x320.
    [00279535] <info> app: on_conn_params_update: params_ok=1..
    [00279535] <info> app: on_conn_params_update: evt_type=1..
    [00282240] <error> app: Updating connection parameters as fast mode..
    [00282240] <info> app: sd_ble_gap_conn_param_update(): min=0x6, max=0x6.
    [00289541] <info> app: on_conn_params_update: params_ok=1..
    [00289541] <info> app: on_conn_params_update: evt_type=1..
    [00301776] <error> app: Updating connection parameters as low power mode..
    [00301776] <info> app: sd_ble_gap_conn_param_update(): min=0x320, max=0x320.
    [00301830] <info> app: on_conn_params_update: params_ok=1..
    [00301830] <info> app: on_conn_params_update: evt_type=1..
    [00326941] <error> app: Updating connection parameters as fast mode..
    [00326941] <info> app: sd_ble_gap_conn_param_update(): min=0x6, max=0x6.
    [00334836] <info> app: on_conn_params_update: params_ok=1..
    [00334836] <info> app: on_conn_params_update: evt_type=1..
    [00346476] <error> app: Updating connection parameters as low power mode..
    [00346476] <info> app: sd_ble_gap_conn_param_update(): min=0x320, max=0x320.
    [00346532] <info> app: on_conn_params_update: params_ok=1..
    [00346532] <info> app: on_conn_params_update: evt_type=1..
    [00349291] <error> app: Updating connection parameters as fast mode..
    [00349291] <info> app: sd_ble_gap_conn_param_update(): min=0x6, max=0x6.
    [00356540] <info> app: on_conn_params_update: params_ok=1..
    [00356540] <info> app: on_conn_params_update: evt_type=1..
    [00368827] <error> app: Updating connection parameters as low power mode..
    [00368827] <info> app: sd_ble_gap_conn_param_update(): min=0x320, max=0x320.
    [00368886] <info> app: on_conn_params_update: params_ok=1..
    [00368886] <info> app: on_conn_params_update: evt_type=1..
  • If you need a quick change, don't use a long interval like 1 second in the first place. The negotiation will need a few roundtrips using the long interval before it can take effect, see "Peripheral Connection Parameter Update" message chart in the softdevice api documents link.

  • Thanks for your help.

    I understand, but if i using the short interval in the first place, the power consumption will be high.

    How does the min & max interval work?

  • Counter question: What reaction time (for conn param change) would be acceptable in your application? Just devide this by 6 to 10 and use that as connection interval.

  • We expect  less than 500ms for reaction time.

    So, what is the suggestion min interval? 

Related