PSOC BLE transmit sint16 type value

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

cross mob
Anonymous
Not applicable

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

0 Likes
1 Solution
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello Jitender,

Yes, you have to change value type to sint16 for sending the negative values.

Thanks,

P Yugandhar.

View solution in original post

0 Likes
3 Replies
lock attach
Attachments are accessible only for community members.
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello Jitender,

Can you please let us know what is the Value type that you are declaring in the BLE Component as shown in attached image.

Thanks,

P Yugandhar.

0 Likes
Anonymous
Not applicable

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

0 Likes
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello Jitender,

Yes, you have to change value type to sint16 for sending the negative values.

Thanks,

P Yugandhar.

0 Likes