Skip to content

Commit

Permalink
sntp/lwip: Add SNTP_UPDATE_DELAY option in Kconfig
Browse files Browse the repository at this point in the history
Closes: #2277
Closes: IDFGH-337
  • Loading branch information
KonstantinKondrashov authored and espressif-bot committed Oct 14, 2019
1 parent 07a3eca commit c50d44e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
31 changes: 22 additions & 9 deletions components/lwip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ menu "LWIP"
help
Enabling this option allows checking for available data on a netconn.

config LWIP_DHCP_MAX_NTP_SERVERS
int "Maximum number of NTP servers"
default 1
range 1 16
help
Set maximum number of NTP servers used by LwIP SNTP module.
First argument of sntp_setserver/sntp_setservername functions
is limited to this value.

config LWIP_IP_FRAG
bool "Enable fragment outgoing IP packets"
default n
Expand Down Expand Up @@ -560,4 +551,26 @@ menu "LWIP"

endmenu # LWIP RAW API

menu "SNTP"

config LWIP_DHCP_MAX_NTP_SERVERS
int "Maximum number of NTP servers"
default 1
range 1 16
help
Set maximum number of NTP servers used by LwIP SNTP module.
First argument of sntp_setserver/sntp_setservername functions
is limited to this value.

config LWIP_SNTP_UPDATE_DELAY
int "Request interval to update time (ms)"
range 15000 4294967295
default 3600000
help
This option allows you to set the time update period via SNTP.
Default is 1 hour. Must not be below 15 seconds by specification.
(SNTPv4 RFC 4330 enforces a minimum update time of 15 seconds).

endmenu # SNTP

endmenu
10 changes: 10 additions & 0 deletions components/lwip/port/esp32/include/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,16 @@ enum {
#define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS
#define LWIP_TIMEVAL_PRIVATE 0

/*
--------------------------------------
------------ SNTP options ------------
--------------------------------------
*/
/*
* SNTP update delay - in milliseconds
*/
#define SNTP_UPDATE_DELAY CONFIG_LWIP_SNTP_UPDATE_DELAY

#define SNTP_SET_SYSTEM_TIME_US(sec, us) \
do { \
struct timeval tv = { .tv_sec = sec, .tv_usec = us }; \
Expand Down

0 comments on commit c50d44e

Please sign in to comment.