From 9e3c2fc9d9f75cdcda0106529d5cae51eecfab5c Mon Sep 17 00:00:00 2001 From: Florent de Lamotte Date: Mon, 6 Oct 2025 15:30:18 +0200 Subject: [PATCH] gps_cli: gps also restored on sensors and rooms --- examples/simple_repeater/MyMesh.cpp | 6 ------ examples/simple_repeater/MyMesh.h | 10 ++++++---- examples/simple_room_server/MyMesh.cpp | 4 ++++ examples/simple_room_server/MyMesh.h | 6 ++++++ examples/simple_sensor/SensorMesh.cpp | 4 ++++ examples/simple_sensor/SensorMesh.h | 5 +++++ 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/examples/simple_repeater/MyMesh.cpp b/examples/simple_repeater/MyMesh.cpp index 1c6c0d77..f7153da3 100644 --- a/examples/simple_repeater/MyMesh.cpp +++ b/examples/simple_repeater/MyMesh.cpp @@ -664,12 +664,6 @@ void MyMesh::begin(FILESYSTEM *fs) { #endif } -#if ENV_INCLUDE_GPS == 1 -void MyMesh::applyGpsPrefs() { - sensors.setSettingByKey("gps", _prefs.gps_enabled?"1":"0"); -} -#endif - void MyMesh::applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) { set_radio_at = futureMillis(2000); // give CLI reply some time to be sent back, before applying temp radio params pending_freq = freq; diff --git a/examples/simple_repeater/MyMesh.h b/examples/simple_repeater/MyMesh.h index ca85d1a4..c45c141d 100644 --- a/examples/simple_repeater/MyMesh.h +++ b/examples/simple_repeater/MyMesh.h @@ -135,6 +135,12 @@ protected: return _prefs.multi_acks; } +#if ENV_INCLUDE_GPS == 1 + void applyGpsPrefs() { + sensors.setSettingByKey("gps", _prefs.gps_enabled?"1":"0"); + } +#endif + void onAnonDataRecv(mesh::Packet* packet, const uint8_t* secret, const mesh::Identity& sender, uint8_t* data, size_t len) override; int searchPeersByHash(const uint8_t* hash) override; void getPeerSharedSecret(uint8_t* dest_secret, int peer_idx) override; @@ -159,10 +165,6 @@ public: _cli.savePrefs(_fs); } -#if ENV_INCLUDE_GPS == 1 - void applyGpsPrefs(); -#endif - void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) override; bool formatFileSystem() override; void sendSelfAdvertisement(int delay_millis) override; diff --git a/examples/simple_room_server/MyMesh.cpp b/examples/simple_room_server/MyMesh.cpp index 89f2afb3..d9a36397 100644 --- a/examples/simple_room_server/MyMesh.cpp +++ b/examples/simple_room_server/MyMesh.cpp @@ -632,6 +632,10 @@ void MyMesh::begin(FILESYSTEM *fs) { updateAdvertTimer(); updateFloodAdvertTimer(); + +#if ENV_INCLUDE_GPS == 1 + applyGpsPrefs(); +#endif } void MyMesh::applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) { diff --git a/examples/simple_room_server/MyMesh.h b/examples/simple_room_server/MyMesh.h index b2df60c3..60ef1e73 100644 --- a/examples/simple_room_server/MyMesh.h +++ b/examples/simple_room_server/MyMesh.h @@ -149,6 +149,12 @@ protected: bool onPeerPathRecv(mesh::Packet* packet, int sender_idx, const uint8_t* secret, uint8_t* path, uint8_t path_len, uint8_t extra_type, uint8_t* extra, uint8_t extra_len) override; void onAckRecv(mesh::Packet* packet, uint32_t ack_crc) override; +#if ENV_INCLUDE_GPS == 1 + void applyGpsPrefs() { + sensors.setSettingByKey("gps", _prefs.gps_enabled?"1":"0"); + } +#endif + public: MyMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables); diff --git a/examples/simple_sensor/SensorMesh.cpp b/examples/simple_sensor/SensorMesh.cpp index ba41ca45..00da006a 100644 --- a/examples/simple_sensor/SensorMesh.cpp +++ b/examples/simple_sensor/SensorMesh.cpp @@ -697,6 +697,10 @@ void SensorMesh::begin(FILESYSTEM* fs) { updateAdvertTimer(); updateFloodAdvertTimer(); + +#if ENV_INCLUDE_GPS == 1 + applyGpsPrefs(); +#endif } bool SensorMesh::formatFileSystem() { diff --git a/examples/simple_sensor/SensorMesh.h b/examples/simple_sensor/SensorMesh.h index d26bcb14..cdc3940c 100644 --- a/examples/simple_sensor/SensorMesh.h +++ b/examples/simple_sensor/SensorMesh.h @@ -149,4 +149,9 @@ private: void sendAlert(const ClientInfo* c, Trigger* t); + #if ENV_INCLUDE_GPS == 1 + void applyGpsPrefs() { + sensors.setSettingByKey("gps", _prefs.gps_enabled?"1":"0"); + } +#endif };