mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-12 21:41:28 +00:00
sntp: allow SNTP_UPDATE_DELAY to be a function
This commit is contained in:
parent
68d75a58df
commit
0c2d94a283
@ -71,9 +71,11 @@
|
|||||||
#define SNTP_SUPPORT_MULTIPLE_SERVERS 0
|
#define SNTP_SUPPORT_MULTIPLE_SERVERS 0
|
||||||
#endif /* NTP_MAX_SERVERS > 1 */
|
#endif /* NTP_MAX_SERVERS > 1 */
|
||||||
|
|
||||||
#if (SNTP_UPDATE_DELAY < 15000) && !defined(SNTP_SUPPRESS_DELAY_CHECK)
|
#ifndef SNTP_SUPPRESS_DELAY_CHECK
|
||||||
|
#if SNTP_UPDATE_DELAY < 15000
|
||||||
#error "SNTPv4 RFC 4330 enforces a minimum update time of 15 seconds (define SNTP_SUPPRESS_DELAY_CHECK to disable this error)!"
|
#error "SNTPv4 RFC 4330 enforces a minimum update time of 15 seconds (define SNTP_SUPPRESS_DELAY_CHECK to disable this error)!"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* the various debug levels for this file */
|
/* the various debug levels for this file */
|
||||||
#define SNTP_DEBUG_TRACE (SNTP_DEBUG | LWIP_DBG_TRACE)
|
#define SNTP_DEBUG_TRACE (SNTP_DEBUG | LWIP_DBG_TRACE)
|
||||||
@ -499,15 +501,17 @@ sntp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
|||||||
|
|
||||||
/* Set up timeout for next request (only if poll response was received)*/
|
/* Set up timeout for next request (only if poll response was received)*/
|
||||||
if (sntp_opmode == SNTP_OPMODE_POLL) {
|
if (sntp_opmode == SNTP_OPMODE_POLL) {
|
||||||
|
u32_t sntp_update_delay;
|
||||||
sys_untimeout(sntp_try_next_server, NULL);
|
sys_untimeout(sntp_try_next_server, NULL);
|
||||||
sys_untimeout(sntp_request, NULL);
|
sys_untimeout(sntp_request, NULL);
|
||||||
|
|
||||||
/* Correct response, reset retry timeout */
|
/* Correct response, reset retry timeout */
|
||||||
SNTP_RESET_RETRY_TIMEOUT();
|
SNTP_RESET_RETRY_TIMEOUT();
|
||||||
|
|
||||||
sys_timeout((u32_t)SNTP_UPDATE_DELAY, sntp_request, NULL);
|
sntp_update_delay = (u32_t)SNTP_UPDATE_DELAY;
|
||||||
|
sys_timeout(sntp_update_delay, sntp_request, NULL);
|
||||||
LWIP_DEBUGF(SNTP_DEBUG_STATE, ("sntp_recv: Scheduled next time request: %"U32_F" ms\n",
|
LWIP_DEBUGF(SNTP_DEBUG_STATE, ("sntp_recv: Scheduled next time request: %"U32_F" ms\n",
|
||||||
(u32_t)SNTP_UPDATE_DELAY));
|
sntp_update_delay));
|
||||||
}
|
}
|
||||||
} else if (err == SNTP_ERR_KOD) {
|
} else if (err == SNTP_ERR_KOD) {
|
||||||
/* KOD errors are only processed in case of an explicit poll response */
|
/* KOD errors are only processed in case of an explicit poll response */
|
||||||
|
Loading…
Reference in New Issue
Block a user