firmware: use verified sensor settings

This commit is contained in:
2026-07-17 02:51:40 -06:00
parent d5578ce796
commit dc7a7223fb
6 changed files with 17 additions and 73 deletions
+3 -29
View File
@@ -4,39 +4,13 @@
namespace { TinyGPSPlus parser; }
namespace {
uint32_t activeBaud = GPS_FALLBACK_BAUD;
bool baudHasValidNmea(HardwareSerial& serial, uint32_t baud) {
TinyGPSPlus probe;
serial.end();
serial.begin(baud, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
unsigned long started = millis();
while (millis() - started < GPS_BAUD_DETECT_MS) {
while (serial.available()) probe.encode(serial.read());
if (probe.passedChecksum() > 0) return true;
delay(1);
}
return false;
}
uint32_t activeBaud = GPS_BAUD;
}
void initGps(HardwareSerial& serial) {
const uint32_t candidates[] = {9600, 38400, 115200, 4800};
Serial.println("Detecting GPS UART baud...");
for (uint32_t baud : candidates) {
Serial.print("Trying GPS baud ");
Serial.println(baud);
if (!baudHasValidNmea(serial, baud)) continue;
activeBaud = baud;
Serial.print("Valid GPS NMEA detected at ");
Serial.println(activeBaud);
return;
}
activeBaud = GPS_FALLBACK_BAUD;
serial.end();
serial.begin(activeBaud, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
Serial.println("No valid GPS NMEA detected; falling back to 9600 baud");
Serial.print("Starting GPS UART at ");
Serial.println(activeBaud);
}
void updateGps(HardwareSerial& serial, GpsState& s) {