Set the time from GPS every 30 minutes (#10737)
This commit is contained in:
+5
-3
@@ -1160,7 +1160,10 @@ void GPS::setPowerState(GPSPowerState newState, uint32_t sleepTime)
|
|||||||
switch (newState) {
|
switch (newState) {
|
||||||
case GPS_ACTIVE:
|
case GPS_ACTIVE:
|
||||||
case GPS_IDLE:
|
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;
|
break;
|
||||||
if (oldState != GPS_ACTIVE && oldState != GPS_IDLE) // If hardware just waking now, clear buffer
|
if (oldState != GPS_ACTIVE && oldState != GPS_IDLE) // If hardware just waking now, clear buffer
|
||||||
clearBuffer();
|
clearBuffer();
|
||||||
@@ -1484,8 +1487,7 @@ int32_t GPS::runOnce()
|
|||||||
// if gps_update_interval is <=10s, GPS never goes off, so we treat that differently
|
// 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);
|
uint32_t updateInterval = Default::getConfiguredOrDefaultMs(config.position.gps_update_interval);
|
||||||
|
|
||||||
// 1. Got a time for the first time
|
// 1. Got a time for the first time this cycle
|
||||||
bool gotTime = (getRTCQuality() >= RTCQualityGPS);
|
|
||||||
if (!gotTime && lookForTime()) { // Note: we count on this && short-circuiting and not resetting the RTC time
|
if (!gotTime && lookForTime()) { // Note: we count on this && short-circuiting and not resetting the RTC time
|
||||||
gotTime = true;
|
gotTime = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ class GPS : private concurrency::OSThread
|
|||||||
uint32_t lastChecksumFailCount = 0;
|
uint32_t lastChecksumFailCount = 0;
|
||||||
uint8_t currentStep = 0;
|
uint8_t currentStep = 0;
|
||||||
int32_t currentDelay = 2000;
|
int32_t currentDelay = 2000;
|
||||||
|
bool gotTime = false;
|
||||||
|
|
||||||
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
|
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
|
||||||
// (20210908) TinyGps++ can only read the GPGSA "FIX TYPE" field
|
// (20210908) TinyGps++ can only read the GPGSA "FIX TYPE" field
|
||||||
|
|||||||
+2
-2
@@ -219,8 +219,8 @@ RTCSetResult perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpd
|
|||||||
} else if (q == RTCQualityGPS) {
|
} else if (q == RTCQualityGPS) {
|
||||||
shouldSet = true;
|
shouldSet = true;
|
||||||
LOG_DEBUG("Reapply GPS time: %ld secs", printableEpoch);
|
LOG_DEBUG("Reapply GPS time: %ld secs", printableEpoch);
|
||||||
} else if (q == RTCQualityNTP && !Throttle::isWithinTimespanMs(lastSetMsec, (12 * 60 * 60 * 1000UL))) {
|
} else if (q == RTCQualityNTP && !Throttle::isWithinTimespanMs(lastSetMsec, (30 * 60 * 1000UL))) {
|
||||||
// Every 12 hrs we will slam in a new NTP or Phone GPS / NTP time, to correct for local RTC clock drift
|
// Every 30 minutes we will slam in a new NTP or Phone GPS / NTP time, to correct for local RTC clock drift
|
||||||
shouldSet = true;
|
shouldSet = true;
|
||||||
LOG_DEBUG("Reapply external time to correct clock drift %ld secs", printableEpoch);
|
LOG_DEBUG("Reapply external time to correct clock drift %ld secs", printableEpoch);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user