Separate Data into multiple notifications

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

cross mob
Anonymous
Not applicable

Dear all,

I'm building a custom BLE-Service and i've stumbled on the folowing problem:

Since I am required to use a ATT_MTU-3 Size i can only send 20 bytes of data in each notification. But I have to send a notification which is longer (e.g. 36 bytes) and all these bytes need to be stored in the same characteristic. Now I am wondering if there is a way to split this data into 2 notifications.

The part i have now will send a notification of 20 bytes of data and i can receive it on the client side. When i use the READ function on the client side i get the full 36 bytes of data. Whenever i change the length from 20 to anything larger the notification will not be send, I am aware that this has to do with the ATT_MTU size. (I do not want to increase the ATT_MTU size!!)

void UpdateGaid(void)

{

    if(CyBle_GetState() != CYBLE_STATE_CONNECTED)

    {

        return;

    }

  

    CYBLE_GATTS_HANDLE_VALUE_NTF_T tempHandle;

  

  

    tempHandle.attrHandle = CYBLE_CHARACTER_HANDLE;

    tempHandle.value.val = (uint8 *)&MyData;

    tempHandle.value.len = sizeof(MyData);

    CyBle_GattsWriteAttributeValue(&tempHandle, 0, &cyBle_connHandle, 0);

  

    if(CyBle_GattGetBusStatus() == CYBLE_STACK_STATE_FREE && Notify)

    {

        ble_SendNotification(CYBLE_CHARACTER_HANDLE, (uint8 *)&GaiData, 20);

    }

}

void ble_SendNotification(CYBLE_GATT_DB_ATTR_HANDLE_T characteristic, uint8* data, uint16 length)

{

    CYBLE_GATTS_HANDLE_VALUE_NTF_T notification;

    notification.value.val  = data;

    notification.value.len  = length;

    notification.attrHandle = characteristic;

    if (CyBle_GattsNotification(cyBle_connHandle, &notification) != CYBLE_ERROR_OK)

    {

        DBG_PRINTF("ERROR sending notification\r\n");

    }  

    else

    {

        DBG_PRINTF("sending notification\r\n");

    }

}

0 Likes
1 Solution
Anonymous
Not applicable

Unfortunately, I don't have an example of this, but it would be the same theory/practice as dealing with IP Fragmentation (IP fragmentation - Wikipedia )

You essentially take your data, and instead of trying to send it all at the same time, you send part of it in each packet, and the receiving side then sorts and recombines the data for use.

For example:

To send the "long" data of 0xAA,0xBB, you would send a notification with

0x01, 0xAA to signify the first section of data is 0xAA (0x01 is for the receiving side to reorder the packets)

Next you would send a packet with 0x02, 0xBB to signify the second section of data is 0xBB (0x02 is for receiving side to reorder the packets)

The receiving side would need to do alot of work to deal with missing packets of data, and verifying all of the data is present before using it. But it should be feasible with a little bit of trial and error on the exact sequencing/data formats.

You will probably need to have some way to signal a retry of the notification, how many packets of data/notifications you expect, and all data received for use.

View solution in original post

0 Likes
3 Replies
Anonymous
Not applicable

If you are wanting to split a single characteristic into two separate notifications, I would be doubtful there is a way to do that

But, if you just want your data in to separate notification packets, then you could probably setup your sending-server to send two different notifications (say NTF1 and NTF2) that would each contain part of the data. Then, you merely send a notification with the NTF1 half, and send a NTF2 half afterwards, rebuilding the original characteristic/data on the receiving side. This would require two separate characteristics unfortunately, but would allow you to differentiate between the first and second half of the data.

The other option, is to send both notifications on the same characteristic you have right now, and then to receive and store the notification data into the reassembled packet. This might overwrite your original characteristic however.

0 Likes
Anonymous
Not applicable

e.pratt_1639216​ Hello, do you have any example on how to build this?
"But, if you just want your data in to separate notification packets, then you could probably setup your sending-server to send two different notifications (say NTF1 and NTF2) that would each contain part of the data. Then, you merely send a notification with the NTF1 half, and send a NTF2 half afterwards"

0 Likes
Anonymous
Not applicable

Unfortunately, I don't have an example of this, but it would be the same theory/practice as dealing with IP Fragmentation (IP fragmentation - Wikipedia )

You essentially take your data, and instead of trying to send it all at the same time, you send part of it in each packet, and the receiving side then sorts and recombines the data for use.

For example:

To send the "long" data of 0xAA,0xBB, you would send a notification with

0x01, 0xAA to signify the first section of data is 0xAA (0x01 is for the receiving side to reorder the packets)

Next you would send a packet with 0x02, 0xBB to signify the second section of data is 0xBB (0x02 is for receiving side to reorder the packets)

The receiving side would need to do alot of work to deal with missing packets of data, and verifying all of the data is present before using it. But it should be feasible with a little bit of trial and error on the exact sequencing/data formats.

You will probably need to have some way to signal a retry of the notification, how many packets of data/notifications you expect, and all data received for use.

0 Likes