Hello,
I'm wondering how long do I need to keep the data I want to send alive.
Here's the use case:
My data changed so I need to notify the central. Since the data changed, the current attribute value is invalid and needs to be updated. I build the data on-the-fly using a single global buffer that is shared among multiple characteristics, and then I send that data with sd_ble_gatts_hvx
. According to the documentation, this call also updates the attribute value, so I kill two birds with one stone.
My question is whether the hvx_params
struct passed to sd_ble_gatts_hvx
gets buffered by the softdevice or whether I need to keep it alive until I get a BLE_GATTS_EVT_HVN_TX_COMPLETE
event. I haven't had problems so far, but since I am sharing this buffer between multiple characteristics, I am afraid this has the potential to become a bug if the data doesn't get copied by the softdevice.
If the data is not buffered after that call, then I would need to create several buffers or at least a bigger one with offsets in order to make sure that the data I already passed to the sd_ble_gatts_hvx
doesn't get overwritten by a new notification on another characteristic.
Thanks for your help. Also, any suggestions on how to approach this in case the softdevice does not buffer the data, are appreciated.
This is, by the way, not documented anywhere as far as I know, and it would be nice to have it in the API calls. I'm using SDK 13.1 and SoftDevice S132 4.0.2.