I'm trying to configure an application queue to hold BLE events I receive from the SoftDevice. The SDK defines NRF_SDH_BLE_EVT_BUF_SIZE as the "Size of the buffer for a BLE event." Ultimately, the value of NRF_SDH_BLE_EVT_BUF_SIZE is related to NRF_SDH_BLE_GATT_MAX_MTU_SIZE, as the event has to house any associated GATT data.
However if I set NRF_SDH_BLE_GATT_MAX_MTU_SIZE to 251, the value of NRF_SDH_BLE_EVT_BUF_SIZE goes to 508--over twice the size of the MTU! I would expect size of NRF_SDH_BLE_EVT_BUF_SIZE to be roughly sizeof(ble_evt_t) + NRF_SDH_BLE_GATT_MAX_MTU_SIZE, which would be 48 + 251 = 299. Instead its 209 bytes bigger.
This appears to be the result of the BLE_EVT_LEN_MAX macro, which is defined as
#define BLE_EVT_LEN_MAX(ATT_MTU) ( \
offsetof(ble_evt_t, evt.gattc_evt.params.prim_srvc_disc_rsp.services) + ((ATT_MTU) - 1) / 4 * sizeof(ble_gattc_service_t) \
)
Looking at the expression, this seems to imply that the event size is related to how many services I might receive from a GATT server while acting as a GATT client. But my application doesn't act as a GATT client.
So how do I determine the maximum size of an event for my use case? And where is this formula documented?
--Jay