|
FastLED 3.10.6
|
Bounded outbound FIFO for chunked BLE GATT notifications.
A GATT notification carries at most ATT_MTU - 3 bytes, so a JSON-RPC response usually needs several sends. The transport therefore holds a payload across multiple can-send-now callbacks while it drains.
Storing that in-flight payload in a single buffer loses data: when a second response is produced before the first finishes draining, the sink overwrites the buffer and the peer receives a truncated first response followed by the whole second one (FastLED#3955). This queue keeps completed responses in order and only advances to the next one after the final chunk of the current one is accepted.
Single producer, single consumer, like the RX ring in the same transport:
push() only. It writes mSlots[mTail] and then publishes it by advancing mTail.chunkData(), chunkSize(), remaining() and advance() only. It reads mSlots[mHead] and owns mOffset outright.The two sides therefore never write the same variable, so no read-modify-write can be lost — which is why depth is derived from the two indices rather than kept in a shared counter. mHead and mTail are volatile so neither side caches the other's index, the same treatment the RX ring gives its own indices.
clear() is the one exception: it resets both sides at once and must only be called when the link is already down and no send callback can be in flight (from onDisconnected / destroyTransport).
The queue is deliberately platform-independent — no BTstack, no NimBLE, no ATT types — so the ordering and chunking contract is covered by host unit tests (tests/fl/net/ble_notify_queue.cpp) on targets that have no BLE silicon.
Definition in file ble_notify_queue.h.
Include dependency graph for ble_notify_queue.h:Go to the source code of this file.
Classes | |
| class | fl::net::ble::BleNotifyQueue |
| Bounded FIFO of outbound notification payloads, drained in MTU-sized chunks. More... | |
Namespaces | |
| namespace | fl |
| Base definition for an LED controller. | |
| namespace | fl::net |
| namespace | fl::net::ble |