Showing results for 
Search instead for 
Did you mean: 


New Contributor II

I need to send/receive data over BLE between my PSoC device and a mobile phone. There are multiple different parameters to transfer and the data length is bigger than 512 bytes.

So, instead of creating different characteristics for each parameter, I wanted to write a packet communication protocol on one characteristic. In this packet communication protocol, the sender will send the data and also say which parameter this data belongs.

I added multiple fields in my characteristic like below:


I also created a struct just like this characteristic fields, which is also below:

#pragma pack(push, 1)

typedef struct{

     uint8 start;

     uint8 cmdId;

     uint8 dataLen;

     uint8 data[500];

     uint8 checksum;

     uint8 end;


#pragma pack(pop)

pck_t packet;

Then when I need to write the attribute value, I will reference my struct by casting it to uint8 like below:

CommCharHandle.value.val = (uint8 *)&packet;

CommCharHandle.value.len = sizeof(pck_t);

err_code = CyBle_GattsWriteAttributeValue(&CommCharHandle, 0, &cyBle_connHandle, CYBLE_GATT_DB_LOCALLY_INITIATED);

Do you think this is a good method? I saw this method (multiple field usage) in the Cypress's BLE Bootloader Module. But I couldn't find how they used these fields in the source codes. There is not any structure definition. Maybe they just defined these fields to help the developer to understand the packet easily? I don't know.

And the real question is:

Does Cypress Bootloader always send 500 bytes of data in each packet? Because if the data length changes, the position of the checksum and end bytes will shift. How to handle them? I mean, if I receive a packet in which the data length is not exactly 500, I can not mass copy the received packet to my structure?

If the data length is always 500, why do they added the 'Data Length' byte in the fields? And how do they handle the last packet that does not actually necessarily contain 500 bytes of data? Do you append zeros to it?

Message was edited by: Abdullah Çınar

1 Reply


You can use this method by adding multiple fields in a characteristic. For more information on the Cypress Bootloader service please refer to this link. The maximum number of bytes that can be sent is Negotiated MTU Size-3 bytes only. If we don't update all the bytes in data[500] then it will take zeros in that positions. The data length field is used for updating the length of the data with respect to MTU size.


P Yugandhar.