BLE - Sending string

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

cross mob
Anonymous
Not applicable

Hello,

I want to send string from char array using BLE
I add custom service in Profiles (BLE configuration),
What should I do next?

0 Likes
1 Solution
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Just set the GATT attribute for you char array to the value you need. When the GATT client next time read the attribute it gets the value (or it anbled notification, then it can get the value as soon as its written).

View solution in original post

0 Likes
5 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Just set the GATT attribute for you char array to the value you need. When the GATT client next time read the attribute it gets the value (or it anbled notification, then it can get the value as soon as its written).

0 Likes
Anonymous
Not applicable

Can somebody tell my step by step how to send string?

I'm working on BLE_Keyboard example project. 

Based on Caspesne BLE video:
In BLE configuroations -> Profiles -> HID over GATT i added:
Custom service named: POINTS ->
Custom Characteristic named: LIST ->
Client Characteristic Configuration


In main body i add:

   

CYBLE_GATTS_HANDLE_VALUE_NTF_T punktyHandle;
               
                char tekst[] = "A:50;B:60" ;
                punktyHandle.attrHandle = CYBLE_POINTS_LIST_CHAR_HANDLE;
                punktyHandle.value.val = &tekst;
                punktyHandle.value.len = 10;
                CyBle_GattsWriteAttributeValue( &punktyHandle, 0, &cyBle_connHandle, 0);

   

But it does not work.

   

0 Likes
Anonymous
Not applicable

The data you are sending is custom in nature where as you are trying to use the Standard BLE Service for HID.

   

I suggest you refer to the application note AN91162 (www.cypress.com/documentation/application-notes/an91162-creating-ble-custom-profile). This should get you in the right direction for implementing what you want.

Anonymous
Not applicable

OK, Thanks. 
It works with uint8 array... now i wonder witch type of filed should I choose in Custom characteristic to send String " (for example: "A:10;B:33;C:50") and then which type sholuld have xData; 

Handle.attrHandle = attrHandle;
Handle.value.val = xData;
Handle.value.len = len;

Should i choose utf8s?
xData should by always uint8?
Is there any simple way to convert char to uint8? 
 

0 Likes
Anonymous
Not applicable

The characteristic interface is in form of uint8*. So the data you receive from or assing to .value.val is in form of uint8*. If you have any other data type, then you should typecase into this form.