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

ble_evt_t.header.evt_len

The documentation for ble_evt_hdr_t says that the evt_len field is

Length in octets excluding this header.

However as far as I can tell it's actually the length in octets including the header.

Here's the code I'm using to pull events from ble

uint16_t len = BLE_BUFFER_LEN;
uint8_t result = sd_ble_evt_get( (uint8_t*)BLE_BUFFER, &len );

in that case len ends up with the total size of the ble event written to the buffer (that would include the header, it's the whole thing). So when I cast to a ble_evt_t like so

ble_evt_t const * ble_evt = (ble_evt_t const *)BLE_BUFFER;

I would expect ble_evt->header.evt_len to be exactly 4 less than 'len' above, but it's not, it is, in every case I've checked so far, the same value. If len is 30, header.evt_len is also 30.

One easy example is a gap disconnect event. That has a ble_evt_hdr_t, a ble_gap_evt_t which has a uint16_t conn_handle and a ble_gap_evt_disconnected_t which has a uint8_t reason.

So the event itself, excluding the header, should be 2 + 1 = 3 bytes. The evt_len reported in the header is however 7 bytes.

Can you check and fix the docs please.

Related