2 #include "EspSntpClock.h"
4 #if defined(ESP8266) || defined(ESP32) || defined(EPOXY_CORE_ESP8266)
11 static const time_t EPOCH_2000_01_01 = 946684800;
16 Serial.print(F(
"Configuring SNTP"));
19 configTime(0 , 0 , ntpServer);
22 uint32_t startMillis = millis();
25 time_t now = time(
nullptr);
26 if (now >= EPOCH_2000_01_01) {
27 Serial.println(F(
" Done."));
31 uint32_t elapsedMillis = millis() - startMillis;
32 if (elapsedMillis >= timeoutMillis) {
33 Serial.println(F(
" Failed!"));
bool setup(const char *ntpServer=kDefaultNtpServer, uint32_t timeoutMillis=kDefaultTimeoutMillis)
Setup the SNTP client.
static const char kDefaultNtpServer[]
Default NTP server, "pool.ntp.org".