Quick update, on investigating further, I found that CYBLE_EVT_GATTC_WRITE_RSP is not not being generated indicating that write operation did not finish successfully. Is there anything that I might be missing?
Since it is giving you an "INVALID OPERATION" response when the function has multiple fields, it would indicate that you are:
1. Out of space; Either ram, heap, stack, etc. for some operation necessary to perform the write
2. You are not connected/Client or allowed to write at this time (not sure what other scenarios would allow a write characteristic call)
3. The function handle/structure being passed is invalid in some way (wrong handle perhaps? With multiple fields within an attribute, the write might want a handle specifying which field to write to)
Some suggestions to try:
Try writing a multiple-byte attribute and see if you can get that approach working for a single field. Then, once you get, say, a 4-byte attribute field write working, then split the single field into two fields to see what changes.
GATTCWriteReq.value.len should be equal to the number of bytes you are writing (in this case 4).
Worst case, you can set the attribute to a single field with multiple bytes of data, and just interpret/use it as if it was two fields? Not ideal, but a good fallback for having issues.
Thank you for your response.
I think I figured out the issue. I was sending multiple write requests to the server. I observed that I was always getting the error on the second write request. I found that before sending the next write request, I need to wait till I receive CYBLE_EVT_GATTC_WRITE_RSP event (indicating that CyBle_GattcWriteCharacteristicValue() has successfully completed) for the previous write request.
With regards to GATTCWriteReq.value.len, yes it should be equal to the number of bytes writing.
I'm glad you figured it out. Best of luck with the rest of the project