- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Could you please provide a reference or example code where I can send sint16 type value from a BLE PSOC device.
Currently I am sending uint16 type value successfully using the following code snippet –
uint16 mydata = 25;
UpdateBleServiceValue16(mydata, CYBLE_MYSERVICE_DATA_CHAR_HANDLE);
void UpdateBleServiceValue8Array(uint16 mydata, uint16 attrHandle)
{
uint8 len = sizeof(mydata);
static uint8 arrayData[2] = { 0x00, 0x00 };
*(arrayData) = (mydata >> 😎 & 0x00FF;
arrayData[1] = mydata & 0x00FF;
CYBLE_GATT_HANDLE_VALUE_PAIR_T pair = { { arrayData, len, len }, attrHandle };
CyBle_GattsWriteAttributeValue( &pair, 0, &cyBle_connHandle, CYBLE_GATT_DB_LOCALLY_INITIATED );
}
But now I want to send value that can be negative as well i.e. I would like to send -25. How to make that possible? CYBLE_GATT_HANDLE_VALUE_PAIR_T accepts only uint8 types.
Alternate question is - Currently the data attribute is of type uint16, do I need to change it to sint16 in order to allow it to transmit negative values?
Please help.
Thanks
Kind Regards,
Jitender Kumar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Jitender,
Yes, you have to change value type to sint16 for sending the negative values.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Yugandhar,
Currently It is being set to uint16 which is working fine for positive numbers. Sorry if my concept is not clear about data types, my thinking is that in order to transmit negative value I would need to change above value type to sint16. Am I right?
Thanks,
Jitender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Jitender,
Yes, you have to change value type to sint16 for sending the negative values.
Thanks,
P Yugandhar.