Merge pull request #146 from D44rkM00n/master

Wrong time after first connection
This commit is contained in:
BitMaker 2023-09-03 15:40:48 +02:00 committed by GitHub
commit 46ef101deb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -193,8 +193,7 @@ String getTime(void){
//Check if need an NTP call to check current time //Check if need an NTP call to check current time
if((mTriggerUpdate == 0) || (millis() - mTriggerUpdate > UPDATE_PERIOD_h * 60 * 60 * 1000)){ //60 sec. * 60 min * 1000ms if((mTriggerUpdate == 0) || (millis() - mTriggerUpdate > UPDATE_PERIOD_h * 60 * 60 * 1000)){ //60 sec. * 60 min * 1000ms
if(WiFi.status() == WL_CONNECTED) { if(WiFi.status() == WL_CONNECTED) {
timeClient.update(); //NTP call to get current time if(timeClient.update()) mTriggerUpdate = millis();
mTriggerUpdate = millis();
initialTime = timeClient.getEpochTime(); // Guarda la hora inicial (en segundos desde 1970) initialTime = timeClient.getEpochTime(); // Guarda la hora inicial (en segundos desde 1970)
Serial.print("TimeClient NTPupdateTime "); Serial.print("TimeClient NTPupdateTime ");
} }
@ -446,4 +445,4 @@ void doLedStuff(int ledPin){
} }
break; break;
} }
} }