1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-02 14:22:55 +03:00

sntp: use one time source and fix unsynchronized sntp time stamp (#7595)

* sntp: use one time source and fix unsynchronized sntp time stamp
* show subsecond synchro between time() and gettimeofday()
This commit is contained in:
david gauchard
2020-09-12 18:22:38 +02:00
committed by GitHub
parent 8418aaf4ef
commit 40eb5747e4
6 changed files with 72 additions and 121 deletions

View File

@ -158,6 +158,24 @@ void showTime() {
}
Serial.println();
// subsecond synchronisation
gettimeofday(&tv, nullptr);
time_t sec = tv.tv_sec;
do {
gettimeofday(&tv, nullptr);
Serial.printf("time(): %u gettimeofday(): %u.%06u",
(uint32_t)time(nullptr),
(uint32_t)tv.tv_sec, (uint32_t)tv.tv_usec);
if (tv.tv_sec == sec) {
Serial.println(" second unchanged");
} else {
Serial.println(" <-- second changed");
}
delay(50);
} while (tv.tv_sec == sec);
Serial.println();
}
void time_is_set_scheduled() {