Skip to content

Commit f25268b

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 aedc00e commit f25268b

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
@@ -163,6 +163,12 @@ class MyMesh : public BaseChatMesh, public DataStoreHost {
163163
public:
164164
void savePrefs() { _store->savePrefs(_prefs, sensors.node_lat, sensors.node_lon); }
165165

166+
#if ENV_INCLUDE_GPS == 1
167+
void applyGpsPrefs() {
168+
sensors.setSettingValue("gps", _prefs.gps_enabled ? "1" : "0");
169+
}
170+
#endif
171+
166172
private:
167173
void writeOKFrame();
168174
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)