mirror of
https://github.com/agessaman/MeshCore.git
synced 2026-09-26 11:38:08 +00:00
Commit 22eb9b87 ("Revert 'Merge remote-tracking branch origin/dev...'")
reverted an entire upstream merge to escape a bad merge state, dropping
860 lines across 66 files. Among the collateral never reconciled on a
later re-merge was eb4fa032's token-bucket duty-cycle enforcement — the
mechanism that keeps nodes under a configured airtime budget (and EU
868 MHz nodes under the legally-mandated duty cycle). The fork had fallen
back to fixed per-packet spacing (getAirtimeBudgetFactor reverted to 2.0),
losing the windowed enforcement.
This was never an intentional design choice, so restoring it re-aligns the
fork with upstream and REDUCES the merge-conflict surface: Dispatcher.{h,cpp}
now diverge from upstream by watchdog additions only (77 insertions, 0
deletions) instead of rewriting checkSend()/loop().
Restored from upstream: updateTxBudget/tx_budget_ms/duty_cycle_window_ms/
getRemainingTxBudget/getDutyCycleWindowMs and the windowed budget logic in
Dispatcher; getOutboundTotal() and the 0xFFFFFFFF count-all sentinel in
StaticPoolPacketManager; the getOutboundTotal() call in StatsFormatHelper.
Re-applied the fork's MQTT radio-watchdog on top as pure additions
(#ifdef WITH_MQTT_BRIDGE), keeping formatRadioDiag.
Stored airtime_factor settings keep their meaning: fork's t*factor spacing
and upstream's 1/(1+factor) windowed budget yield the same steady-state
duty cycle; upstream additionally allows short bursts within the window.
Phase 2 (CAD / radio_fem_rxgain, which touch NodePrefs persistence and
per-board FEM wiring) is documented in RESTORE_UPSTREAM_NOTES.md, not done
here. Builds: Heltec_v3 observer + plain repeater. NEEDS ON-DEVICE
duty-cycle validation before merge.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <Dispatcher.h>
|
|
|
|
class PacketQueue {
|
|
mesh::Packet** _table;
|
|
uint8_t* _pri_table;
|
|
uint32_t* _schedule_table;
|
|
int _size, _num;
|
|
|
|
public:
|
|
PacketQueue(int max_entries);
|
|
mesh::Packet* get(uint32_t now);
|
|
bool add(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for);
|
|
int count() const { return _num; }
|
|
int countBefore(uint32_t now) const;
|
|
mesh::Packet* itemAt(int i) const { return _table[i]; }
|
|
mesh::Packet* removeByIdx(int i);
|
|
};
|
|
|
|
class StaticPoolPacketManager : public mesh::PacketManager {
|
|
PacketQueue unused, send_queue, rx_queue;
|
|
|
|
public:
|
|
StaticPoolPacketManager(int pool_size);
|
|
|
|
mesh::Packet* allocNew() override;
|
|
void free(mesh::Packet* packet) override;
|
|
void queueOutbound(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for) override;
|
|
mesh::Packet* getNextOutbound(uint32_t now) override;
|
|
int getOutboundCount(uint32_t now) const override;
|
|
int getOutboundTotal() const override;
|
|
int getFreeCount() const override;
|
|
mesh::Packet* getOutboundByIdx(int i) override;
|
|
mesh::Packet* removeOutboundByIdx(int i) override;
|
|
void queueInbound(mesh::Packet* packet, uint32_t scheduled_for) override;
|
|
mesh::Packet* getNextInbound(uint32_t now) override;
|
|
}; |