Add dropped packet count to LocalStats (#8207)

* Add dropped packet count to LocalStats
In case the transmit queue was full

* Trunked

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
GUVWAF
2025-10-04 15:13:58 +02:00
committed by GitHub
parent fe4fb085e6
commit 888692a373
8 changed files with 34 additions and 7 deletions

View File

@@ -65,7 +65,7 @@ void fixPriority(meshtastic_MeshPacket *p)
}
/** enqueue a packet, return false if full */
bool MeshPacketQueue::enqueue(meshtastic_MeshPacket *p)
bool MeshPacketQueue::enqueue(meshtastic_MeshPacket *p, bool *dropped)
{
// no space - try to replace a lower priority packet in the queue
if (queue.size() >= maxLen) {
@@ -73,9 +73,16 @@ bool MeshPacketQueue::enqueue(meshtastic_MeshPacket *p)
if (!replaced) {
LOG_WARN("TX queue is full, and there is no lower-priority packet available to evict in favour of 0x%08x", p->id);
}
if (dropped) {
*dropped = true;
}
return replaced;
}
if (dropped) {
*dropped = false;
}
// Find the correct position using upper_bound to maintain a stable order
auto it = std::upper_bound(queue.begin(), queue.end(), p, CompareMeshPacketFunc);
queue.insert(it, p); // Insert packet at the found position