Skip to content

Fix TransmitHistory to improve epoch handling#10017

Merged
thebentern merged 10 commits into
masterfrom
fix-node-info
Mar 27, 2026
Merged

Fix TransmitHistory to improve epoch handling#10017
thebentern merged 10 commits into
masterfrom
fix-node-info

Conversation

@thebentern

Copy link
Copy Markdown
Contributor

Closes #9901

@Xaositek please test. Also make sure you test for the original problem of devices rebooting without a real timestamp from RTC, GPS or NTP. Maybe take a RAK4631 with no GPS and reboot a second or two after the initial nodeinfo send

@thebentern thebentern requested review from Xaositek and Copilot March 27, 2026 00:03
@github-actions github-actions Bot added needs-review Needs human review bugfix Pull request that fixes bugs labels Mar 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts how TransmitHistory reconstructs throttling state across boots to avoid incorrectly suppressing first broadcasts (notably NodeInfo) after long power-off periods, addressing #9901.

Changes:

  • Stop seeding lastMillis during TransmitHistory::loadFromDisk() and rely on epoch-to-millis reconstruction.
  • Add a test helper API to set stored epoch values directly for test scenarios.
  • Expand unit tests to cover the #9901 regression cases (long gap allows send; short gap still throttles).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/mesh/TransmitHistory.cpp Removes lastMillis seeding on load; adds epoch-setter helper; documents wraparound behavior.
src/mesh/TransmitHistory.h Declares new setLastSentAtEpoch() helper method.
test/test_transmit_history/test_main.cpp Updates existing persistence test expectations and adds regression tests for #9901 scenarios.

Comment thread src/mesh/TransmitHistory.cpp
Comment thread src/mesh/TransmitHistory.h
Comment thread src/mesh/TransmitHistory.cpp Outdated
Comment thread test/test_transmit_history/test_main.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread test/test_transmit_history/test_main.cpp
@Xaositek

Xaositek commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Tested this morning with results below; overall works great! Test unit was a RAK3401 1-watt radio.

First Boot after being offline for 2 days:
INFO | 08:04:55 21 [Router] Heard new node on ch. 0, send NodeInfo and ask for response INFO | 08:04:55 21 [Router] Send owner !4710878e/Piper Test 1-watt/1WAT

Second Boot:
INFO | 08:05:41 33 [NodeInfo] Send our nodeinfo to mesh (wantReplies=0) DEBUG | 08:05:41 33 [NodeInfo] Skip send NodeInfo since we sent it <600s ago

Took node offline immediately and let set for 13 minutes:
INFO | 08:18:11 31 [NodeInfo] Send our nodeinfo to mesh (wantReplies=0) INFO | 08:18:11 31 [NodeInfo] Send owner !4710878e/Piper Test 1-watt/1WAT

Powered off and back on:
INFO | 08:19:11 33 [NodeInfo] Send our nodeinfo to mesh (wantReplies=0) DEBUG | 08:19:11 33 [NodeInfo] Skip send NodeInfo since we sent it <600s ago

@Xaositek

Copy link
Copy Markdown
Contributor

Testing without Bluetooth, RTC or GPS....

First Boot:
INFO | ??:??:?? 32 [NodeInfo] Send our nodeinfo to mesh (wantReplies=0) INFO | ??:??:?? 32 [NodeInfo] Send owner !4710878e/Piper Test 1-watt/1WAT

Second Boot:
INFO | ??:??:?? 31 [NodeInfo] Send our nodeinfo to mesh (wantReplies=0) INFO | ??:??:?? 31 [NodeInfo] Send owner !4710878e/Piper Test 1-watt/1WAT

Confirmed fixed when it's attached to a Phone, but when missing any time source it appears to not have suppression.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/mesh/TransmitHistory.h:53

  • getLastSentToMeshEpoch() is documented as returning "epoch seconds", but history can now store boot-relative seconds when ENTRY_FLAG_BOOT_RELATIVE is set. Either adjust this comment (and/or rename the API) to reflect that the returned value may be boot-relative, or provide a separate accessor for the raw persisted timestamp vs. a true epoch value.
    /**
     * Get the last transmit epoch seconds for a given key, or 0 if unknown.
     */
    uint32_t getLastSentToMeshEpoch(uint16_t key) const;

Comment thread test/test_transmit_history/test_main.cpp Outdated
Comment thread test/test_transmit_history/test_main.cpp Outdated
Comment thread src/mesh/TransmitHistory.h
@thebentern thebentern merged commit 99abfeb into master Mar 27, 2026
57 of 71 checks passed
skrashevich pushed a commit to skrashevich/meshtastic-firmware that referenced this pull request Apr 4, 2026
* Fix TransmitHistory to improve epoch handling

* Enable epoch handling in unit tests

* Improve comments and test handling for epoch persistence in TransmitHistory

* Add boot-relative timestamp handling and unit tests for TransmitHistory

* loadFromDisk should handle legacy entries and clean up old v1 files after migration

* Revert "loadFromDisk should handle legacy entries and clean up old v1 files after migration"

This reverts commit eb7e5c7.

* Add NodeInfoModule integration for RTC quality changes and trigger immediate checks

* Update test conditions for RTC quality checks
@caveman99 caveman99 deleted the fix-node-info branch April 12, 2026 15:16
jeek pushed a commit to jeek/Meshtastic-Exploiteers-Hacker-Pager that referenced this pull request Jun 30, 2026
* Fix TransmitHistory to improve epoch handling

* Enable epoch handling in unit tests

* Improve comments and test handling for epoch persistence in TransmitHistory

* Add boot-relative timestamp handling and unit tests for TransmitHistory

* loadFromDisk should handle legacy entries and clean up old v1 files after migration

* Revert "loadFromDisk should handle legacy entries and clean up old v1 files after migration"

This reverts commit eb7e5c7.

* Add NodeInfoModule integration for RTC quality changes and trigger immediate checks

* Update test conditions for RTC quality checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs needs-review Needs human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants