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.

CC2674P10: How to handle Pending bit in BLE stack?

Part Number: CC2674P10
Other Parts Discussed in Thread: BLE-STACK, SYSCONFIG

Tool/software:

Hello
I am writing a program for working with BLE based on the multirole example. I have some of the following actions:
1. Connect to the device using a known MAC address
2. Find the desired service by a known UUID and subscribe to a notification inside it.
3. Send data with confirmation to another characteristic in this service.

Repeat action 3 many times.

The problem is that when calling the GATT_WriteCharValue (or GATT_WriteLongCharValue) function, it often returns 0x16 (blePending: A response is pending with this server). I temporarily solved this problem by making a loop in which I check the result of the check and repeat until I get a successful execution. This may require up to 800 iterations.

The question is how to properly handle such events, because the loop seems to me to be an ineffective solution. Perhaps it is necessary to somehow check the readiness of a new sending? Or to maintain some kind of pause before connecting? Maybe the latency parameter affects this?

  • I guess the possible reason is that I am calling the write function again before I received confirmation of successful sending of the previous message from rf stack (gatt msg)

  • Hi,

    Thank you for reaching out.

    I guess the possible reason is that I am calling the write function again before I received confirmation of successful sending of the previous message from rf stack (gatt msg)

    I believe you are correct. The blePending return code occurs when the BLE-Stack has too many events or payloads queued up for  processing. There are a few ways to work around this issue.

    1. Increase the max PDU amount and size (through sysconfig) until able to blePending no longer occurs.

    2. Only call the GATT_write API when the previous call has completed (can be verified through the completion event that is posted to the application)

    I would suggest doing option 2 as this ensures stability without increasing the ram/heap usage. Option 1 can work but may come at the cost of additional ram/heap consumption.

    Best Regards,

    Jan

  • Hi

    Is it possible to request a status from the stack at any point in time to determine readiness? Or just keep track of the event all the time?

  • Hi,

    You may monitor the heap/stack usage during runtime, but I would highly recommend keeping track of the events instead. You may use global flags or some sort of message posting/pending system.

    Best Regards,

    Jan