The basic example for ESP32 NTP is very rough:
void setup() {
Serial.begin(115200);
//connect to WiFi
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(" CONNECTED");
//init and get the time
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
printLocalTime();
//disconnect WiFi as it's no longer needed
WiFi.disconnect(true);
WiFi.mode(WIFI_OFF);
}
But it tells nothing about the success of the operation.
I need to know if it was able to update the time from the NTP server. Is there a method to know that?
I can't rely on the time struct because I must init it manually at startup, say to 1st Jan 2020 00:00.