mirror of
https://github.com/mikecarper/MeshCore.git
synced 2026-07-28 10:39:23 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user