This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Changing a read characteristic value during a connection

I was disappointed to see from this question that when calling sd_ble_gatts_characteristic_add(), the value of the characteristic is copied to the SD's memory region:

devzone.nordicsemi.com/.../

A change to the value after a connection is made will not be reflected in the characteristic. It must be a perfectly common use case to expect this to happen. How do you suggest we implement this?

  • There is a parameter that you can set in the attr_md_t that tells the stack not to store the value in the SD memory region but in the application region, this should exist in attr_md_t structure you supply with the characteristic add (attr_md.vloc = BLE_GATTS_VLOC_USER;). developer.nordicsemi.com/.../a00305.html

    If you modify the value length at a later point, you should make sure to update the metadata with sd_ble_gatts_value_set(...) so that the length is updated in the stack and it knows how much data to return to the peer. But as long as it is only the value or bytes that changes, it does not matter.

  • I see, thanks. Wasn't clear how BLE_GATTS_VLOC_USER differs to BLE_GATTS_VLOC_STACK with respect to copying the value. Perhaps the documentation could be improved.

Related