GpsGuard: let GPS correct a clock outside the plausible window
This commit is contained in:
1 parent
f5cbc18b83
commit
faabf34950
2 files changed
+5
-3
No files matched your search
@@ -1080,7 +1080,7 @@ region save
|
||||
#### GPS anti-spoofing guard (When built with `GPS_GUARD`)
|
||||
With `GPS_GUARD`, a fix becomes the node's last fix (position, telemetry, adverts) only after it passes plausibility checks: at least `GPS_GUARD_MIN_SATS` satellites, HDOP ≤ `GPS_GUARD_MAX_HDOP10`/10, inside the optional build-time region (`GPS_GUARD_LAT_MIN/MAX`, `GPS_GUARD_LON_MIN/MAX`), within the fence around the node's configured `lat`/`lon` (if set), no jump faster than `GPS_GUARD_MAX_SPEED_KMH`, and `GPS_GUARD_STABLE_FIXES` consistent fixes in a row. An unverified position is never reported.
|
||||
|
||||
GPS time is written to the clock only while such a fix is current, never earlier than the firmware build date, and, once the clock is valid, only within `GPS_GUARD_TIME_MAX_STEP` seconds for the first sync and within clock drift (`GPS_GUARD_TIME_DRIFT_BASE` s + `GPS_GUARD_TIME_DRIFT_PPM`) afterwards. Setting the clock manually (`time`, `clock sync`) resets that anchor.
|
||||
GPS time is written to the clock only while such a fix is current, never earlier than the firmware build date, and, once the clock holds a plausible time (from the build date to 10 years after it), only within `GPS_GUARD_TIME_MAX_STEP` seconds for the first sync and within clock drift (`GPS_GUARD_TIME_DRIFT_BASE` s + `GPS_GUARD_TIME_DRIFT_PPM`) afterwards. Setting the clock manually (`time`, `clock sync`) resets that anchor. A clock outside that window (e.g. a bogus date in 2080) is corrected by the first trusted fix.
|
||||
|
||||
Covers serial NMEA receivers (`MicroNMEALocationProvider`).
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
}
|
||||
|
||||
// GPS time is only written to the clock while a trusted fix is current, it is not
|
||||
// older than this firmware, and (once the clock is valid) it only nudges the clock.
|
||||
// older than this firmware, and (once the clock is plausible) it only nudges the clock.
|
||||
bool acceptTime(uint32_t gps_time, uint32_t clock_time) {
|
||||
const char* why = NULL;
|
||||
long step = 0;
|
||||
@@ -208,7 +208,9 @@ public:
|
||||
why = "nofix";
|
||||
} else if (gps_time < minEpoch() || gps_time > maxEpoch()) {
|
||||
why = "range";
|
||||
} else if (clock_time >= minEpoch()) { // clock already holds a plausible time
|
||||
} else if (clock_time >= minEpoch() && clock_time <= maxEpoch()) {
|
||||
// The clock already holds a plausible time. A clock outside that window (e.g. a
|
||||
// bogus 2080 date at boot) is treated like an unset one, so GPS can correct it.
|
||||
step = (long)gps_time - (long)clock_time;
|
||||
long limit = GPS_GUARD_TIME_MAX_STEP;
|
||||
if (_time_accepted) {
|
||||
|
||||
Reference in new issue
Block a user