diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index b2fbcac8d..5078a6a27 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1160,7 +1160,10 @@ void GPS::setPowerState(GPSPowerState newState, uint32_t sleepTime) switch (newState) { case GPS_ACTIVE: case GPS_IDLE: - if (oldState == GPS_ACTIVE || oldState == GPS_IDLE) // If hardware already awake, no changes needed + if (oldState == GPS_ACTIVE) + break; + gotTime = false; + if (oldState == GPS_IDLE) // If hardware already awake, no changes needed break; if (oldState != GPS_ACTIVE && oldState != GPS_IDLE) // If hardware just waking now, clear buffer clearBuffer(); @@ -1484,8 +1487,7 @@ int32_t GPS::runOnce() // if gps_update_interval is <=10s, GPS never goes off, so we treat that differently uint32_t updateInterval = Default::getConfiguredOrDefaultMs(config.position.gps_update_interval); - // 1. Got a time for the first time - bool gotTime = (getRTCQuality() >= RTCQualityGPS); + // 1. Got a time for the first time this cycle if (!gotTime && lookForTime()) { // Note: we count on this && short-circuiting and not resetting the RTC time gotTime = true; } diff --git a/src/gps/GPS.h b/src/gps/GPS.h index 25de0379a..4028e351a 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -174,6 +174,7 @@ class GPS : private concurrency::OSThread uint32_t lastChecksumFailCount = 0; uint8_t currentStep = 0; int32_t currentDelay = 2000; + bool gotTime = false; #ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS // (20210908) TinyGps++ can only read the GPGSA "FIX TYPE" field diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp index a8288a069..78439a50a 100644 --- a/src/gps/RTC.cpp +++ b/src/gps/RTC.cpp @@ -219,8 +219,8 @@ RTCSetResult perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpd } else if (q == RTCQualityGPS) { shouldSet = true; LOG_DEBUG("Reapply GPS time: %ld secs", printableEpoch); - } else if (q == RTCQualityNTP && !Throttle::isWithinTimespanMs(lastSetMsec, (12 * 60 * 60 * 1000UL))) { - // Every 12 hrs we will slam in a new NTP or Phone GPS / NTP time, to correct for local RTC clock drift + } else if (q == RTCQualityNTP && !Throttle::isWithinTimespanMs(lastSetMsec, (30 * 60 * 1000UL))) { + // Every 30 minutes we will slam in a new NTP or Phone GPS / NTP time, to correct for local RTC clock drift shouldSet = true; LOG_DEBUG("Reapply external time to correct clock drift %ld secs", printableEpoch); } else {