diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 4388fd1..f2a91ed 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -1193,12 +1193,24 @@ void MyMesh::begin(bool has_display) { _prefs.gps_baudrate != 9600 && _prefs.gps_baudrate != 19200 && _prefs.gps_baudrate != 38400 && _prefs.gps_baudrate != 57600 && _prefs.gps_baudrate != 115200) { + Serial.printf("PREFS: invalid gps_baudrate=%lu — reset to 0 (default)\n", + (unsigned long)_prefs.gps_baudrate); _prefs.gps_baudrate = 0; // reset to default if invalid } - // interference_threshold: 0 = disabled, minimum functional value is 14 + // interference_threshold: 0 = disabled, minimum functional value is 14, max sane ~30 if (_prefs.interference_threshold > 0 && _prefs.interference_threshold < 14) { _prefs.interference_threshold = 0; } + if (_prefs.interference_threshold > 50) { + Serial.printf("PREFS: invalid interference_threshold=%d — reset to 0 (disabled)\n", + _prefs.interference_threshold); + _prefs.interference_threshold = 0; // garbage from prefs upgrade — disable + } + // Clamp remaining v1.0 fields that may contain garbage after upgrade from older firmware + if (_prefs.path_hash_mode > 2) _prefs.path_hash_mode = 0; + if (_prefs.autoadd_max_hops > 64) _prefs.autoadd_max_hops = 0; + if (_prefs.dark_mode > 1) _prefs.dark_mode = 0; + if (_prefs.portrait_mode > 1) _prefs.portrait_mode = 0; #ifdef BLE_PIN_CODE // 123456 by default if (_prefs.ble_pin == 0) { diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index 9b0c65e..eb593b3 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -8,11 +8,11 @@ #define FIRMWARE_VER_CODE 10 #ifndef FIRMWARE_BUILD_DATE -#define FIRMWARE_BUILD_DATE "14 March 2026" +#define FIRMWARE_BUILD_DATE "15 March 2026" #endif #ifndef FIRMWARE_VERSION -#define FIRMWARE_VERSION "Meck v1.0" +#define FIRMWARE_VERSION "Meck v1.0.1" #endif #if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index ab71db5..446839b 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1164,15 +1164,18 @@ void setup() { sensors.begin(); MESH_DEBUG_PRINTLN("setup() - sensors.begin() done"); - // IMPORTANT: sensors.begin() calls initBasicGPS() which steals the GPS pins for Serial1 - // We need to reinitialize Serial2 to reclaim them + // IMPORTANT: sensors.begin() calls initBasicGPS() which steals the GPS pins for Serial1. + // We must end Serial1 first, then reclaim the pins for Serial2 (which feeds gpsStream). #if HAS_GPS - Serial2.end(); // Close any existing Serial2 + Serial1.end(); // Release GPS pins from Serial1's UART + ISR + Serial2.end(); // Close any existing Serial2 { uint32_t gps_baud = the_mesh.getNodePrefs()->gps_baudrate; + Serial.printf("GPS: prefs gps_baudrate=%lu (0=use default)\n", (unsigned long)gps_baud); if (gps_baud == 0) gps_baud = GPS_BAUDRATE; Serial2.begin(gps_baud, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); - MESH_DEBUG_PRINTLN("setup() - Reinitialized Serial2 for GPS at %lu baud", (unsigned long)gps_baud); + Serial.printf("GPS: Serial2 started at %lu baud (RX=%d TX=%d)\n", + (unsigned long)gps_baud, GPS_RX_PIN, GPS_TX_PIN); } #endif @@ -1373,10 +1376,12 @@ void setup() { } #endif - // GPS power — honour saved pref, default to enabled on first boot + // GPS power — honour saved pref, default to enabled on first boot. + // GPS is critical for timesync on standalone variants without 4G. #if HAS_GPS { bool gps_wanted = the_mesh.getNodePrefs()->gps_enabled; + Serial.printf("GPS: pref gps_enabled=%d\n", (int)gps_wanted); if (gps_wanted) { #ifdef PIN_GPS_EN digitalWrite(PIN_GPS_EN, GPS_EN_ACTIVE); @@ -1388,7 +1393,7 @@ void setup() { #endif sensors.setSettingValue("gps", "0"); } - MESH_DEBUG_PRINTLN("setup() - GPS power %s", gps_wanted ? "on" : "off"); + Serial.printf("GPS: power %s, PIN_GPS_EN=%d\n", gps_wanted ? "ON" : "OFF", PIN_GPS_EN); } #endif @@ -1410,6 +1415,21 @@ void loop() { sensors.loop(); + // GPS diagnostic — print sentence count every 30s so we can tell if Serial2 is receiving data + #if HAS_GPS + { + static unsigned long lastGpsDiag = 0; + if (millis() - lastGpsDiag >= 30000) { + lastGpsDiag = millis(); + uint32_t sentences = gpsStream.getSentenceCount(); + uint16_t perSec = gpsStream.getSentencesPerSec(); + Serial.printf("GPS diag: %lu sentences total, %u/sec, Serial2.available=%d, lat=%.6f lon=%.6f\n", + (unsigned long)sentences, perSec, Serial2.available(), + sensors.node_lat, sensors.node_lon); + } + } + #endif + // Map screen: periodically update own GPS position and contact markers #if HAS_GPS if (ui_task.isOnMapScreen()) {