A cold start can take up to ~30 min with a weak sky view, so the default
limit before the first fix since boot goes from 15 min to 1 h.
The limit is now a GPS preference, set with `gps firstfix <duration>`
(0 = no limit, at most 1 day) and saved with the other GPS settings, so
repeaters and companions can use different values without a rebuild.
GPS_FIRST_FIX_TIMEOUT_MS stays as the build default.
Before the first fix since boot, a periodic acquisition had no timeout. If no
fix is accepted (no sky view, no antenna, or a guard rejecting spoofed fixes),
the receiver then stayed on until a fix was accepted.
Give that window its own limit, GPS_FIRST_FIX_TIMEOUT_MS (15 min by default,
enough for a full almanac; 0 keeps the old behaviour). It counts as a miss and
the next acquisition starts after the configured period.
Add a 16-byte zeroed tail behind the 100-byte NMEA buffer. MicroNMEA's
fixed-width field skips can read a few bytes past the end of a malformed
sentence; with the tail those reads land on NUL bytes.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
#3813 removed the telemetry channel for the GPS time alert. Remove the
docs sentence that still described it and the now unused
GpsGuard::getAlertOffset().
The remote-CLI reply buffers in onPeerDataRecv() (repeater, room server,
sensor) and BaseChatMesh were sized temp[166] for a 5-byte datagram
header plus 161 bytes of reply. But MyMesh::handleCommand() first
reflects a 3-byte correlation prefix (e.g. 'aa|') into the reply, after
which CommonCLI commands may write up to 160 chars + NUL into the
remaining 158 bytes -- overflowing the buffer by 2 bytes (e.g. a full
'regions' listing via exportTo(reply, 160)).
Triggering this remotely crashes the node (observed as an unresponsive
repeater after a prefixed 'regions' query); the 2 out-of-bounds bytes
are a printable region-name character and a NUL.
Size the buffers for the full worst case instead:
5 header + 3 prefix + 160 reply + 1 NUL = 169.
Verified with a host ASan harness reproducing the exact layout:
prefixed 'regions' with a 25-region listing overflowed temp[166]
(BufStream::write, RegionMap.cpp) and now passes clean with temp[169];
unprefixed (serial) path unaffected.
When the last GPS time check passed but there is no current trusted fix
(e.g. the GPS is asleep between periodic fixes), gps guard showed
"time rej nofix", which reads like a rejection although the clock is fine.
Show "time wait" instead. A real rejection without a trusted fix (GPS time
arriving while fixes are rejected) still shows "rej nofix".
The probe list was wired only in variants/promicro/target.cpp. It is now the
default list of NmeaGpsDriver when GPS_BAUD_PROBE_LIST is set, so a variant
enables baud autodetection with a build flag alone.
Station G2 and G3 enable it: their Grove UART connector is used with M5Stack
Unit GPS modules, which default to 115200.
A spoofed GPS signal can move a fixed node anywhere and set its clock to
any time; the clock only moves forward, so a time pushed into the future
breaks timestamps and replay protection until fixed by hand.
With GPS_GUARD, MicroNMEALocationProvider asks a GpsGuard before a fix is
stored as the last fix (satellites, HDOP, optional region box, fence
around the configured position, jump speed, N stable fixes) and before
GPS time is written to the clock (trusted fix current, not before the
build date, small steps once the clock is valid, drift-sized after the
first sync). Without a trusted fix no live position is reported.
CLI in CommonGpsPrefs: 'gps guard', 'gps guard accept', 'gps fence',
'gps ref'; CommonCLI keeps the reference on set lat/lon and gps setloc,
resets the time anchor on manual clock sets and adds 'time force'.
Ported from #3736 onto the GpsDriver/LocationProvider refactor.