Added delay to NTP to let WiFi catch up before time request
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user