Skip to content

gps: don't let the settle time close a periodic window before the time sync - #3845

Merged
fdlamotte merged 1 commit into
meshcore-dev:devfrom
Ve2mrx:fix/gps-sync-before-settle
Nov 15, 2026
Merged

fdlamotte merged 1 commit into
meshcore-dev:devfrom
Ve2mrx:fix/gps-sync-before-settle

Conversation

@Ve2mrx

@Ve2mrx Ve2mrx commented Nov 15, 2026

Copy link
Copy Markdown

In periodic mode, a window closes after GPS_FIX_SETTLE_MS (10 s) from the first fix even if the clock sync is still
pending. The sync needs about 4 s of continuous valid fixes (time_valid > 2, reset on any pass without a fix). After a
hot start the receiver can report a fix within seconds, before it's steady, and the window then closes unsynced. On a
board without an RTC the clock stays at its default (15 May 2024) until the next window, a whole period later.

Seen on a RAK4631 repeater with an L76K (RAK12501), gps period 1d: a reboot about 30 min after a fix gave
gps fix_stats ttf:5s/5s ok:1 miss:0 and clock 11:03 - 15/5/2024 UTC 10 min later. gps diag showed the
last UART byte, sentence and fix at the same moment, with 6 satellites and 188 sentences in all, about 5 s plus the
10 s settle. Every earlier fix on that unit was a 27 to 35 s cold start and synced fine.

This closes the window only once the sync has been tried (done, not needed, or refused by GPS_GUARD); the settle time
and the satellite count apply after that. The acquisition timeout (5 min once there's a fix) still bounds the window.

Tested

Same repeater, three hot starts within an hour of a fix (the OTA, then two reboots), clock about a minute after
each boot (a boot resets it to 15 May 2024, so a right clock means the GPS set it):

Boot ttf gps diag sentences Window clock
OTA 3 s 87 about 7 s right
reboot 9 s 279 about 22 s right
reboot 8 s 144 about 11.5 s right

(Window from the ok: count at about 12.5 sentences a second.) On the second one, gps diag about 11 s in still had
the GPS on with fix:1 fm:3 sat:6, and the time took about 13 s after the first fix to settle, so without this
change that window would most likely have closed at the 10 s settle mark, unsynced.
RAK_4631_repeater_gps_power (also with -D GPS_GUARD), Heltec_t114_repeater and RAK_4631_companion_radio_ble build.

Who did what: I worked on this with Claude Code. I found the wrong clock on my repeater and ran the commands. Claude
traced the cause, wrote the patch, and drafted this text, which I reviewed before posting.

🤖 Generated with Claude Code

…e sync

In periodic mode a window closed after GPS_FIX_SETTLE_MS (10 s) from the
first fix even if the clock sync was still pending. The sync needs about
4 s of continuous valid fixes (time_valid > 2, reset on any pass without
a fix), so after a hot start, when the receiver reports a fix within
seconds but not yet steadily, the window could close unsynced. On a
board without an RTC the clock then stays at its default until the next
window, a whole period later.

Close the window only once the sync has been tried (done, not needed, or
refused by GPS_GUARD); the settle time and the satellite count apply
after that. The acquisition timeout still bounds the window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fdlamotte

Copy link
Copy Markdown
Collaborator

looks good,

Thanks

@fdlamotte
fdlamotte merged commit 69bace8 into meshcore-dev:dev Nov 15, 2026
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.

2 participants