This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Why does the TI stack fragment writing of 18+ bytes to a characteristic into two events (to callback function)?

Other Parts Discussed in Thread: CC2541, CC2650

Background:

We are working on a project based on the HostTestApp example application. Our previous
colleagues extended this application to enable communication with another MCU over SPI.

Our application has a service with a custom characteristic containing one attribute. Callback functions for read/write between the example application and the extended part have been registered together with the service using the function GATTServApp_RegisterService.


The question:

If we write 20 bytes to this characteristic from BTool, the sniffer shows that 20 bytes are sent.

However, the BLE stack receives the 20 bytes but forwards them to the extension in two events. So the callback function is called twice: The first time with the first 18 bytes and an
offset of 0, and the second event with the last 2 bytes and an offset of 18 bytes.

If we send 19 bytes from BTool, there will also be two "events". One with 18 bytes and
one with 1 byte.

Why does the stack split the message into 18 + x bytes if it is longer than 18 bytes?
Is there a way to change this limit from 18 to 20?

  • Hi Elin,

    I'm not sure why you are seeing that behaviour. I tried to reproduce it from the receiving end but I always get all 20 bytes in one event. My setup is following;

    CC2541 Keyfob (sending 20 Bytes in a notification) -> CC2540USB Dongle (HostTestApp) -> PC (BTool) 

    What BLE Stack are you using? (I'm testing on BLEv1.4)

    Have you restricted the SPI outgoing buffer or something like that?

    Best Regards

    Joakim

  • Hi Joakim,

    thank you for the quick reply!

    We are running v1.3.2 on a CC2541 (I think I wrote 2540 before). We'll will upgrade to v1.4 now and see if there's a difference.

    Unfortunately not, currently we're assembling the two events into one message of 20 bytes that we send over SPI.

    1. BTool sends 20 bytes to CC2541
    2. "Black box"
    3.  Stack calls callback function two times, once with 18 bytes and once with 2
    4.  We assemble the messages into one 20 byte message and send it over SPI 

    Step 4 requires a complicated workaround to fit the application on the other MCU, it would therefore be preferable if we could get 20 bytes directly from the stack.

    Best regards,

    Elin

  • Hi Elin,

    What is the command you are using to send the data over the air? Are you using long read/write commands?

    The reason I ask is because the behaviour you are seeing should not be possible. There is no fragmentation within the stack if the data is less or equal to 20 bytes.

    It would be perfect if you could share as much details as possible on the process.

    Best Regards

    Joakim

  • Hi Joakim,

    We've been using the ATT_FindInfoReq in BTool and written to our attribute from the table that this command retrieves. I guess that it uses writeLong "under the hood". Because, when we instead use ATT_WriteReq the problem is gone!

    Thank you very much!

  • Hi Elin,

    You are correct, I'm glad you found the issue.

    Best Regards

    Joakim

  • Hy,
    I came across the same issue with BTool 1.40.12 and CC2650. I can't use the Write function in "Read/write" tab nor the double click on the Value feature of BTool to write 20byte characteristics. Only 18byte are sent and I get an "Attribute Length" error. Using ATT_WriteReq in "Adv. Commands" works fine, but is circumstantially. Is there any other way to simply write 20byte characteristics with BTool?
    Regards, Harald