Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is the length passed to sd_ble_gatts_hvx maintained after NRF_SUCCESS is returned?

I'm wondering whether the value pointed to by "ble_gatts_hvx_params_t.p_len" passed to sd_ble_gatts_hvx is copied to SoftDevice-owned memory before the call returns NRF_SUCCESS.

I've seen in other posts that the data pointed to by "p_data" is maintained, but I haven't specifically seen the length mentioned.

I'm using nRF5 SDK 14.2 and SoftDevice s132 v5.1.0.

  • Hi,

    Yes, the data is copied to the SoftDevice memory, that includes the length. This can also happen in some cases even if the return value is other than NRF_SUCCESS, though, but in that case no notification/indication is sent.

    From API doc for sd_ble_gatts_hvx():

    The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution. The Attribute Table has been updated if one of the following error codes is returned: NRF_ERROR_INVALID_STATE, NRF_ERROR_BUSY, NRF_ERROR_FORBIDDEN, BLE_ERROR_GATTS_SYS_ATTR_MISSING and NRF_ERROR_RESOURCES. The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len).

    Note that p_len is an in/out variable:

    Length in bytes to be written, length in bytes written after return.

    Einar

Related