Merge pull request #90 from mepholic/fix/gps-duty-boot-ordering

Fix GPS duty interval read before loadPrefs() on repeater/room server
This commit is contained in:
liquidraver
2026-09-19 20:15:09 +02:00
committed by GitHub
2 changed files with 50 additions and 10 deletions
+25 -5
View File
@@ -700,14 +700,11 @@ int main(void)
}
}
/* Set GPS to repeater mode: power off now, wake every 48h for time sync only.
* This prevents GPS from draining power on boards that have it (e.g., Wio Tracker). */
/* GPS callbacks only. The duty interval and the mode switch that starts
* acquisition are applied after loadPrefs() below — see the block there. */
if (gps_is_available()) {
gps_set_fix_callback(gps_fix_callback);
gps_set_event_callback(gps_event_callback);
/* Apply persisted GPS duty interval (repeater default 48h; 0 = always on) */
gps_set_poll_interval_sec(repeater_mesh.getNodePrefs()->gps_interval);
gps_set_repeater_mode(true);
}
/* Initialize UI (display + buttons). Shows splash screen, then auto-
@@ -763,6 +760,29 @@ int main(void)
data_store.loadPrefs(*repeater_mesh.getNodePrefs());
lora_radio.setPrefs(repeater_mesh.getNodePrefs());
/* Set GPS to repeater mode: power off now, wake every duty interval for
* time sync only. This prevents GPS from draining power on boards that
* have it (e.g., Wio Tracker).
*
* MUST come after loadPrefs(), for the same reason as the LED switch
* below -- but note loadPrefs() is not a pure read here. It is also the
* only place this role's GPS default is established: initNodePrefs()
* sets gps_interval=300 (the companion value), and the 48 h default is
* applied and PERSISTED by loadPrefs()'s first-boot path.
*
* This block used to sit ~55 lines earlier, where getNodePrefs() still
* held that 300. So the GPS manager was armed from the companion default
* on every boot and nothing re-applied the real value afterwards:
* - a stock repeater woke its GPS every 5 min instead of every 48 h;
* - any operator value, notably "set gps duty 0" (always-on), was
* stored and read back correctly but never reached the hardware.
* Same failure shape as the radio-frequency and LED ordering bugs in this
* file. main_companion.cpp has always had this order right. */
if (gps_is_available()) {
gps_set_poll_interval_sec(repeater_mesh.getNodePrefs()->gps_interval);
gps_set_repeater_mode(true);
}
/* Apply the persisted LED master switch ("set leds on|off"). MUST come
* after loadPrefs(): this used to sit just after ui_init(), ~45 lines
* earlier, where getNodePrefs() still held the initNodePrefs() default of
+25 -5
View File
@@ -586,14 +586,11 @@ int main(void)
}
}
/* Set GPS to repeater mode: power off now, wake every 48h for time sync only.
* This prevents GPS from draining power on boards that have it (e.g., Wio Tracker). */
/* GPS callbacks only. The duty interval and the mode switch that starts
* acquisition are applied after loadPrefs() below — see the block there. */
if (gps_is_available()) {
gps_set_fix_callback(gps_fix_callback);
gps_set_event_callback(gps_event_callback);
/* Apply persisted GPS duty interval (repeater default 48h; 0 = always on) */
gps_set_poll_interval_sec(room_mesh.getNodePrefs()->gps_interval);
gps_set_repeater_mode(true);
}
/* Initialize UI (display + buttons). Shows splash screen, then auto-
@@ -648,6 +645,29 @@ int main(void)
data_store.loadPrefs(*room_mesh.getNodePrefs());
lora_radio.setPrefs(room_mesh.getNodePrefs());
/* Set GPS to repeater mode: power off now, wake every duty interval for
* time sync only. This prevents GPS from draining power on boards that
* have it (e.g., Wio Tracker).
*
* MUST come after loadPrefs(), for the same reason as the LED switch
* below -- but note loadPrefs() is not a pure read here. It is also the
* only place this role's GPS default is established: initNodePrefs()
* sets gps_interval=300 (the companion value), and the 48 h default is
* applied and PERSISTED by loadPrefs()'s first-boot path.
*
* This block used to sit ~55 lines earlier, where getNodePrefs() still
* held that 300. So the GPS manager was armed from the companion default
* on every boot and nothing re-applied the real value afterwards:
* - a stock repeater woke its GPS every 5 min instead of every 48 h;
* - any operator value, notably "set gps duty 0" (always-on), was
* stored and read back correctly but never reached the hardware.
* Same failure shape as the radio-frequency and LED ordering bugs in this
* file. main_companion.cpp has always had this order right. */
if (gps_is_available()) {
gps_set_poll_interval_sec(room_mesh.getNodePrefs()->gps_interval);
gps_set_repeater_mode(true);
}
/* Apply the persisted LED master switch ("set leds on|off"). MUST come
* after loadPrefs(): this used to sit just after ui_init(), ~45 lines
* earlier, where getNodePrefs() still held the initNodePrefs() default of