Writing uint16 characteristic

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I'm trying to take a uint16 characteristic and store it in a local variable. This is the code:

   

     wrReqParam = (CYBLE_GATTS_WRITE_REQ_PARAM_T *) eventParam;
            
                 /* If the attribute handle of the characteristic written to
                 * is equal to that of the Delay_Info characteristic, then extract
                 * the Delay_Info data */
                 if (CYBLE_DELAY_SERVICE_DELAY_INFO_CHAR_HANDLE ==
                                             wrReqParam->handleValPair.attrHandle)
                 {
                      TimeSignature[0] =
                                 wrReqParam->handleValPair.value.val[0];
                      TimeSignature[1] = 
                                 wrReqParam->handleValPair.value.val[1];
                
                                 Delay = wrReqParam->handleValPair.value.val;
                 }

   

wrReqParam works for the uint8 TimeSignature, but Delay is a uint16 and therefore gives me an error. Is there any way around this? Thanks in advance.

0 Likes
1 Solution
JobinT_31
Employee
Employee
50 solutions authored 25 solutions authored 10 solutions authored

Hi,

Can you try replacing Delay = wrReqParam->handleValPair.value.val;    with
Delay =  ((uint16)TimeSignature[1])<<8)| (uint16) TimeSignature[0] ;

Thanks
Jobin

View solution in original post

0 Likes
1 Reply
JobinT_31
Employee
Employee
50 solutions authored 25 solutions authored 10 solutions authored

Hi,

Can you try replacing Delay = wrReqParam->handleValPair.value.val;    with
Delay =  ((uint16)TimeSignature[1])<<8)| (uint16) TimeSignature[0] ;

Thanks
Jobin

0 Likes