Fabian Schlenz
47812de405
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This has the advantage of being able to set DST automatically.
27 lines
624 B
C++
27 lines
624 B
C++
#include <sntp.h>
|
|
#include <coredecls.h>
|
|
#include <time.h>
|
|
#include <TZ.h>
|
|
#include "my_fastled.h"
|
|
|
|
/*void updateCallback(NTPClient* c) {
|
|
random16_add_entropy(c->getEpochMillis() & 0xFFFF);
|
|
LOGln("Received current time. Epoch is %lu.", ntpClient.getEpochTime());
|
|
}*/
|
|
|
|
void time_changed() {
|
|
random16_add_entropy(millis() & 0xFFFF);
|
|
time_t now;
|
|
tm timeinfo;
|
|
time(&now);
|
|
localtime_r(&now, &timeinfo);
|
|
char time_s[30];
|
|
strftime(time_s, 30, "%a %d.%m.%Y %T", &timeinfo);
|
|
LOGln("NTP * Received time: %s", time_s);
|
|
}
|
|
|
|
void ntp_setup() {
|
|
settimeofday_cb(time_changed);
|
|
configTime(TZ_Europe_Berlin, "de.pool.ntp.org");
|
|
}
|