Skip to content

Commit f8dbdce

Browse files
committed
fix: apply persisted GPS enabled setting on boot for companion radio
The companion_radio example was not restoring the GPS enabled/disabled preference from flash after reboot. The preference was being saved correctly when toggled via the mobile app, but on boot, sensors.begin() -> initBasicGPS() unconditionally sets gps_active=false and nothing subsequently restored the persisted state. Added applyGpsPrefs() (matching the pattern in simple_repeater, simple_sensor, and simple_room_server) and call it from main.cpp after sensors.begin() to ensure the GPS hardware is initialized before the saved preference is applied.
1 parent bdf1050 commit f8dbdce

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

examples/companion_radio/MyMesh.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ class MyMesh : public BaseChatMesh, public DataStoreHost {
165165
public:
166166
void savePrefs() { _store->savePrefs(_prefs, sensors.node_lat, sensors.node_lon); }
167167

168+
#if ENV_INCLUDE_GPS == 1
169+
void applyGpsPrefs() {
170+
sensors.setSettingValue("gps", _prefs.gps_enabled ? "1" : "0");
171+
}
172+
#endif
173+
168174
private:
169175
void writeOKFrame();
170176
void writeErrFrame(uint8_t err_code);

examples/companion_radio/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ void setup() {
213213

214214
sensors.begin();
215215

216+
#if ENV_INCLUDE_GPS == 1
217+
the_mesh.applyGpsPrefs();
218+
#endif
219+
216220
#ifdef DISPLAY_CLASS
217221
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs()); // still want to pass this in as dependency, as prefs might be moved
218222
#endif

0 commit comments

Comments
 (0)