Skip to content

Dispatcher: skip the periodic AGC reset while packets are being received - #3752

Open
AlexandrTyshchenko wants to merge 1 commit into
meshcore-dev:devfrom
AlexandrTyshchenko:feature/agc-reset-when-idle
Open

AlexandrTyshchenko wants to merge 1 commit into
meshcore-dev:devfrom
AlexandrTyshchenko:feature/agc-reset-when-idle

Conversation

@AlexandrTyshchenko

Copy link
Copy Markdown

Problem

With agc.reset.interval > 0, Dispatcher::loop() calls resetAGC() on a fixed timer
(restarted only after a TX). Each reset puts the radio into warm sleep, recalibrates and
re-arms RX, so the node is deaf for that time. On a busy channel this costs packets every
interval, although the gain cannot be stuck: packets are still being decoded.

Change

When the AGC timer fires:

  • skip the reset if a valid packet was received within the last reset interval
    (the gain is fine), or if a packet is queued for transmit;
  • reset anyway at least once per AGC_FORCED_RESET_MILLIS (default 24 h, overridable
    build flag), and on the first tick after boot;
  • otherwise reset as before.

"Valid packet" means one that passed tryParsePacket() (set right after logRx()), so
corrupt/garbage receptions don't count as hearing.

This is the same logic Meshtastic uses on develop
(RadioLibInterface::periodicRadioMaintenance(): check every 60 s, reset only if nothing
was decoded for AGC_IDLE_RESET_MS = 60 s, forced every AGC_FORCED_RESET_MS = 24 h,
never with TX queued). Here the idle window is the configured agc.reset.interval itself.

Nodes with agc.reset.interval 0 (the default) are not affected. MESH_DEBUG builds log
each decision (AGC reset / AGC reset skipped, last rx N ms ago / ... tx queued).

Testing

ProMicro nRF52840 + E22-400M22S (SX1268), repeater, MESH_DEBUG, agc.reset.interval 8:

  • quiet channel: reset every 8 s;
  • adverts received at t and t+6 s: the next two resets skipped
    (last rx 923 ms ago, last rx 1673 ms ago);
  • after 8 s with nothing received: resets resumed;
  • no RX/TX errors; the node has since run with agc.reset.interval 60.

Builds: ProMicro_repeater, RAK_4631_repeater, Heltec_v3_repeater.

Not tested: the 24 h forced reset (logic only), and the "TX queued" branch was not hit
in the bench run.

Notes

A reset takes the radio off the air. As in Meshtastic (develop), skip the
periodic reset if a packet was decoded within the last reset interval or
a packet is queued for transmit; the gain is not stuck then. Still reset
at least once per AGC_FORCED_RESET_MILLIS (default 24 h). Only matters
when agc.reset.interval > 0.
@AlexandrTyshchenko
AlexandrTyshchenko changed the base branch from main to dev November 8, 2026 18:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant