Skip to content

GPS: cache model and baudrate and skip full sweep every startup#10544

Open
HarukiToreda wants to merge 10 commits into
developfrom
GPS-Probe
Open

GPS: cache model and baudrate and skip full sweep every startup#10544
HarukiToreda wants to merge 10 commits into
developfrom
GPS-Probe

Conversation

@HarukiToreda
Copy link
Copy Markdown
Contributor

@HarukiToreda HarukiToreda commented May 24, 2026

Description

Boot was spending too much time sweeping GPS models and baud rates every time, making nodes slugish and unresponsive on first boot.
This change keeps startup fast by remembering the last known-good GPS settings, while still verifying the cached value is real on each boot.

What changed

New GPS cache flow

  • Save detected GPS model + baud to /prefs/gps_probe_cache.dat.
  • On next boot, load that cache first.
  • Verify the cached model/baud is actually alive before trusting it.
  • If cached settings fail verification:
    • clear cache as stale
    • mark GPS as not present for this boot
    • skip full sweep this boot
    • allow full probe again on next boot

Setup/runtime behavior updates

  • GPS::setup() now:
    • tries cached probe first (once per boot)
    • falls back to normal probe only when no usable cache
    • saves cache after successful detection
  • GPS::runOnce() now:
    • disables GPS for current boot if cached check failed / no detected model

Maintainability

  • Added short comments around the new cache/probe blocks so the startup decision path is easier to follow.

How to test

  1. Flash firmware and boot once with GPS connected.
  2. Confirm log shows cache save/load messages.
  3. Reboot and confirm it uses cached model/baud (no full probe sweep).
  4. Boot with GPS disconnected:
    • should mark cached probe stale
    • should disable GPS for that boot
  5. Reconnect GPS and reboot:
    • should run full probe again and cache fresh values.

GNSS Chips to test:

  • L76K
  • AG3335
  • AGTM3332D
  • Ublox 10
  • Ublox 9
  • Ublox 7
  • Ublox 6
  • UC6580

@HarukiToreda HarukiToreda requested a review from thebentern May 24, 2026 22:04
@HarukiToreda HarukiToreda self-assigned this May 24, 2026
@HarukiToreda HarukiToreda added enhancement New feature or request gps GPS subsystem labels May 24, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c045e4a55b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/gps/GPS.cpp Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 improves GPS startup responsiveness by persisting the last known-good GNSS model + baud rate to the filesystem and attempting a fast “cached verify” path on subsequent boots, avoiding a full model/baud sweep on every startup.

Changes:

  • Add a versioned /prefs/gps_probe_cache.dat record to cache detected GNSS model and baud.
  • On boot, try cached model/baud first and actively/passively verify the GPS is present before trusting it.
  • If cached verification fails, clear the cache and suppress full probing for the remainder of that boot (GPS marked not present until reboot).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/gps/GPS.h Adds cache/probe helper declarations and new state to track cached model/baud and boot-latched outcomes.
src/gps/GPS.cpp Implements cache load/save/clear, cached presence verification logic, and integrates the cached flow into GPS::setup() / GPS::runOnce().

Comment thread src/gps/GPS.cpp
Comment thread src/gps/GPS.cpp
Comment thread src/gps/GPS.cpp
Comment thread src/gps/GPS.cpp Outdated
Comment thread src/gps/GPS.cpp
@fifieldt
Copy link
Copy Markdown
Member

fifieldt commented May 25, 2026

Good idea.

Just to note: changes to detection code of this extent should be tested on each GPS chip we support prior to merge.

Testing hitlist:

  • L76K
  • AG3335
  • AGTM3332D
  • Ublox 10
  • Ublox 9
  • Ublox 7
  • Ublox 6
  • UC6580

HarukiToreda and others added 6 commits May 24, 2026 23:42
@HarukiToreda
Copy link
Copy Markdown
Contributor Author

So far tested on
L76K
Ublox 9
Ublox 7

@thebentern thebentern requested a review from fifieldt May 30, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request gps GPS subsystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants