From 2f6b681b1afd9d28152a306db59fbdc2095db1ff Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Tue, 10 Jan 2023 14:24:03 +0800 Subject: [PATCH] lwip:optimization dhcp coarse timer --- components/lwip/Kconfig | 8 ++++++++ components/lwip/port/include/lwipopts.h | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 9edc571761..ea863870bc 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -272,6 +272,14 @@ menu "LWIP" help Number of clients that may store data in client_data member array of struct netif. + config LWIP_DHCP_COARSE_TIMER_SECS + int "DHCP coarse timer interval(s)" + default 1 + range 1 10 + help + Set DHCP coarse interval in seconds. + A higher value will be less precise but cost less power consumption. + menu "DHCP server" config LWIP_DHCPS diff --git a/components/lwip/port/include/lwipopts.h b/components/lwip/port/include/lwipopts.h index 481951ff70..d97f82829d 100644 --- a/components/lwip/port/include/lwipopts.h +++ b/components/lwip/port/include/lwipopts.h @@ -347,7 +347,7 @@ extern "C" { #define ESP_DHCP_DISABLE_VENDOR_CLASS_IDENTIFIER CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID #define DHCP_DEFINE_CUSTOM_TIMEOUTS 1 -#define DHCP_COARSE_TIMER_SECS (1) +#define DHCP_COARSE_TIMER_SECS CONFIG_LWIP_DHCP_COARSE_TIMER_SECS #define DHCP_NEXT_TIMEOUT_THRESHOLD (3) /* Since for embedded devices it's not that hard to miss a discover packet, so lower * the discover retry backoff time from (2,4,8,16,32,60,60)s to (500m,1,2,4,8,15,15)s. @@ -362,6 +362,7 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) if (timeout == 0) { timeout = min; } + timeout = (timeout + DHCP_COARSE_TIMER_SECS - 1) / DHCP_COARSE_TIMER_SECS; return timeout; }