From b4ff37104a58792f8a5c3519d061880af3f9d791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 6 May 2023 23:16:39 +0200 Subject: [PATCH] fix NMEA Timestamp for good --- src/gps/NMEAWPL.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index cf158d993..ac11d78f8 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -59,8 +59,10 @@ 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)); + if (getRTCQuality() > 0) { // use the device clock if we got time from somewhere. If not, use the GPS timestamp. + uint32_t rtc_sec = getValidTime(RTCQuality::RTCQualityDevice); + t = localtime((time_t *)&rtc_sec); + } 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,