Public Access
M2 step 3: GNSS Service, with standby and the clock from a Fix
The GNSS Service reads the receiver (UART 15/13, 115200, 1 KB buffer) from its 50 ms tick and feeds the NMEA parser. With a Fix it sets the clock (GNSS is the most trusted TimeSource) and refreshes it every 10 min. Settings gets GNSS On/Off and the coordinate format (Q64). Off puts the receiver in standby with $PCAS12,65535, renewed hourly; On wakes it with a hot start, $PCAS10,0. Both measured on the device: the output stops within a second, and a command wakes it within a second. Commands: gnss status (Fix, satellites per constellation, bytes and sentences), gnss nmea on|off, gnss send <sentence>, gnss restart. The probe is gone; never drive GPIO 15 (the receiver's output): the first probe's swapped-pin attempt silenced it until a power cycle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
+10
-28
@@ -2,7 +2,6 @@
|
||||
#include <M5Cardputer.h>
|
||||
#include <SD.h>
|
||||
|
||||
#include <esp_task_wdt.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
@@ -27,6 +26,7 @@
|
||||
#include "services/irc_service.h"
|
||||
#include "services/clock_service.h"
|
||||
#include "services/debug_console.h"
|
||||
#include "services/gnss_service.h"
|
||||
#include "services/power_service.h"
|
||||
#include "services/storage_service.h"
|
||||
#include "services/update_service.h"
|
||||
@@ -52,6 +52,7 @@ static BatteryService* battery;
|
||||
static StorageService* storageService;
|
||||
static PowerService* power;
|
||||
static ClockService* clockService;
|
||||
static GnssService* gnssService;
|
||||
static SavedNetworks* savedNetworks;
|
||||
static WifiService* wifi;
|
||||
static IrcService* irc;
|
||||
@@ -131,6 +132,7 @@ void setup() {
|
||||
storageService = new StorageService(bus);
|
||||
power = new PowerService(settings);
|
||||
clockService = new ClockService(settings, bus);
|
||||
gnssService = new GnssService(settings, *clockService, bus);
|
||||
savedNetworks = new SavedNetworks(nvs);
|
||||
savedNetworks->load();
|
||||
wifi = new WifiService(settings, *savedNetworks, *clockService);
|
||||
@@ -141,6 +143,7 @@ void setup() {
|
||||
services.add(*power);
|
||||
services.add(*clockService);
|
||||
services.add(*battery);
|
||||
services.add(*gnssService);
|
||||
services.add(*storageService);
|
||||
services.add(*wifi);
|
||||
services.add(*irc);
|
||||
@@ -325,6 +328,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"
|
||||
"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"
|
||||
@@ -386,33 +390,11 @@ static void runCommand(String line) {
|
||||
});
|
||||
}
|
||||
if (line.startsWith("install ")) update->installFromSd(line.substring(8).c_str()); // Update from SD
|
||||
if (line == "gnss probe") { // M2 step 1: which pins and baud rate carry NMEA (temporary)
|
||||
struct Try { int rx, tx; uint32_t baud; } tries[] = {{15, 13, 115200}, {13, 15, 115200}, {15, 13, 9600}, {13, 15, 9600}};
|
||||
for (auto& t : tries) {
|
||||
Serial1.begin(t.baud, SERIAL_8N1, t.rx, t.tx);
|
||||
uint32_t start = millis(), bytes = 0, lines = 0;
|
||||
std::string current, sample;
|
||||
while (millis() - start < 1200) {
|
||||
esp_task_wdt_reset(); // four listens outlast the 5 s loop watchdog
|
||||
while (Serial1.available()) {
|
||||
char c = Serial1.read();
|
||||
bytes++;
|
||||
if (c == '\n') {
|
||||
if (current.size() > 6 && current[0] == '$') {
|
||||
lines++;
|
||||
if (sample.size() < 400) sample += " " + current + "\n";
|
||||
}
|
||||
current.clear();
|
||||
} else if (c != '\r' && current.size() < 120) current += c;
|
||||
}
|
||||
delay(5);
|
||||
}
|
||||
Serial1.end();
|
||||
console.printf("gnss probe: rx %d tx %d at %lu: %lu bytes, %lu NMEA lines\n", t.rx, t.tx,
|
||||
(unsigned long)t.baud, (unsigned long)bytes, (unsigned long)lines);
|
||||
if (lines) console.print(sample.c_str());
|
||||
}
|
||||
}
|
||||
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.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);
|
||||
if (line == "coredump erase") console.println(crash_report::erase() ? "coredump: erased" : "coredump: nothing to erase");
|
||||
#ifdef RORO_DEBUG
|
||||
|
||||
Reference in New Issue
Block a user