feat(lwip): Integrate sntp with newlib time

This commit is contained in:
Wu Jian Gang
2018-05-03 14:53:35 +08:00
parent 0cffd7b916
commit 3918cb633b
3 changed files with 23 additions and 5 deletions

View File

@ -174,6 +174,11 @@ config LWIP_IP6_DEBUG
depends on LWIP_DEBUG
default n
config LWIP_SNTP_DEBUG
bool "Enable debugging for SNTP."
depends on LWIP_DEBUG
default n
config LWIP_SO_REUSE
bool "Enable SO_REUSEADDR option"
default n

View File

@ -86,4 +86,6 @@ typedef int sys_prot_t;
#define LWIP_PLATFORM_HTONS(_n) ((u16_t)((((_n) & 0xff) << 8) | (((_n) >> 8) & 0xff)))
#define LWIP_PLATFORM_HTONL(_n) ((u32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) ))
#define LWIP_TIMEVAL_PRIVATE 0
#endif /* __ARCH_CC_H__ */

View File

@ -711,11 +711,14 @@ extern void vPortFree(void *pv, const char * file, unsigned line);
#define SNTP_SERVER_DNS 1
#ifndef sntp_time_t
typedef long sntp_time_t;
#endif
extern void sntp_set_system_time(sntp_time_t GMT_Time);
#define SNTP_SET_SYSTEM_TIME sntp_set_system_time
#include <sys/time.h>
#define SNTP_SET_SYSTEM_TIME_US(sec, us) \
do { \
struct timeval tv = { .tv_sec = sec, .tv_usec = us }; \
settimeofday(&tv, NULL); \
} while (0);
/*
----------------------------------
----- Multicast/IGMP options -----
@ -2134,6 +2137,14 @@ extern void sntp_set_system_time(sntp_time_t GMT_Time);
#if CONFIG_LWIP_IP6_DEBUG
#define IP6_DEBUG LWIP_DBG_ON
#endif
/**
* SNTP_DEBUG: Enable debugging for SNTP.
*/
#if CONFIG_LWIP_SNTP_DEBUG
#define SNTP_DEBUG LWIP_DBG_ON
#endif
/**
* @}
*/