Wiriting uint16 to GATT Server Attribute

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

cross mob
MuNa_4652896
Level 4
Level 4
First like received First like given

I am trying to write a uint16 value to the a GATT Server attribute

The attribute is set to unit16 in the Service Configuration. However, this crashes the GATT DB as the PSoC module becomes unresponsive and I have to reset it.

if (CY_BLE_LEDSERV_TIMESTAMP_CHAR_HANDLE == writeReqParameter->handleValPair.attrHandle)

            {

                cy_stc_ble_gatt_handle_value_pair_t  timeHandle;

               

                timeHandle.attrHandle = CY_BLE_LEDSERV_TIMESTAMP_CHAR_HANDLE;

             

                printf("0x%x\r\n", writeReqParameter->handleValPair.value.val[0]);

                printf("0x%x\r\n", writeReqParameter->handleValPair.value.val[1]);

             

                timeHandle.value.val[0] = writeReqParameter->handleValPair.value.val[0];

                timeHandle.value.val[1] = writeReqParameter->handleValPair.value.val[1];

             

                timeHandle.value.len = 2;

             

                Cy_BLE_GATTS_WriteAttributeValueLocal(&timeHandle);

                Cy_BLE_GATTS_WriteRsp(writeReqParameter->connHandle);

             

            }

pastedImage_0.png

May I understand what am I doing wrong?

Thanks

0 Likes
1 Solution
MuNa_4652896
Level 4
Level 4
First like received First like given

Okaaay...I modified it, but this was not my main problem. Anyway, I solved the problem...Basically I can point to the uint64 value with a uint8 *. A warning will be issued, but it still works if sizes are handled carefully

View solution in original post

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

Hello,

Cy_BLE_GATTS_WriteAttributeValuePeer() function should be used to write to the value field of the specified attribute in the GATT database of a GATT Server by a peer device. Please refer to the KBA link for more information Updating an Attribute’s Value in GATT DB of a BLE GATT Server in PSoC 6 BLE – KBA228425

Thanks,

P Yugandhar.

MuNa_4652896
Level 4
Level 4
First like received First like given

Okaaay...I modified it, but this was not my main problem. Anyway, I solved the problem...Basically I can point to the uint64 value with a uint8 *. A warning will be issued, but it still works if sizes are handled carefully

0 Likes