* Dispatcher::checkSend() bug: getOutboundCount() should only count non-future packets

This commit is contained in:
Scott Powell
2025-05-14 16:50:11 +10:00
parent a56e9ef62f
commit e291b57a07
6 changed files with 17 additions and 7 deletions

View File

@@ -184,7 +184,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
case REQ_TYPE_GET_STATUS: { // guests can also access this now case REQ_TYPE_GET_STATUS: { // guests can also access this now
RepeaterStats stats; RepeaterStats stats;
stats.batt_milli_volts = board.getBattMilliVolts(); stats.batt_milli_volts = board.getBattMilliVolts();
stats.curr_tx_queue_len = _mgr->getOutboundCount(); stats.curr_tx_queue_len = _mgr->getOutboundCount(0xFFFFFFFF);
stats.curr_free_queue_len = _mgr->getFreeCount(); stats.curr_free_queue_len = _mgr->getFreeCount();
stats.last_rssi = (int16_t) radio_driver.getLastRSSI(); stats.last_rssi = (int16_t) radio_driver.getLastRSSI();
stats.n_packets_recv = radio_driver.getPacketsRecv(); stats.n_packets_recv = radio_driver.getPacketsRecv();

View File

@@ -290,7 +290,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
case REQ_TYPE_GET_STATUS: { case REQ_TYPE_GET_STATUS: {
ServerStats stats; ServerStats stats;
stats.batt_milli_volts = board.getBattMilliVolts(); stats.batt_milli_volts = board.getBattMilliVolts();
stats.curr_tx_queue_len = _mgr->getOutboundCount(); stats.curr_tx_queue_len = _mgr->getOutboundCount(0xFFFFFFFF);
stats.curr_free_queue_len = _mgr->getFreeCount(); stats.curr_free_queue_len = _mgr->getFreeCount();
stats.last_rssi = (int16_t) radio_driver.getLastRSSI(); stats.last_rssi = (int16_t) radio_driver.getLastRSSI();
stats.n_packets_recv = radio_driver.getPacketsRecv(); stats.n_packets_recv = radio_driver.getPacketsRecv();

View File

@@ -205,7 +205,7 @@ void Dispatcher::processRecvPacket(Packet* pkt) {
} }
void Dispatcher::checkSend() { void Dispatcher::checkSend() {
if (_mgr->getOutboundCount() == 0) return; // nothing waiting to send if (_mgr->getOutboundCount(_ms->getMillis()) == 0) return; // nothing waiting to send
if (!millisHasNowPassed(next_tx_time)) return; // still in 'radio silence' phase (from airtime budget setting) if (!millisHasNowPassed(next_tx_time)) return; // still in 'radio silence' phase (from airtime budget setting)
if (_radio->isReceiving()) { // LBT - check if radio is currently mid-receive, or if channel activity if (_radio->isReceiving()) { // LBT - check if radio is currently mid-receive, or if channel activity
if (cad_busy_start == 0) { if (cad_busy_start == 0) {

View File

@@ -78,7 +78,7 @@ public:
virtual void queueOutbound(Packet* packet, uint8_t priority, uint32_t scheduled_for) = 0; virtual void queueOutbound(Packet* packet, uint8_t priority, uint32_t scheduled_for) = 0;
virtual Packet* getNextOutbound(uint32_t now) = 0; // by priority virtual Packet* getNextOutbound(uint32_t now) = 0; // by priority
virtual int getOutboundCount() const = 0; virtual int getOutboundCount(uint32_t now) const = 0;
virtual int getFreeCount() const = 0; virtual int getFreeCount() const = 0;
virtual Packet* getOutboundByIdx(int i) = 0; virtual Packet* getOutboundByIdx(int i) = 0;
virtual Packet* removeOutboundByIdx(int i) = 0; virtual Packet* removeOutboundByIdx(int i) = 0;

View File

@@ -8,6 +8,15 @@ PacketQueue::PacketQueue(int max_entries) {
_num = 0; _num = 0;
} }
int PacketQueue::countBefore(uint32_t now) const {
int n = 0;
for (int j = 0; j < _num; j++) {
if (_schedule_table[j] > now) continue; // scheduled for future... ignore for now
n++;
}
return n;
}
mesh::Packet* PacketQueue::get(uint32_t now) { mesh::Packet* PacketQueue::get(uint32_t now) {
uint8_t min_pri = 0xFF; uint8_t min_pri = 0xFF;
int best_idx = -1; int best_idx = -1;
@@ -81,8 +90,8 @@ mesh::Packet* StaticPoolPacketManager::getNextOutbound(uint32_t now) {
return send_queue.get(now); return send_queue.get(now);
} }
int StaticPoolPacketManager::getOutboundCount() const { int StaticPoolPacketManager::getOutboundCount(uint32_t now) const {
return send_queue.count(); return send_queue.countBefore(now);
} }
int StaticPoolPacketManager::getFreeCount() const { int StaticPoolPacketManager::getFreeCount() const {

View File

@@ -13,6 +13,7 @@ public:
mesh::Packet* get(uint32_t now); mesh::Packet* get(uint32_t now);
void add(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for); void add(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for);
int count() const { return _num; } int count() const { return _num; }
int countBefore(uint32_t now) const;
mesh::Packet* itemAt(int i) const { return _table[i]; } mesh::Packet* itemAt(int i) const { return _table[i]; }
mesh::Packet* removeByIdx(int i); mesh::Packet* removeByIdx(int i);
}; };
@@ -27,7 +28,7 @@ public:
void free(mesh::Packet* packet) override; void free(mesh::Packet* packet) override;
void queueOutbound(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for) override; void queueOutbound(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for) override;
mesh::Packet* getNextOutbound(uint32_t now) override; mesh::Packet* getNextOutbound(uint32_t now) override;
int getOutboundCount() const override; int getOutboundCount(uint32_t now) const override;
int getFreeCount() const override; int getFreeCount() const override;
mesh::Packet* getOutboundByIdx(int i) override; mesh::Packet* getOutboundByIdx(int i) override;
mesh::Packet* removeOutboundByIdx(int i) override; mesh::Packet* removeOutboundByIdx(int i) override;