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
@@ -4,6 +4,26 @@
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
|
||||
// GPS duty cycle (`gps duty`, gps_enabled == 2). A repeater that runs GPS only
|
||||
// for the clock does not need a continuous fix: the receiver is powered just
|
||||
// long enough to sync the RTC, then cut. On a solar node this is the single
|
||||
// biggest lever there is -- an L76K draws 25-35 mA, an order of magnitude more
|
||||
// than the whole radio + MCU budget it is being spent next to.
|
||||
#ifndef GPS_DUTY_SYNC_INTERVAL_SECS
|
||||
// Same cadence as MicroNMEALocationProvider::TIME_SYNC_INTERVAL, so clock
|
||||
// accuracy is unchanged from `gps on` -- only the power in between differs.
|
||||
#define GPS_DUTY_SYNC_INTERVAL_SECS 1800
|
||||
#endif
|
||||
#ifndef GPS_DUTY_MAX_AWAKE_SECS
|
||||
// Cap on one sync attempt: a blocked sky must not turn duty cycle back into
|
||||
// "always on". A cold fix is tens of seconds, so this is deliberately loose.
|
||||
#define GPS_DUTY_MAX_AWAKE_SECS 300
|
||||
#endif
|
||||
#ifndef GPS_DUTY_RETRY_SECS
|
||||
// Backoff after a window that produced no fix (antenna, snow, indoors).
|
||||
#define GPS_DUTY_RETRY_SECS 3600
|
||||
#endif
|
||||
|
||||
class EnvironmentSensorManager : public SensorManager {
|
||||
protected:
|
||||
static const int MAX_ACTIVE_SENSORS = 16;
|
||||
@@ -24,9 +44,17 @@ protected:
|
||||
uint32_t gps_update_interval_sec = 1;
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
// Duty-cycle state. `gps_duty` is the mode; `gps_active` stays the truth
|
||||
// about the receiver being powered, so everything that already reads it
|
||||
// (telemetry, settings) keeps working unchanged.
|
||||
bool gps_duty = false;
|
||||
uint32_t gps_wake_at = 0; // millis of the next sync attempt
|
||||
uint32_t gps_awake_until = 0; // millis the current attempt gives up at
|
||||
|
||||
LocationProvider* _location;
|
||||
void start_gps();
|
||||
void stop_gps();
|
||||
void gpsDutyLoop();
|
||||
void initBasicGPS();
|
||||
#ifdef RAK_BOARD
|
||||
void rakGPSInit();
|
||||
@@ -50,4 +78,5 @@ public:
|
||||
const char* getSettingName(int i) const override;
|
||||
const char* getSettingValue(int i) const override;
|
||||
bool setSettingValue(const char* name, const char* value) override;
|
||||
int scanI2C(char* dest, size_t max_len) override;
|
||||
};
|
||||
Reference in new issue
Block a user