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

MTU Exchange and default BLE_EVT_BUFFER size

Hi,

In the BLE_UART example code posted here, I noticed a discrepancy with the SD 3.0 migration document, SDK12, and the example code.

In stock SDK 12.1.0, ble_stack_handler_types.h has BLE_EVT_BUFFER defined with a size of [(sizeof(ble_evt_t) + (GATT_MTU_SIZE_DEFAULT))] where GATT_MTU_SIZE_DEFAULT is 23. This does not work well with larger MTU sizes as the event buffer doesn't contain enough space for larger MTU sizes. I found this when trying to work with a characteristic that has a size of 128 bytes. When talking to an OS X based laptop, I was unable to send larger sizes and determined the cause seems to be related to the size of the above buffer.

In the example source, I see that BLE_EVT_BUFFER has a size of (sizeof(ble_evt_t) + (NRF_BLE_MAX_MTU_SIZE)) which is defined in the example's main.c file with

#if (NRF_SD_BLE_API_VERSION == 3)
#define NRF_BLE_MAX_MTU_SIZE            158   //DLE
#endif

I am wondering if I missed where this is a required change in the migration document or if it is not documented appropriately. Is the answer to change the defines in ble_stack_handler_types? Is there a formula for making sure BLE_EVT_BUFFER is large enough to handle the maximum supported MTU by my application?

Please clarify.

Thanks,

Eric

Related