How do I extract the length of the Characteristic value written to the Server from a Client when the Characteristic value is longer than the MTU size?
When the length of the Characteristic value written is greater than the MTU size, at the Server end, the CYBLE_EVT_GATTS_EXEC_WRITE_REQ event is generated. The event parameter is pointer to the CYBLE_GATTS_EXEC_WRITE_REQ_T structure.
In the CYBLE_GATTS_EXEC_WRITE_REQ_T structure, baseAddr.handleValuePair.value.len can be added for the total of the prepwritecount value to get the total length of the Characteristic value written. A sample code can be found below.
Declare the following variables:
In Stackeventhandler, add the following case statement:
//getting the eventparamter
longwrite= (CYBLE_GATTS_EXEC_WRITE_REQ_T *)eventParam;
//getting the total prepwritecount value
//adding the baseaddress.handevaluepair.value.len for total prepwritecount value
printf("\nLength written is %d \n",length);