[core] Include SNTP app from lwIP (#38)

This commit is contained in:
kolos
2022-12-06 22:47:22 +01:00
committed by GitHub
parent e806c4db3a
commit 9583bb35f5
2 changed files with 23 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ def env_add_lwip(
"+<src/netif/ethernet.c>", # 2.0.x
"+<src/netif/etharp.c>", # 1.4.x
"+<src/apps/mdns/mdns.c>",
"+<src/apps/sntp/sntp.c>",
*port_srcs,
],
includes=[

View File

@@ -63,3 +63,25 @@
#undef DNS_DEBUG
#undef IP6_DEBUG
#undef MDNS_DEBUG
/** Set this to 1 to support DNS names (or IP address strings) to set sntp servers
* One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
* \#define SNTP_SERVER_ADDRESS "pool.ntp.org"
*/
#define SNTP_SERVER_DNS 1
#define SNTP_SET_SYSTEM_TIME_US(sec, us) \
do { \
struct timeval tv = { .tv_sec = sec, .tv_usec = us }; \
settimeofday(&tv, NULL); \
} while (0);
#define SNTP_GET_SYSTEM_TIME(sec, us) \
do { \
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; \
gettimeofday(&tv, NULL); \
(sec) = tv.tv_sec; \
(us) = tv.tv_usec; \
} while (0);