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

The effects of slave latency

I'm trying to use slave latency to reduce current consumption of my device.

Connection parameters defined in `main.c`:

#define MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(30, UNIT_1_25_MS)
#define SLAVE_LATENCY 4
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)

The device I'm connecting to is running iOS and I'm well within its requirements:

Slave Latency ≤ 30
2 seconds ≤ connSupervisionTimeout ≤ 6 seconds
Interval Min modulo 15 ms == 0
Interval Min ≥ 15 ms
Interval Min + 15 ms ≤ Interval Max
Interval Max * (Slave Latency + 1) ≤ 2 seconds
Interval Max * (Slave Latency + 1) * 3 < connSupervisionTimeout

To figure out the actual connection parameters I've put breakpoints after all calls to `sd_ble_gap_conn_param_update()` in my project, but none of them are visited even after the module connects to the master.

The problem is I'm not seeing any effects of slave latency on the current consumption profile (see image below). Here, there are regular pulses every 30 ms (connection interval). What I expected to see is a pulse every 4 (±1) * 30 ms since there's no data to be transmitted otherwise.

Why am I not seeing reduced consumption with the use of slave latency?

I'm using SDK 11.

Parents
  • You should first check the effective connection parameter on BLE_GAP_EVT_CONNECTED.

    Assuming that you are using ble_conn_params.c module, take note that it only checks for the connection interval.  As long as the effective connection interval is within your desired min and max, it will not initiate a Connection Parameter Update Request.

    jing

  • Thanks updating the connection parameters at BLE_GAP_EVT_CONNECED has worked.

    Here's the code:

    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        uint32_t err_code;
    
        switch (p_ble_evt->header.evt_id) {
            case BLE_GAP_EVT_CONNECTED:
                err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
                APP_ERROR_CHECK(err_code);
                m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            
                // ADDED THIS
                ble_gap_conn_params_t p_conn_params;
                p_conn_params.min_conn_interval = p_ble_evt->evt.gap_evt.params.connected.conn_params.min_conn_interval;
                p_conn_params.max_conn_interval = p_ble_evt->evt.gap_evt.params.connected.conn_params.max_conn_interval;
                p_conn_params.slave_latency     = SLAVE_LATENCY;
                p_conn_params.conn_sup_timeout  = p_ble_evt->evt.gap_evt.params.connected.conn_params.conn_sup_timeout;
    
                err_code = sd_ble_gap_conn_param_update(m_conn_handle, &p_conn_params);
                APP_ERROR_CHECK(err_code);
                //
            
                break;
    
            case BLE_GAP_EVT_DISCONNECTED:
                m_conn_handle = BLE_CONN_HANDLE_INVALID;
                break;
            
            case BLE_GAP_EVT_CONN_PARAM_UPDATE:
                break;
    
            default:
                // No implementation needed.
                break;
        }
    }

Reply
  • Thanks updating the connection parameters at BLE_GAP_EVT_CONNECED has worked.

    Here's the code:

    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        uint32_t err_code;
    
        switch (p_ble_evt->header.evt_id) {
            case BLE_GAP_EVT_CONNECTED:
                err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
                APP_ERROR_CHECK(err_code);
                m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            
                // ADDED THIS
                ble_gap_conn_params_t p_conn_params;
                p_conn_params.min_conn_interval = p_ble_evt->evt.gap_evt.params.connected.conn_params.min_conn_interval;
                p_conn_params.max_conn_interval = p_ble_evt->evt.gap_evt.params.connected.conn_params.max_conn_interval;
                p_conn_params.slave_latency     = SLAVE_LATENCY;
                p_conn_params.conn_sup_timeout  = p_ble_evt->evt.gap_evt.params.connected.conn_params.conn_sup_timeout;
    
                err_code = sd_ble_gap_conn_param_update(m_conn_handle, &p_conn_params);
                APP_ERROR_CHECK(err_code);
                //
            
                break;
    
            case BLE_GAP_EVT_DISCONNECTED:
                m_conn_handle = BLE_CONN_HANDLE_INVALID;
                break;
            
            case BLE_GAP_EVT_CONN_PARAM_UPDATE:
                break;
    
            default:
                // No implementation needed.
                break;
        }
    }

Children
No Data
Related