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);