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:
1 parent
bdaf1678da
commit
c7c9b812ab
6 files changed
+169
-5
No files matched your search
@@ -168,7 +168,8 @@ public:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled ? "1" : "0");
|
||||
// 0 off / 1 on / 2 duty cycle (see EnvironmentSensorManager::gpsDutyLoop)
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled == 2 ? "2" : (_prefs.gps_enabled ? "1" : "0"));
|
||||
if (_prefs.gps_interval > 0) {
|
||||
char interval_str[12]; // Max: 24 hours = 86400 seconds (5 digits + null)
|
||||
sprintf(interval_str, "%u", _prefs.gps_interval);
|
||||
|
||||
@@ -316,7 +316,10 @@ protected:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled?"1":"0");
|
||||
// 0 off / 1 on / 2 duty cycle -- pass the mode through, not a boolean, or
|
||||
// a duty-cycled node comes back from a reboot with GPS powered forever.
|
||||
const char* mode = _prefs.gps_enabled == 2 ? "2" : (_prefs.gps_enabled ? "1" : "0");
|
||||
sensors.setSettingValue("gps", mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user