Hello,
I am tinkering with some BLE configurations specifically related to MTU and throughput optimization, and my question relates to using Notify on my attribute value and how it relates to the currently set MTU size in a connection.
I am using the following part, SD and SDK:
NRF52832
SD132 v5.1
SDK v14.2
My device is running as a BLE peripheral Server, there is a mobile application connecting to it as a client.
The client is subscribing to a characteristic which my device then uses Notify to send data to the mobile app client which works fine. In order to notify on the attribute I am using the standard function from the SD API:
|
uint32_t sd_ble_gatts_hvx |
( |
uint16_t |
conn_handle, |
|
|
|
ble_gatts_hvx_params_t const * |
p_hvx_params |
|
|
) |
|
|
My question centers around the data length specified in the “p_hvx_params” field and how that relates to the MTU size and what actually gets sent to the device.
I am seeing a mismatch in what I set for the “p_hvx_params->p_len” and what actually gets sent to the mobile application. Every notify, the app sees the amount of data sent as the currently set MTU size, and not what I set for p_hvx_params->p_len.
For example, say I connect to the mobile app and MTU size is being set to 100 bytes. If I want to do a Notify less than 100 bytes, Iet's say 10 bytes, I do the following essentially:
uint16_t len = 10;
p_hvx_params->p_len = &len;
sd_ble_gatts_hvx(conn_handle, p_hvx_params);
The mobile app is claiming to receive 100-3 bytes = 97 bytes of the data I send padded with 0s. This is the MTU size, - ATT header (3 bytes). I am expecting it to receive 10 bytes.
So in summary, my question boils down to: As a peripheral server device, can you do a BLE Notify on a characteristic of length less than the MTU and am I doing it wrong with example code above? Maybe there is some configuration or step I am missing here.
It is entirely possible there is a mobile application bug and I really am sending up data correctly, but interacting with other non-Nordic MCUs, the app is able to receive less data than the MTU length no problem, wondering if there is a specific difference with the Nordic SD here or I am doing something wrong. My next step is to get a sniffer setup to try and debug, but wanted to leave a post here to see if anyone has any advice or help they could give me.