Skip to content

Limit the first periodic GPS acquisition after boot - #3823

Merged
fdlamotte merged 2 commits into
meshcore-dev:devfrom
AlexandrTyshchenko:fix/gps-first-fix-timeout
Nov 13, 2026
Merged

fdlamotte merged 2 commits into
meshcore-dev:devfrom
AlexandrTyshchenko:fix/gps-first-fix-timeout

Conversation

@AlexandrTyshchenko

@AlexandrTyshchenko AlexandrTyshchenko commented Nov 12, 2026 •

Copy link
Copy Markdown

Before the first fix since boot, a periodic acquisition has no timeout ("cold start can be long"). If no fix is ever accepted — no sky view, a disconnected antenna, or GPS_GUARD rejecting spoofed fixes — the receiver stays on until a fix is accepted. On a solar node that's tens of mA for as long as the condition lasts, and the fix-stats never report a miss.

This gives that window its own limit: 1 h by default (GPS_FIRST_FIX_TIMEOUT_MS), changed at runtime with gps firstfix <duration> (0 = no limit, at most 1d) and saved with the other GPS settings. When it expires, the window counts as a miss and the next acquisition starts after the configured period. Windows after the first fix still use GPS_PERIODIC_ACQUISITION_TIMEOUT_MS (5 min).

Tested on a Faketec (nRF52840, u-blox MAX-M10S, GPS_GUARD), built with GPS_FIRST_FIX_TIMEOUT_MS=60000 and a 2 min period:

  • boot without antenna: receiver powered off after ~60 s, gps fix_stats → miss:1; next window the same (miss:2)
  • antenna connected during GPS spoofing (all fixes rejected as rej region): every window stopped at the limit, miss:3 … miss:9 over ~25 min
  • after the spoofing ended: fix accepted, ttf:7s ok:1 miss:0

Also builds for RAK_4631_repeater, with and without GPS_GUARD / GPS_FIRST_FIX_TIMEOUT_MS=0.

gps firstfix (second commit), same board: get/set, persistence across reboot, invalid values rejected (abc, 2d), and gps firstfix 5s + reboot: GPS off after 5 s without a fix, miss:1. Also builds for Heltec_v3_companion_radio_ble.

Before the first fix since boot, a periodic acquisition had no timeout. If no
fix is accepted (no sky view, no antenna, or a guard rejecting spoofed fixes),
the receiver then stayed on until a fix was accepted.

Give that window its own limit, GPS_FIRST_FIX_TIMEOUT_MS (15 min by default,
enough for a full almanac; 0 keeps the old behaviour). It counts as a miss and
the next acquisition starts after the configured period.
@AlexandrTyshchenko

Copy link
Copy Markdown
Author

@fdlamotte gentle ping on this one too. Without it, a node that never gets a valid fix after boot (no sky view, or every fix rejected by GPS_GUARD under spoofing) keeps the GPS on forever in periodic mode. It adds GPS_FIRST_FIX_TIMEOUT_MS (15 min default, 0 = off). Tested on hardware (log in the description), merges cleanly into dev.

@fdlamotte

Copy link
Copy Markdown
Collaborator

At first I was doing that, but where I am nodes take sometimes 30min to get a fix (even outside) then as the almanach is downloaded the fix are shorter ... so I set up this policy

Could make it something like an hour

It's also a different problem for repeaters and companions

maybe it would be good to have a preference for that (instead of a compile time option) ?

A cold start can take up to ~30 min with a weak sky view, so the default
limit before the first fix since boot goes from 15 min to 1 h.

The limit is now a GPS preference, set with `gps firstfix <duration>`
(0 = no limit, at most 1 day) and saved with the other GPS settings, so
repeaters and companions can use different values without a rebuild.
GPS_FIRST_FIX_TIMEOUT_MS stays as the build default.
@AlexandrTyshchenko

Copy link
Copy Markdown
Author

Agreed, thanks. Updated:

  • default limit before the first fix is now 1 h;
  • it is a saved GPS setting, gps firstfix <duration> (0 = no limit, at most 1d), so repeaters and companions can use different values; GPS_FIRST_FIX_TIMEOUT_MS is only the build default.

Tested on our Faketec board: get/set, persistence across reboot, and a 5 s limit after reboot (GPS off, miss:1).

@fdlamotte

Copy link
Copy Markdown
Collaborator

looks good to me, nice job

@fdlamotte
fdlamotte merged commit 7a900cf into meshcore-dev:dev Nov 13, 2026
20 checks passed
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