This commit is contained in:
Wolfgang Hottgenroth 2021-02-07 13:54:45 +01:00
parent a5f20fc073
commit be279e4421
Signed by: wn
GPG Key ID: E49AF3B9EF6DD469

View File

@ -137,14 +137,20 @@ static void wizSNTPHandler(void *handle) {
if (networkAvailable) { if (networkAvailable) {
coloredMsg(LOG_BLUE, "wizsh, about to call SNTP"); coloredMsg(LOG_BLUE, "wizsh, about to call SNTP");
int8_t res = SNTP_run(&curTime); uint8_t ntpServer[4];
coloredMsg(LOG_BLUE, "wizsh, res: %d", res); if (wizDnsQuery(NTP_SERVER, &ntpServer)) {
if (res == 1) { SNTP_init(SNTP_SOCK, NTP_SERVER, 0, sntpBuffer);
coloredMsg(LOG_BLUE, "wizsh, curTime: %04d-%02d-%02d %02d:%02d:%02d", int8_t res = SNTP_run(&curTime);
curTime.yy, curTime.mo, curTime.dd, coloredMsg(LOG_BLUE, "wizsh, res: %d", res);
curTime.hh, curTime.mm, curTime.ss); if (res == 1) {
coloredMsg(LOG_BLUE, "wizsh, curTime: %04d-%02d-%02d %02d:%02d:%02d",
curTime.yy, curTime.mo, curTime.dd,
curTime.hh, curTime.mm, curTime.ss);
} else {
coloredMsg(LOG_BLUE, "wizsh, error when requesting time");
}
} else { } else {
coloredMsg(LOG_BLUE, "wizsh, error when requesting time"); coloredMsg(LOG_BLUE, "wizsh, error when querying ntp server name");
} }
} }
@ -179,7 +185,6 @@ static void wizPhyLinkHandler(void *handle) {
dhcpInitialized = true; dhcpInitialized = true;
SNTP_init(SNTP_SOCK, NTP_SERVER, 0, sntpBuffer);
schAdd(wizSNTPHandler, NULL, 0, 60*1000); schAdd(wizSNTPHandler, NULL, 0, 60*1000);
coloredMsg(LOG_BLUE, "wizplh, SNTP handler scheduled"); coloredMsg(LOG_BLUE, "wizplh, SNTP handler scheduled");