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) {
coloredMsg(LOG_BLUE, "wizsh, about to call SNTP");
int8_t res = SNTP_run(&curTime);
coloredMsg(LOG_BLUE, "wizsh, res: %d", res);
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);
uint8_t ntpServer[4];
if (wizDnsQuery(NTP_SERVER, &ntpServer)) {
SNTP_init(SNTP_SOCK, NTP_SERVER, 0, sntpBuffer);
int8_t res = SNTP_run(&curTime);
coloredMsg(LOG_BLUE, "wizsh, res: %d", res);
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 {
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;
SNTP_init(SNTP_SOCK, NTP_SERVER, 0, sntpBuffer);
schAdd(wizSNTPHandler, NULL, 0, 60*1000);
coloredMsg(LOG_BLUE, "wizplh, SNTP handler scheduled");