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

How to send notification for a large custom attribute

I am using nRF52 S132 and latest SDK V11. I defined a custom service with a custom characteristic which is 509 bytes (based on your tutorial). Read operation is fine from a client. But when using sd_ble_gatts_hvx() to send notification, only the first 20 bytes are received. The return code of this function is 0x3401, which means BLE_ERROR_GATTS_SYS_ATTR_MISSING. But it does not make sense to me. So I reduce the size from 509 to 10. The notification is sent and received. But the error code is still 0x3401. How to send notification properly?

  • Yes, it is definitely misleading how the offset doesn't work as one might expect in this situation. Would have been much simpler to implement if the offset would allow sending different parts of the value without having to copy each piece down into the lower portion (and then restore the full value in case there is a read by a peer afterwards).

    I wound up writing a function: "notify_long_chx()" which handles the general case. It gets called to send a long value as a series of shorter notifications and also handles running out of TX buffers--indicating so in the return value--so that it can be called again to finish on a subsequent BLE_EVT_TX_COMPLETE. Sorry I can't share the code since it was written for a client.

    Good luck - Tony

Related