From 9b6ac98ae0d41023e1d8ccb517098d0fa601cdaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 6 May 2023 18:10:00 +0200 Subject: [PATCH] use the device time, only use gps timestamp as a fallback. --- src/gps/NMEAWPL.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index 70d3d22cb..902ba4c95 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -1,6 +1,7 @@ #include "NMEAWPL.h" #include "GeoCoord.h" #include +#include "RTC.h" /* ------------------------------------------- * 1 2 3 4 5 6 @@ -58,6 +59,9 @@ uint32_t printGGA(char *buf, size_t bufsz, const meshtastic_Position &pos) { GeoCoord geoCoord(pos.latitude_i, pos.longitude_i, pos.altitude); tm *t = localtime((time_t *)&pos.timestamp); + if (getRTCQuality() > 0) // use the device clock if we got time from somewhere. If not, use the GPS timestamp. + t = localtime((time_t *)getValidTime(RTCQuality::RTCQualityDevice)); + uint32_t len = snprintf( buf, bufsz, "$GNGGA,%02d%02d%02d.%02d,%02d%07.4f,%c,%03d%07.4f,%c,%u,%02u,%04u,%04d,%c,%04d,%c,%d,%04d", t->tm_hour,