Yes, You can have it as a array of bytes and the write the particular fields alone using CyBle_GattsWriteAttributeValue API. There the length and the offset can be given so that the selected fields alone are overwritten.
(Once the write comes from the client, the write call back is invoked in the server, from which the server accesses the data. Here, the CyBle_GattsWriteAttributeValue API is callled in order to write the received data to the GATT DB of the server)
- Madhu Sudhan
As a follow up to this, how can I write a single field of a GATTS notificaiton to an Android device. I cannot see how to get the device to realize that the data update is only for, say the second field of the characteristic. I have tried to set the value.len to specify the offset, but the data is garbage on the Android side. The only way that works to notify is to set both the len and actualLen to 1, but then my app cannot tell which of the fields the value is for. I suppose the only other way would be to send an array of all 4 values and pick out the non-zero value on the other side, but I actually want the value to be able to be zero, so it would then be indistinguishable.
tempHandle.value.val = &value;
tempHandle.attrHandle = CYBLE_DMX_CONTROLLER_SYSVALS_CHAR_HANDLE;
tempHandle.value.len = length;
tempHandle.value.actualLen = 1;
The notification functions on the entire characteristic/attribute, so afaik there is no way to indicate which field exactly changed. It should be a simple matter to compare it with a previous value on the client to see changed values however.
I have set it up so that the read just replaces all of the field values every time, as the GATT server should have the most up to date values anyways. Thanks for your comment.