mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-01 01:35:48 +00:00
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.
This commit is contained in:
@@ -165,6 +165,12 @@ protected:
|
||||
public:
|
||||
void savePrefs() { _store->savePrefs(_prefs, sensors.node_lat, sensors.node_lon); }
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled ? "1" : "0");
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
void writeOKFrame();
|
||||
void writeErrFrame(uint8_t err_code);
|
||||
|
||||
@@ -213,6 +213,10 @@ void setup() {
|
||||
|
||||
sensors.begin();
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
the_mesh.applyGpsPrefs();
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs()); // still want to pass this in as dependency, as prefs might be moved
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user