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

BLE_GATTS_VLOC_USER and sd_ble_gatts_value_set

When using BLE_GATTS_VLOC_USER with a variable-length characteristic, we still need to use sd_ble_gatts_value_set to keep SoftDevice appraised of updates to characteristic value length (and presumably other bookkeeping).

A major motivation for using VLOC_USER (for us, at least) is for large characteristic values.

Does that mean we must have two large buffers (a "src" and "dst" )?

Is it safe to use sd_ble_gatts_value_set() with a p_value pointing to the same user buffer that was configured in sd_ble_gatts_characteristic_add()?

Does sd_ble_gatts_value_set() properly handle this kind of "overlapping regions" between its p_value and the configured VLOC_USER buffer? I guess memcpy() is likely involved, and the man page for ARM gcc memcpy(3) reads "If the regions overlap, the behavior is undefined."

Thanks.

  • This has previously been discussed here. With the current S110 version, it's recommended to use value_set() with different buffers, if you need to change the length of the characteristic. However, if you don't change the length, you can actually just change the buffer you already have access to. Also, if the peer device changes the length, no call to value_set() is needed.

    In the next release of the S110 softdevice, this will be changed to allow you to tell the S110 about the new length of a VLOC_USER attribute by simply passing NULL for the value when calling value_set(). This release should be out in production version in a couple of months time, with alphas and/or betas coming some time before.

Related