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 <noreply@anthropic.com>
This commit is contained in:
MarekZegare4
2026-08-12 22:43:15 +02:00
co-authored by Claude Sonnet 5
parent 71c39bab4f
commit 6c7c9f3f83
2 changed files with 18 additions and 4 deletions
+12 -1
View File
@@ -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));