mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-04 03:18:10 +10:00
* Yank mqtt service envelope queue * trybuildfix mqtt system * removed too much * no excessive heap debugging on release builds * send QueueStatus messages The QueueStatus message is sent as a response to the attempt to queue an outgoing MeshPacket and contains statuses of the last queue attempt, TX Queue space and capacity and MeshPacket.id that was queued. When TX Queue changes status from completely full to at least a single slot free a QueueStatus message is also sent to notify that user can queue more messages. Signed-off-by: Pavel Boldin <pavel.b@techspark.engineering> * WIP: update protobufs Signed-off-by: Pavel Boldin <pavel.b@techspark.engineering> * update protobufs * regen protos Signed-off-by: Pavel Boldin <pavel.b@techspark.engineering> Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> Co-authored-by: Sacha Weatherstone <sachaw100@hotmail.com>
42 lines
1008 B
C++
42 lines
1008 B
C++
#pragma once
|
|
|
|
#include "MeshTypes.h"
|
|
|
|
#include <assert.h>
|
|
#include <queue>
|
|
|
|
|
|
/**
|
|
* A priority queue of packets
|
|
*/
|
|
class MeshPacketQueue
|
|
{
|
|
size_t maxLen;
|
|
std::vector<MeshPacket *> queue;
|
|
|
|
/** Replace a lower priority package in the queue with 'mp' (provided there are lower pri packages). Return true if replaced. */
|
|
bool replaceLowerPriorityPacket(MeshPacket *mp);
|
|
|
|
public:
|
|
explicit MeshPacketQueue(size_t _maxLen);
|
|
|
|
/** enqueue a packet, return false if full */
|
|
bool enqueue(MeshPacket *p);
|
|
|
|
/** return true if the queue is empty */
|
|
bool empty();
|
|
|
|
/** return amount of free packets in Queue */
|
|
size_t getFree() { return maxLen - queue.size(); }
|
|
|
|
/** return total size of the Queue */
|
|
size_t getMaxLen() { return maxLen; }
|
|
|
|
MeshPacket *dequeue();
|
|
|
|
MeshPacket *getFront();
|
|
|
|
/** Attempt to find and remove a packet from this queue. Returns the packet which was removed from the queue */
|
|
MeshPacket *remove(NodeNum from, PacketId id);
|
|
};
|