Skip to content

GPS: poll up to 5s for cold-start detection instead of a single 1s check#2838

Open
benskigomez wants to merge 1 commit into
meshcore-dev:devfrom
benskigomez:fix/gps-cold-start-detection
Open

GPS: poll up to 5s for cold-start detection instead of a single 1s check#2838
benskigomez wants to merge 1 commit into
meshcore-dev:devfrom
benskigomez:fix/gps-cold-start-detection

Conversation

@benskigomez

Copy link
Copy Markdown

Problem

EnvironmentSensorManager::initBasicGPS() waits a fixed 1 second, then decides the GPS is present only if NMEA data has already arrived. Cold-start GPS modules often need 2–5 seconds before emitting their first sentence, so on a cold boot detection frequently fails.

A failed detection sets gps_detected = false, which hides all GPS CLI settings and disables GPS time sync until the next reboot — so the GPS appears permanently dead even though the hardware is fine. This affects the ~20 GPS-equipped variants that don't set the ENV_SKIP_GPS_DETECT/PERSISTANT_GPS bypass flags.

Fix

Poll for up to ~5 seconds (in 250 ms steps) and return as soon as any data appears. Fast modules are detected almost immediately and add no boot delay; slow cold-start modules now get enough time. The ENV_SKIP_GPS_DETECT bypass is unchanged.

Trade-off

Boards that have ENV_INCLUDE_GPS but no physical GPS will now wait the full ~5 s at boot (vs. 1 s before), since detection never succeeds. This seemed the right call given the alternative is GPS silently not working, but happy to shorten the cap if preferred.

Testing

Builds clean (verified on a ThinkNode M6 companion build). The change is a drop-in replacement for the single check.

Fixes #2258.

@ViezeVingertjes ViezeVingertjes 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.

PR targets main instead of dev, approve when fixed. 👍🏼

initBasicGPS() waited a fixed 1 second and then decided the GPS was
present only if NMEA data had already arrived. Cold-start GPS modules
often need 2-5 seconds before they emit their first sentence, so on a
cold boot detection frequently failed. A failed detection sets
gps_detected = false, which hides all GPS CLI settings and disables GPS
time sync until the next reboot - so the GPS appears permanently dead
even though the hardware is fine.

Poll for up to ~5 seconds (in 250ms steps) and return as soon as any
data appears. Fast modules are detected almost immediately and add no
boot delay; slow cold-start modules now get enough time. The
ENV_SKIP_GPS_DETECT bypass is unchanged.

Fixes meshcore-dev#2258.
@benskigomez benskigomez force-pushed the fix/gps-cold-start-detection branch from c826756 to 27feb73 Compare June 26, 2026 14:44
@benskigomez benskigomez changed the base branch from main to dev June 26, 2026 14:44
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.

GPS detection in initBasicGPS() too short — most repeater variants affected

3 participants