feat(gps): duty-cycle the receiver, for nodes that run GPS only for the clock

Measured on a SenseCAP Solar P1-Pro: a continuously powered L76K costs 46.0 mA
(paired A/B, spread 43.7-47.5), which is more than everything else on the node
put together -- it runs at ~24 mA with GPS asleep. A mast repeater does not need
a continuous fix; it needs its volatile RTC set, or clients drop its replies.

`gps duty` powers the receiver only around a sync and cuts it in between. The
cadence matches the 30-minute re-sync MicroNMEALocationProvider already does, so
clock accuracy is unchanged while 42-45 of those 46 mA come back -- 42 even in
the pathological case where a fix never arrives.

Encoded as gps_enabled == 2 rather than a new pref, so the prefs file layout is
untouched and an older build just clamps the value.

The cadence is owned by the state machine, not by the provider's own re-arm, for
a concrete reason: with the receiver unpowered nothing feeds the parser, and
MicroNMEA keeps reporting the LAST fix as valid -- a provider-driven re-arm
would therefore set the RTC to a half-hour-old timestamp. Hence syncTime() (which
clears the parser) on every wake plus an own timer, and int32_t deltas so the
49-day millis() wrap cannot park GPS on or off forever.

Verified on hardware, both paths: with sky `duty, asleep, fix, 7 sats` (fix
taken, clock set, receiver cut); indoors `awake` for exactly 300 s and then
`asleep` with an hourly retry.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5 committed 2026-08-06 10:05:26 +02:00
1 parent bdaf1678da
commit c7c9b812ab
6 files changed
+169 -5

No files matched your search

+12 -1
View File
@@ -955,13 +955,24 @@ region save
- `gps <state>`
**Parameters:**
- `state`: `on`|`off`
- `state`: `on`|`off`|`duty`
**Default:** `off`
**Note:** Output format:
- `off` when the GPS hardware is disabled
- `on, {active|deactivated}, {fix|no fix}, {sat count} sats` when the GPS hardware is enabled
- `duty, {awake|asleep}, {fix|no fix}, {sat count} sats` in duty-cycle mode
`gps duty` powers the receiver only around a clock sync and cuts it in between.
It is meant for a node that runs GPS purely to keep its (volatile) RTC set — a
mast or solar repeater — where a receiver drawing tens of mA continuously
dwarfs the rest of the power budget. Clock accuracy is unchanged: the sync
cadence matches the periodic re-sync that `gps on` already does. The position
still comes from prefs (see `gps advert`), so duty mode does not affect what a
repeater advertises. Build-time knobs: `GPS_DUTY_SYNC_INTERVAL_SECS` (1800),
`GPS_DUTY_MAX_AWAKE_SECS` (300, the cap on one attempt) and
`GPS_DUTY_RETRY_SECS` (3600, backoff after a window with no fix).
---