2020-03-29 16:08:54 +00:00
|
|
|
#include <sntp.h>
|
|
|
|
#include <coredecls.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <TZ.h>
|
2019-06-06 04:43:01 +00:00
|
|
|
#include "my_fastled.h"
|
|
|
|
|
2020-03-29 16:08:54 +00:00
|
|
|
/*void updateCallback(NTPClient* c) {
|
2019-06-06 04:43:01 +00:00
|
|
|
random16_add_entropy(c->getEpochMillis() & 0xFFFF);
|
2020-03-29 16:08:54 +00:00
|
|
|
LOGln("Received current time. Epoch is %lu.", ntpClient.getEpochTime());
|
|
|
|
}*/
|
2019-05-29 22:49:54 +00:00
|
|
|
|
2020-03-29 16:08:54 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-06-06 04:43:01 +00:00
|
|
|
|
|
|
|
void ntp_setup() {
|
2020-03-29 16:08:54 +00:00
|
|
|
settimeofday_cb(time_changed);
|
|
|
|
configTime(TZ_Europe_Berlin, "de.pool.ntp.org");
|
2019-06-06 04:43:01 +00:00
|
|
|
}
|