M2 step 6: Tracks, recorded to GPX in the background

`r` in the GNSS App (or `gnss track start|stop`) records a Track to
/gnss/tracks/YYYYMMDD-HHMMSS.gpx: a point every 5 s once moved 5 m
(lib/gnss/track, 7 tests: haversine, the rule, GPX text, the file name).
It keeps recording with the App closed, shows REC in the Status Bar, and
announces start and stop with a Toast. It needs a card and the time;
switching GNSS off stops it. Tracks are written like Captures: past 90 %
card usage, until full. Storage Clean-up gets a GNSS tracks category.

A Track cut short by a reset or power loss has no GPX footer; the GNSS
Service closes such files at the next boot.

Verified on the device: a recorded Track and one interrupted by a reset
both parse as GPX 1.1 on the PC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-04 22:46:57 +02:00
co-authored by Claude Opus 5.5
parent 463ed2dda8
commit d7952612dd
13 changed files with 335 additions and 11 deletions
+8 -2
View File
@@ -99,6 +99,7 @@ static StatusInfo currentStatus() {
: g.fix == gnss::FixType::TwoD ? StatusInfo::Gnss::TwoD
: StatusInfo::Gnss::ThreeD;
s.gnssSatellites = g.satellitesUsed;
s.tracking = gnssService->tracking();
}
using WifiState = WifiController::State;
switch (wifi->state()) {
@@ -141,7 +142,7 @@ void setup() {
storageService = new StorageService(bus);
power = new PowerService(settings);
clockService = new ClockService(settings, bus);
gnssService = new GnssService(settings, *clockService, bus);
gnssService = new GnssService(settings, *clockService, *storageService, bus);
savedNetworks = new SavedNetworks(nvs);
savedNetworks->load();
wifi = new WifiService(settings, *savedNetworks, *clockService);
@@ -338,7 +339,7 @@ static const char* const kHelp =
"reboot restart\n"
"boot other restart into the other app slot (manual Rollback)\n"
"log level <0-5> ESP-IDF log level (0 none ... 5 verbose)\n"
"gnss status | gnss restart | gnss nmea on|off | gnss send <sentence without $ and checksum>\n"
"gnss status | gnss restart | gnss track start|stop | gnss nmea on|off | gnss send <sentence without $ and checksum>\n"
"crash the last crash: firmware, reason, task, backtrace\n"
"coredump erase forget the core dump in flash\n"
"key <name|char> press a key: up down left right select back home del tab, or one character\n"
@@ -403,6 +404,11 @@ static void runCommand(String line) {
if (line == "gnss status" && gnssService) gnssService->printStatus(console, millis());
if ((line == "gnss nmea on" || line == "gnss nmea off") && gnssService) gnssService->setEcho(line.endsWith("on"));
if (line == "gnss restart" && gnssService) gnssService->restart(millis());
if (line == "gnss track start" && gnssService) {
std::string why = gnssService->startTrack(millis());
console.printf("gnss track: %s\n", why.empty() ? "recording" : why.c_str());
}
if (line == "gnss track stop" && gnssService) gnssService->stopTrack();
if (line.startsWith("gnss send ") && gnssService) // the checksum is added
console.println(gnssService->send(line.substring(10).c_str()) ? "gnss: sent" : "gnss: off");
if (line == "crash") crash_report::print(console, nvs);