Merge pull request #1877 from DanielNovak/fix-countbefore-sentinel-regression
Fix countBefore regression: replace sentinel with getOutboundTotal()
This commit is contained in:
@@ -1716,7 +1716,7 @@ void MyMesh::handleCmdFrame(size_t len) {
|
|||||||
out_frame[i++] = STATS_TYPE_CORE;
|
out_frame[i++] = STATS_TYPE_CORE;
|
||||||
uint16_t battery_mv = board.getBattMilliVolts();
|
uint16_t battery_mv = board.getBattMilliVolts();
|
||||||
uint32_t uptime_secs = _ms->getMillis() / 1000;
|
uint32_t uptime_secs = _ms->getMillis() / 1000;
|
||||||
uint8_t queue_len = (uint8_t)_mgr->getOutboundCount(0xFFFFFFFF);
|
uint8_t queue_len = (uint8_t)_mgr->getOutboundTotal();
|
||||||
memcpy(&out_frame[i], &battery_mv, 2); i += 2;
|
memcpy(&out_frame[i], &battery_mv, 2); i += 2;
|
||||||
memcpy(&out_frame[i], &uptime_secs, 4); i += 4;
|
memcpy(&out_frame[i], &uptime_secs, 4); i += 4;
|
||||||
memcpy(&out_frame[i], &_err_flags, 2); i += 2;
|
memcpy(&out_frame[i], &_err_flags, 2); i += 2;
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
|
|||||||
if (payload[0] == REQ_TYPE_GET_STATUS) { // guests can also access this now
|
if (payload[0] == 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(0xFFFFFFFF);
|
stats.curr_tx_queue_len = _mgr->getOutboundTotal();
|
||||||
stats.noise_floor = (int16_t)_radio->getNoiseFloor();
|
stats.noise_floor = (int16_t)_radio->getNoiseFloor();
|
||||||
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();
|
||||||
@@ -1321,5 +1321,5 @@ bool MyMesh::hasPendingWork() const {
|
|||||||
#if defined(WITH_BRIDGE)
|
#if defined(WITH_BRIDGE)
|
||||||
if (bridge.isRunning()) return true; // bridge needs WiFi radio, can't sleep
|
if (bridge.isRunning()) return true; // bridge needs WiFi radio, can't sleep
|
||||||
#endif
|
#endif
|
||||||
return _mgr->getOutboundCount(0xFFFFFFFF) > 0;
|
return _mgr->getOutboundTotal() > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
|
|||||||
if (payload[0] == REQ_TYPE_GET_STATUS) {
|
if (payload[0] == 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(0xFFFFFFFF);
|
stats.curr_tx_queue_len = _mgr->getOutboundTotal();
|
||||||
stats.noise_floor = (int16_t)_radio->getNoiseFloor();
|
stats.noise_floor = (int16_t)_radio->getNoiseFloor();
|
||||||
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();
|
||||||
|
|||||||
@@ -90,6 +90,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(uint32_t now) const = 0;
|
virtual int getOutboundCount(uint32_t now) const = 0;
|
||||||
|
virtual int getOutboundTotal() 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;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ PacketQueue::PacketQueue(int max_entries) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int PacketQueue::countBefore(uint32_t now) const {
|
int PacketQueue::countBefore(uint32_t now) const {
|
||||||
|
if (now == 0xFFFFFFFF) return _num; // sentinel: count all entries regardless of schedule
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (int j = 0; j < _num; j++) {
|
for (int j = 0; j < _num; j++) {
|
||||||
if ((int32_t)(_schedule_table[j] - now) > 0) continue; // scheduled for future... ignore for now
|
if ((int32_t)(_schedule_table[j] - now) > 0) continue; // scheduled for future... ignore for now
|
||||||
@@ -97,6 +99,10 @@ int StaticPoolPacketManager::getOutboundCount(uint32_t now) const {
|
|||||||
return send_queue.countBefore(now);
|
return send_queue.countBefore(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int StaticPoolPacketManager::getOutboundTotal() const {
|
||||||
|
return send_queue.count();
|
||||||
|
}
|
||||||
|
|
||||||
int StaticPoolPacketManager::getFreeCount() const {
|
int StaticPoolPacketManager::getFreeCount() const {
|
||||||
return unused.count();
|
return unused.count();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public:
|
|||||||
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(uint32_t now) const override;
|
int getOutboundCount(uint32_t now) const override;
|
||||||
|
int getOutboundTotal() 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;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
board.getBattMilliVolts(),
|
board.getBattMilliVolts(),
|
||||||
ms.getMillis() / 1000,
|
ms.getMillis() / 1000,
|
||||||
err_flags,
|
err_flags,
|
||||||
mgr->getOutboundCount(0xFFFFFFFF)
|
mgr->getOutboundTotal()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user