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

NRF_BLE_GATT_MAX_MTU_SIZE > 23 and backwards compatibility

Hello,

I didn't find much information about how different settings for the MTU size behaves with older versions of BLE devices. I'm using the softdevice s132 4.0.2.

/*  Configure the maximum ATT MTU. */
memset(&ble_cfg, 0x00, sizeof(ble_cfg));
ble_cfg.conn_cfg.conn_cfg_tag                       = BLE_CONN_CFG_TAG;
ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu       = NRF_BLE_GATT_MAX_MTU_SIZE; //247
err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, ram_start);
APP_ERROR_CHECK(err_code);

How will this work with a device that supports max 23? My device is a peripheral. Will the central that connects, negotiate this to 23?

  • The att mtu length will be negotiated. This is done with an Exchange MTU Request (sd_ble_gattc_exchange_mtu_request) and a Exchange MTU Response (sd_ble_gatts_exchange_mtu_reply). The default length will be used unless a longer MTU is negotiated.

  • I posted a comment but it seemed to disappear. I still don't really understand the flow here. For instance, when connecting with an android device i get the following printout:

    nrf_ble_gatt:DEBUG:Requesting to update ATT MTU to 247 bytes on connection 0x0.
    nrf_ble_gatt:DEBUG:Requesting to update data length to 251 on connection 0x0.
    nrf_ble_gatt:ERROR:sd_ble_gap_data_length_update() (request) on connection 0x0 returned unexpected value 0x13.
    nrf_ble_gatt:DEBUG:ATT MTU updated to 247 bytes on connection 0x0 (response).
    

    Return code 0x13 seems to be NRF_ERROR_RESOURCES. The peripheral must support centrals that only support a MTU size of 23. But we really would like a bigger MTU size to increase the throughput.

    The debug output seems to have more to do with data length update than MTU.

  • What parameters do you pass to the sd_ble_gap_data_length_update call? What is .max_rx_octets and .max_tx_octets?

    Note that we have an example that changes this in our SDK; look at \examples\ble_central_and_peripheral\experimental\ble_app_att_mtu_throughput

  • Hello,

    This is how my code look like:

    case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
            {
                ble_gap_data_length_params_t dl_params;
                memset(&dl_params, 0, sizeof(ble_gap_data_length_params_t));
                err_code = sd_ble_gap_data_length_update(
                    p_ble_evt->evt.gap_evt.conn_handle,
                    &dl_params, NULL);
                APP_ERROR_CHECK(err_code);
            } break;
    

    But isn't the BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST event handeled by the nrf_ble_gatt.c module? I.e., do i have t o handle this event?

  • BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST is handled as long as nrf_ble_gatt_on_ble_evt is called from ble_evt_dispatch.

    But if you are connecting to a device that supports max 23 bytes I assumed maybe you where calling sd_ble_gap_data_length_update to initiate the data length update procedure? But it looks like you are testing with a device that supports more. So your problem isn't actually that the MTU exchange fails. But it's the DLE procedure that returns an error.

Related