From 88a1cbfa047108cb05bb95cd1c70ff9a15bb02d9 Mon Sep 17 00:00:00 2001 From: Daniel Ekman Date: Sat, 26 Sep 2026 11:51:10 +0200 Subject: [PATCH] Add GPS read interval to sensor Signed-off-by: Daniel Ekman --- examples/simple_sensor/SensorMesh.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/simple_sensor/SensorMesh.cpp b/examples/simple_sensor/SensorMesh.cpp index a01d82760..781893f16 100644 --- a/examples/simple_sensor/SensorMesh.cpp +++ b/examples/simple_sensor/SensorMesh.cpp @@ -68,6 +68,10 @@ static void applyRxPowerSavingConfig(NodePrefs& prefs, uint8_t sf, float bw) { #define SENSOR_READ_INTERVAL_SECS 60 #endif +#ifndef GPS_READ_INTERVAL_SECS + #define GPS_READ_INTERVAL_SECS 60 +#endif + /* ------------------------------ Code -------------------------------- */ #define FIRMWARE_VER_LEVEL 1 @@ -203,8 +207,10 @@ uint8_t SensorMesh::handleRequest(uint8_t perms, uint32_t sender_timestamp, uint telemetry.reset(); telemetry.addVoltage(TELEM_CHANNEL_SELF, (float)board.getBattMilliVolts() / 1000.0f); // query other sensors -- target specific - if (sensors.getLocationProvider() != NULL && sensors.getLocationProvider()->isPowerSavingEnabled()) { - sensors.getLocationProvider()->syncTime(); // Request for GPS sync if GPS is in PowerSaving + if (sensors.getLocationProvider() != NULL && + sensors.getLocationProvider()->isPowerSavingEnabled() && + getRTCClock()->getCurrentTime() - sensors.getLocationProvider()->getLastValidTimeSync() >= GPS_READ_INTERVAL_SECS)) { + sensors.getLocationProvider()->syncTime(); // Request for GPS sync if GPS is in PowerSaving if later than read interval } sensors.querySensors(0xFF & perm_mask, telemetry); // allow all telemetry permissions for admin or guest // TODO: let requester know permissions they have: telemetry.addPresence(TELEM_CHANNEL_SELF, perms);