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?

  • Hello and thanks for answer. I realized this right now, this actually caused my application to crash when a device requested for a data length update. My own handling of the event resulted in an error code (not enough resources i think), which caused the APP_ERROR_CHECK to halt my application (resulting in watch dog reset).

    So, the data length update response works well. It's the request i'm dealing with right now. I still got this debug 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.
    :DEBUG:Established link 0x0.
    

    This is triggered from the nrf_ble_gatt.c during the BLE_GAP_EVT_CONNECTED event. My guess is that there are not enough resources directly after the sd_ble_gattc_exchange_mtu_request. Any ideas how to handle this?

  • I solved this by changing:

    ble_cfg.conn_cfg.params.gap_conn_cfg.event_length   = BLE_GAP_EVENT_LENGTH_DEFAULT;
    

    to

    ble_cfg.conn_cfg.params.gap_conn_cfg.event_length   = 320;
    

    in my ble_stack_init function. Don't really know exactly what's going on here though.

Related