- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
case CYBLE_EVT_GATTS_WRITE_REQ:
/* 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;
if (CYBLE_DELAY_SERVICE_DELAY_INFO_CHAR_HANDLE ==
wrReqParam->handleValPair.attrHandle)
{
Array[0] =
wrReqParam->handleValPair.value.val[0];
Array[1] =
wrReqParam->handleValPair.value.val[1];
uint16value = wrReqParam->handleValPair.value.val;
}
CyBle_GattsWriteRsp(cyBle_connHandle);
break;
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.
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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] << 😎 | ((uint16)wrReqParam.handleValPair.value.val[0]) ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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] << 😎 | ((uint16)wrReqParam.handleValPair.value.val[0]) ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes that is what I meant. Thank you very much.