How to pass a string over BLE

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

cross mob
user_3678521
Level 3
Level 3
5 likes given First like given

So I know how to sent a int over BLE, but now I want to sent a string but I can't seem to find out how.

This is how I sent a int, that i can read from my app:

for(;;)

    {

        /* https://www.youtube.com/watch?v=Aeip0hkc4YE*/

        cy_stc_ble_gatt_handle_value_pair_t serviceHandle;

        cy_stc_ble_gatt_value_t serviceData;

     

        serviceData.val = (uint8*)data;

        serviceData.len = 1;

     

        serviceHandle.attrHandle = CY_BLE_CUSTOM_SERVICE_DEVICE_OUTBOUND_CHAR_HANDLE;

        serviceHandle.value = serviceData;

     

        Cy_BLE_GATTS_WriteAttributeValueLocal(&serviceHandle);

        data[0]++;

        CyDelay(1000);

    }

This counts up every second and I can read it.

but if I want to sent a string how can I do that?? I tried somthing like this, but i only read the start letter 'M':

ValStr = "Mads Sander Hoegstrup";

     

serviceData.val = (uint8*) ValStr;

serviceData.len = 1;

     

serviceHandle.attrHandle = CY_BLE_CUSTOM_SERVICE_DEVICE_OUTBOUND_2_CHAR_HANDLE;

serviceHandle.value = serviceData;

     

Cy_BLE_GATTS_WriteAttributeValueLocal(&serviceHandle);

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

Hello,

Please check proper value for the Length to be packed(in bytes) in the cy_stc_ble_gatt_handle_value_pair_t structure .

Thanks,
P Yugandhar.

View solution in original post

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

Hello,

Please check proper value for the Length to be packed(in bytes) in the cy_stc_ble_gatt_handle_value_pair_t structure .

Thanks,
P Yugandhar.

0 Likes