From a3c6e859322ae0b762a922f93b5d2ab4c35950f8 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 13 Sep 2024 18:12:58 -0500 Subject: [PATCH 1/2] Ignore attempts to set times in the past (before our build epoch) --- platformio.ini | 1 + src/gps/RTC.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 7613a2f43b..d561aaf744 100644 --- a/platformio.ini +++ b/platformio.ini @@ -81,6 +81,7 @@ build_flags = -Wno-missing-field-initializers -DRADIOLIB_EXCLUDE_APRS -DRADIOLIB_EXCLUDE_LORAWAN -DMESHTASTIC_EXCLUDE_DROPZONE=1 + -DBUILD_EPOCH=$UNIX_TIME ;-D OLED_PL monitor_speed = 115200 diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp index c056bb9e48..59a33890fe 100644 --- a/src/gps/RTC.cpp +++ b/src/gps/RTC.cpp @@ -109,7 +109,13 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpdate) static uint32_t lastSetMsec = 0; uint32_t now = millis(); uint32_t printableEpoch = tv->tv_sec; // Print lib only supports 32 bit but time_t can be 64 bit on some platforms - +#ifdef BUILD_EPOCH + if (tv->tv_sec < BUILD_EPOCH) { + LOG_WARN("Ignoring time (%ld) before build epoch (%ld)!\n", printableEpoch, BUILD_EPOCH); + return false; + } +#endif + bool shouldSet; if (forceUpdate) { shouldSet = true; From 347163b8405cd4529f935ace29999fb37dccf511 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 13 Sep 2024 18:21:12 -0500 Subject: [PATCH 2/2] TRONK --- src/gps/RTC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp index 59a33890fe..42a98f5685 100644 --- a/src/gps/RTC.cpp +++ b/src/gps/RTC.cpp @@ -115,7 +115,7 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv, bool forceUpdate) return false; } #endif - + bool shouldSet; if (forceUpdate) { shouldSet = true;