Opportunistic clock sync from verified advert timestamps#2423
Open
pelgraine wants to merge 3 commits intomeshcore-dev:devfrom
Open
Opportunistic clock sync from verified advert timestamps#2423pelgraine wants to merge 3 commits intomeshcore-dev:devfrom
pelgraine wants to merge 3 commits intomeshcore-dev:devfrom
Conversation
GPS-less repeaters that lose their clock on power cycle can now automatically sync from signature-verified advert timestamps. Opt-in via shouldSyncClockFromMesh() override (default: false). Only fires when local clock is clearly wrong (before Jan 2025). Closes meshcore-dev#1329
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1329. Related: #2132, #1332, #1882.
Problem
GPS-less repeaters lose their clock on every power cycle, reverting to the firmware default (~May 2024). This means their adverts carry stale timestamps until an admin manually syncs the clock via serial, the mobile app, or a remote management command. For inaccessible repeaters (rooftops, hilltops, solar-powered sites that reboot daily), manual sync is impractical.
Solution
Add an opt-in mechanism for nodes to sync their local RTC from signature-verified advert timestamps. When a node's clock is clearly wrong (before Jan 2025) and it receives a valid advert with a sane timestamp (Jan 2025 – Jan 2036), it adopts that timestamp.
The sync only fires when:
shouldSyncClockFromMesh()(defaults tofalse)Once the clock is set past Jan 2025, the sync stops firing — it won't overwrite a valid clock with subsequent adverts.
Changes
src/Mesh.h— New virtual method:src/Mesh.cpp— 14 lines added after advert signature verification (inside thePAYLOAD_TYPE_ADVERThandler), beforeonAdvertRecv()call. Checks the opt-in gate, validates both local and incoming timestamps, and callssetCurrentTime()if appropriate.examples/simple_repeater/MyMesh.h— Single-line override:What this does NOT do
Testing
clock synced from advert: <epoch>Tested