You are here

Reading Characteristic value other than uint8 | Cypress Semiconductor

Reading Characteristic value other than uint8

Summary: 2 Replies, Latest post by user_516327008 on 11 Aug 2015 10:34 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
user_516327008's picture
11 posts

I'm making a project in which the client reads a few values from the server when the server characteristics are updated.

From what I understand, this is how to read characteristic values:

        /* This event is generated when the connected Central */
        /* device sends a Write request. */
        /* The parameter 'eventParam' contains the data written */
            wrReqParam = (CYBLE_GATTS_WRITE_REQ_PARAM_T *) eventParam;
                Array[0] =
                Array[1] = 
                uint16value = wrReqParam->handleValPair.value.val;

This words fine for the array, but when i use a uint16 it won't allow it, as "handleValPair.value.val" is a uint8. If someone could help me with this or point me in the direction of a good example of how to read/write characteristic values it would be much appreciated. Thanks in advance.

roit's picture
Cypress Employee
221 posts

First of all, this is not a Read operation on a characteristic but rather a Write operation from Client to Server. I guess that is what you meant.

Coming to array vs uint16, you can consider the uint16 as an array too, with the size of 2 bytes. The first byte you receive is the LSB and the second byte is MSB. You can reconstruct the uint16 value as below:

uint16value = ((uint16)wrReqParam.handleValPair.value.val[1] << 8) | ((uint16)wrReqParam.handleValPair.value.val[0]) ;


user_516327008's picture
11 posts

Yes that is what I meant. Thank you very much.

Log in to post new comments.