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.

CC2640R2F: Missed attribute write callbacks, debugging LL acks

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC2640

Hi,

I am investigating an issue that seems to occur if too much time is spent inside the pfnGATTWriteAttrCB_t. We are in the middle of a connection event where many (6+) packets are being sent in the same interval from the central, and if too much processing takes place inside the attribute write callback, some of the packets get missed. The strange part is these packets seem to be missed completely, i.e. the central does not retransmit them (as if the BLE LL on the CC2640 has acked the packets, despite not calling our callback). In order to maximize throughput, we are using Write W/O Response, however my understanding is the central should retransmit these packets if the peripheral does not have enough buffers to process the data, because the BLE stack should not be issuing an LL-ack for those packets.

Is there a way to either control the LL-ack behavior of the stack in case there are not enough buffers or if something occurs that causes the write callback to take longer than usual? There is a structure in the HCI API called hciPER_t that contains useful info like number of rx packets/connection events, but no functions appear to make use of this structure.

Also, it looks like the pfnGATTWriteAttrCB_t can return blePending in case it needs additional time to process a write request, however the documentation does not state what effect this has on the connection. Will the BLE LL still ack packets that are received if it is out of HCI buffers? Is there a way we can inspect how many RX buffers are available? There's an API to limit the number of RX buffers per interval called HCI_EXT_OnePktPerEvtCmd(), but this would severely limit throughput.

Regards,
Michael

  • Hi Michael,
    There is no way to control the LL-ack behaviour. I am assigning one of the experts to comment in more detail.
  • Hello. You should not be doing long processing in the stack context. Please read here for more information: dev.ti.com/.../the-application.html

    You should transfer processing to the application context as recommended in the link above and as all the applications do.
  • Understood, code can be moved out of the callback to minimize processing time, however, that still leaves me with the second part of my question.

    If the sending node (the central) is sending data faster than the receiving node (the CC2640) can process, eventually it will back up (even if the data is processed in the application context). What is the expected behavior in this case? If the BLE stack is still acking the packets even if a buffer is not available, then it breaks the assumption of reliability at the link layer. Can you confirm the behavior of the BLE stack if it is out of receive buffers?
  • There are two potential scenarios:
    1. On sender side, you are trying to queue data faster than controller can send it out. In this case, the data function that you are using will return an error. It is then up to you to retransmit at a later time.
    2. Receiver side receives data but is unable to allocate buffer to pass up the stack. You can find this by looking for heap allocation failures. See here: dev.ti.com/.../debugging-index.html
    It would be quite difficult to reach this scenario as long the top-level destination of the received data is freeing it as expected.
  • In this case, the CC2640 is only acting as a receiver, the sender is always a mobile phone that sends as fast as its underlying stack allows (i.e. it throttles data based on its own TX buffers).  In the event that the stack on the CC2640 has a heap allocation failure for an RX buffer, will it respond to the phone with an LL-ack or a nack?

  • The CC2640 will respond with an ACK but the data will never be passed up the stack since the message failed to allocate.