Extracting the Length of Characteristic Value in Long Write – KBA223087

Version 3

    Version: *A


    Translation - Japanese: ロングライトの特性値の長さの抽出– KBA223087 - Community Translated (JA)



    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:

    CYBLE_GATTS_EXEC_WRITE_REQ_T *longwrite;      



    In Stackeventhandler, add the following case statement:



       uint8 length=0;

       uint8 writecount;

       //getting the eventparamter

       longwrite= (CYBLE_GATTS_EXEC_WRITE_REQ_T *)eventParam;


       dataaddress= longwrite->baseAddr;

       //getting the total prepwritecount value


       //adding the baseaddress.handevaluepair.value.len for total prepwritecount value

       for(int8 i=0;i<writecount;i++)

       length+= dataaddress[i].handleValuePair.value.len;


        printf("\nLength written is %d \n",length);