This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Connection Interval update issue

Hi I am trying to update the connection interval of a peripheral device (nRF52840 ) and I have followed the steps mentioned here.

After Enabling the ble on the device I read the connection interval at initialization by doing this

              uint16_t max =  p_ble_evt->evt.gap_evt.params.connected.conn_params.max_conn_interval;
              uint16_t min =  p_ble_evt->evt.gap_evt.params.connected.conn_params.min_conn_interval;
              NRF_LOG_INFO("Conn.Interval Initialized. Max: 0x%X, Min: 0x%X, Max: %d, Min: %d", max, min, max, min);

Then I used the following code part  to update the connection interval dynamically

 memset(&m_gap_conn_params, 0, sizeof(m_gap_conn_params));

    m_gap_conn_params.min_conn_interval =  30; //MSEC_TO_UNITS(30, UNIT_1_25_MS);
    m_gap_conn_params.max_conn_interval =  40; //MSEC_TO_UNITS(40, UNIT_1_25_MS);
    m_gap_conn_params.slave_latency     = 0;    // as init
    m_gap_conn_params.conn_sup_timeout  = MSEC_TO_UNITS(4000, UNIT_10_MS); // as init
    
    err_code = sd_ble_gap_conn_param_update(*m_conn_handle_gen, &m_gap_conn_params);
    APP_ERROR_CHECK(err_code);
    NRF_LOG_INFO("Conn.Interval in function. Max: 0x%X, Min: 0x%X, Max: %d, Min: %d", 
                  m_gap_conn_params.max_conn_interval, m_gap_conn_params.min_conn_interval, 
                  m_gap_conn_params.max_conn_interval, m_gap_conn_params.min_conn_interval);
   // NRF_LOG_INFO("Conn.Interval in function. Max: %d, Min: %d", m_gap_conn_params.max_conn_interval, m_gap_conn_params.min_conn_interval);

   while(conn_params_updated == false && timeoutCnt > 0)
   {
      timeoutCnt--;
      nrf_delay_ms(1);
      NRF_WDT->RR[0] = WDT_RR_RR_Reload;
   }
   conn_params_updated = false;
   if(timeoutCnt > 0) { result = COMM_RESPONSE_SUCCESS; }
   
   *lenPtr++ = COMM_RESPONSE_START;
   *lenPtr++ = COMM_CIUPDT;
   *lenPtr++ = result;
   *lenPtr++ = COMM_RESPONSE_END;
   size = lenPtr - buffer;
   err_code = ble_nus_data_send(m_nus_gen, buffer, &size , *m_conn_handle_gen);
   APP_ERROR_CHECK(err_code);

in the BLE_GAP_EVT_CONN_PARAM_UPDATE event I read back the values like this 

case BLE_GAP_EVT_CONN_PARAM_UPDATE:
            if(userRequest == UR_CONNINUPDT)
            {
              uint16_t max =  p_ble_evt->evt.gap_evt.params.connected.conn_params.max_conn_interval;
              uint16_t min =  p_ble_evt->evt.gap_evt.params.connected.conn_params.min_conn_interval;
              NRF_LOG_INFO("Conn.Interval is updated. Max: 0x%X, Min: 0x%X, Max: %d, Min: %d", max, min, max, min);
              conn_params_updated = true;
            }
            break;

But I get the following resulting values.36 is correct in initialization then the numbers don't make sense

<info> app: BLE GAP Connected
<info> app: Conn.Interval Initialized. Max: 0x24, Min: 0x24, Max: 36, Min: 36
<info> app: Data len is set to 0xF4(244)
<info> app: Data len is set to 0xF4(244)
<info> app: Conn.Interval in function. Max: 0x28, Min: 0x1E, Max: 40, Min: 30
<info> app: Conn.Interval is updated. Max: 0x2000, Min: 0xAF9, Max: 8192, Min: 2809
<info> app: Conn.Interval is updated. Max: 0x0, Min: 0x0, Max: 0, Min: 0

So I am doing something wrong but I cannot find out what

Related