From 6c7c9f3f83a23c2f604db9d5e95c0d222f8c70df Mon Sep 17 00:00:00 2001 From: MarekZegare4 Date: Wed, 12 Aug 2026 22:43:15 +0200 Subject: [PATCH] fix(prefs): snap legacy gps_interval values to a valid duty-cycle preset The pre-v1.13 "GPS Interval" setting (hidden from Settings ever since, but its byte kept "for backwards compatibility") used a different option set than today's duty-cycle presets -- its old 30s choice isn't one of them. A device that had it set to 30 would load that value straight into the new duty-cycle scheduler while "GPS pwr" in Settings showed OFF (gpsDutyIndex() found no matching preset), silently cycling GPS on a setting nobody could see or change. Unrecognised values now reset to OFF on load, same as the existing out-of-range clamp this replaces. Also refreshes MyMesh.h's FIRMWARE_VERSION/FIRMWARE_BUILD_DATE fallback (only ever used by a `pio run` that bypasses build.sh entirely) -- it was still "v1.17-solo.0" from 12 tags ago. Co-Authored-By: Claude Sonnet 5 --- examples/companion_radio/DataStore.cpp | 13 ++++++++++++- examples/companion_radio/MyMesh.h | 9 ++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/examples/companion_radio/DataStore.cpp b/examples/companion_radio/DataStore.cpp index 2cb92147..aff9f3e1 100644 --- a/examples/companion_radio/DataStore.cpp +++ b/examples/companion_radio/DataStore.cpp @@ -264,7 +264,18 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no file.read((uint8_t *)&_prefs.buzzer_quiet, sizeof(_prefs.buzzer_quiet)); file.read((uint8_t *)&_prefs.gps_enabled, sizeof(_prefs.gps_enabled)); file.read((uint8_t *)&_prefs.gps_interval, sizeof(_prefs.gps_interval)); - if (_prefs.gps_interval > 86400) _prefs.gps_interval = 0; // now a duty-cycle sleep window (secs); 0 = disabled + // Only today's duty-cycle presets are meaningful now (see SettingsScreen's + // GPS_DUTY_OPTS). Anything else -- out of range, or a leftover value from + // the pre-v1.13 "GPS Interval" setting this byte used to hold (its own + // 30s option isn't one of today's presets) -- wouldn't match a Settings + // choice, so "GPS pwr" would misleadingly show OFF while still silently + // duty-cycling GPS on that stale value. Snap anything unrecognised to OFF. + { + static const uint32_t GPS_DUTY_PRESETS[] = { 0, 60, 300, 900, 1800, 3600 }; + bool known = false; + for (uint32_t v : GPS_DUTY_PRESETS) { if (_prefs.gps_interval == v) { known = true; break; } } + if (!known) _prefs.gps_interval = 0; + } file.read((uint8_t *)&_prefs.autoadd_config, sizeof(_prefs.autoadd_config)); file.read((uint8_t *)&_prefs.autoadd_max_hops, sizeof(_prefs.autoadd_max_hops)); file.read((uint8_t *)&_prefs.rx_boosted_gain, sizeof(_prefs.rx_boosted_gain)); diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index bea006c5..90a4dd57 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -12,12 +12,15 @@ class UITask; #define FIRMWARE_VER_CODE 13 #ifndef FIRMWARE_BUILD_DATE -#define FIRMWARE_BUILD_DATE "11 Aug 2026" +#define FIRMWARE_BUILD_DATE "12 Aug 2026" #endif -// Versioning: vX.Y = upstream base, solo.N = fork revision +// Fallback only -- every real build (local or CI) goes through build.sh, which +// always injects FIRMWARE_VERSION itself (the pushed tag name for a release, +// "dev-" otherwise; see build-solo-firmwares.yml). This default only +// shows up for a `pio run` invoked directly, bypassing build.sh entirely. #ifndef FIRMWARE_VERSION -#define FIRMWARE_VERSION "v1.17-solo.0" +#define FIRMWARE_VERSION "v1.24-dev" #endif #if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)