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

Detect MTU and Interval during connection?

Is there an easy way to check what the current connection's agreed upon MTU is?

I'm connecting to random devices that all have different intervals and MTUs. I can't be sure that this device supports more than 20 byte read/writes, but so I'd like to check with the softdevice and see what was established at connection.

Likewise, I'd like to know the current connection interval. But I haven't been able to find getter functions for these things.

Seems like it should be obvious, perhaps in a struct somewhere?

Thanks!

Parents
  • In example ble_app_hrs (and many others), this is reported via the nrf_ble_gatt module:

    /**@brief GATT module event handler.
     */
    static void gatt_evt_handler(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_t const * p_evt)
    {
        if (p_evt->evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED)
        {
            NRF_LOG_INFO("GATT ATT MTU on connection 0x%x changed to %d.",
                         p_evt->conn_handle,
                         p_evt->params.att_mtu_effective);
        }
    
        ble_hrs_on_gatt_evt(&m_hrs, p_evt);
    }
    
    
    /**@brief Function for initializing the GATT module.
     */
    static void gatt_init(void)
    {
        ret_code_t err_code = nrf_ble_gatt_init(&m_gatt, gatt_evt_handler);
        APP_ERROR_CHECK(err_code);
    }

     

    Best regards,

    Håkon

  • Håkon, great, that works if there is a re-negotiation but we're still not clear on how to pick up the MTU at initial connection... or is it always default (20ish) and has to run through the update to make it longer?

Reply Children
Related