feat(lwip): SNTP: Add support for adjusting startup delay

pull/13550/head
David Cermak 2024-03-15 16:58:54 +01:00
rodzic 8ed66457e6
commit 199d416bc5
2 zmienionych plików z 32 dodań i 0 usunięć

Wyświetl plik

@ -1077,6 +1077,26 @@ menu "LWIP"
Default is 1 hour. Must not be below 15 seconds by specification.
(SNTPv4 RFC 4330 enforces a minimum update time of 15 seconds).
config LWIP_SNTP_STARTUP_DELAY
bool "Enable SNTP startup delay"
default y
help
It is recommended (RFC 4330) to delay the initial request after by a random timeout from 1 to 5 minutes
to reduce potential load of NTP servers after simultaneous power-up of many devices.
This option disables this initial delay. Please use this option with care, it could improve
a single device responsiveness but might cause peaks on the network after reset.
Another option to address responsiveness of devices while using the initial random delay
is to adjust LWIP_SNTP_MAXIMUM_STARTUP_DELAY.
config LWIP_SNTP_MAXIMUM_STARTUP_DELAY
int "Maximum startup delay (ms)"
depends on LWIP_SNTP_STARTUP_DELAY
range 100 300000
default 5000
help
RFC 4330 recommends a startup delay before sending the initial request.
LWIP calculates this delay to a random number of milliseconds between 0 and this value.
endmenu # SNTP
menu "DNS"

Wyświetl plik

@ -1520,6 +1520,18 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min)
#define SNTP_SET_SYSTEM_TIME_US(sec, us) (sntp_set_system_time(sec, us))
#define SNTP_GET_SYSTEM_TIME(sec, us) (sntp_get_system_time(&(sec), &(us)))
/**
* Configuring SNTP startup delay
*/
#ifdef CONFIG_LWIP_SNTP_STARTUP_DELAY
#define SNTP_STARTUP_DELAY 1
#ifdef CONFIG_LWIP_SNTP_MAXIMUM_STARTUP_DELAY
#define SNTP_STARTUP_DELAY_FUNC (LWIP_RAND() % CONFIG_LWIP_SNTP_MAXIMUM_STARTUP_DELAY)
#endif /* CONFIG_LWIP_SNTP_MAXIMUM_STARTUP_DELAY */
#else
#define SNTP_STARTUP_DELAY 0
#endif /* SNTP_STARTUP_DELAY */
/*
---------------------------------------
--------- ESP specific options --------