From 2640127049bb47e69d887b9c8d45cff56d581ca7 Mon Sep 17 00:00:00 2001 From: Adam Gessaman Date: Fri, 6 Feb 2026 05:54:19 -0800 Subject: [PATCH] Enhance NTP sync handling in MQTTBridge - Updated the logic for JWT token timestamp validation to allow reconnection if the system clock is set, even when NTP sync is not confirmed. This change prevents unnecessary connection blocks after a successful NTP sync at boot. - Introduced a check to determine if the system clock is clearly set, improving the robustness of the connection maintenance process. --- src/helpers/bridges/MQTTBridge.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/helpers/bridges/MQTTBridge.cpp b/src/helpers/bridges/MQTTBridge.cpp index 184f7a3d..b7b84d5c 100644 --- a/src/helpers/bridges/MQTTBridge.cpp +++ b/src/helpers/bridges/MQTTBridge.cpp @@ -2575,8 +2575,12 @@ void MQTTBridge::maintainAnalyzerConnections() { return; } - // Check NTP sync status - JWT tokens require valid timestamps - if (!_ntp_synced) { + // JWT tokens require valid timestamps. Allow if NTP sync flag is set, or if system clock + // is clearly set (e.g. not firmware default 2024) so we don't block reconnection after + // a successful NTP sync at boot when _ntp_synced might be wrong. + unsigned long clock_sec = time(nullptr); + bool clock_looks_set = (clock_sec >= 1735689600); // 2025-01-01 00:00:00 UTC + if (!_ntp_synced && !clock_looks_set) { return; }