Added delay to NTP to let WiFi catch up before time request

This commit is contained in:
2026-01-07 21:46:26 +02:00
parent eb6e0f0e5c
commit 7e279c6e45
2 changed files with 28 additions and 8 deletions

View File

@@ -152,9 +152,9 @@ void Timekeeper::syncTimeWithNTP() {
// Configure NTP with settings from config
configTime(timeConfig.gmtOffsetSec, timeConfig.daylightOffsetSec, timeConfig.ntpServer.c_str());
// 🔥 NON-BLOCKING: Try to get time immediately without waiting
// 🔥 NON-BLOCKING: Try to get time with reasonable timeout for network response
struct tm timeInfo;
if (getLocalTime(&timeInfo, 100)) { // 100ms timeout instead of blocking
if (getLocalTime(&timeInfo, 5000)) { // 5 second timeout for NTP response
// Success! Update RTC with synchronized time
rtc.adjust(DateTime(timeInfo.tm_year + 1900, timeInfo.tm_mon + 1, timeInfo.tm_mday,
timeInfo.tm_hour, timeInfo.tm_min, timeInfo.tm_sec));