Use the time.age() value to correct stale GPS times (#4705)

* Use the time.age() value to correct stale GPS times

* Trunk

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Jonathan Bennett 2024-09-14 07:44:40 -05:00 committed by GitHub
parent ae791ca7e1
commit 1ab5bf4355
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1539,7 +1539,7 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s
(midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
*/ */
struct tm t; struct tm t;
t.tm_sec = ti.second(); t.tm_sec = ti.second() + round(ti.age() / 1000);
t.tm_min = ti.minute(); t.tm_min = ti.minute();
t.tm_hour = ti.hour(); t.tm_hour = ti.hour();
t.tm_mday = d.day(); t.tm_mday = d.day();
@ -1547,8 +1547,8 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s
t.tm_year = d.year() - 1900; t.tm_year = d.year() - 1900;
t.tm_isdst = false; t.tm_isdst = false;
if (t.tm_mon > -1) { if (t.tm_mon > -1) {
LOG_DEBUG("NMEA GPS time %02d-%02d-%02d %02d:%02d:%02d\n", d.year(), d.month(), t.tm_mday, t.tm_hour, t.tm_min, LOG_DEBUG("NMEA GPS time %02d-%02d-%02d %02d:%02d:%02d age %d\n", d.year(), d.month(), t.tm_mday, t.tm_hour, t.tm_min,
t.tm_sec); t.tm_sec, ti.age());
perhapsSetRTC(RTCQualityGPS, t); perhapsSetRTC(RTCQualityGPS, t);
return true; return true;
} else } else
@ -1807,4 +1807,4 @@ void GPS::toggleGpsMode()
enable(); enable();
} }
} }
#endif // Exclude GPS #endif // Exclude GPS