mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
lwip:optimization dhcp coarse timer
This commit is contained in:
@@ -283,6 +283,14 @@ menu "LWIP"
|
|||||||
options and values. If your code meets LWIP_ASSERT due to option value is too long.
|
options and values. If your code meets LWIP_ASSERT due to option value is too long.
|
||||||
Please increase the LWIP_DHCP_OPTIONS_LEN value.
|
Please increase the LWIP_DHCP_OPTIONS_LEN value.
|
||||||
|
|
||||||
|
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"
|
menu "DHCP server"
|
||||||
|
|
||||||
config LWIP_DHCPS
|
config LWIP_DHCPS
|
||||||
|
Submodule components/lwip/lwip updated: 6fa02bd30d...a7abf28e02
@@ -21,6 +21,11 @@
|
|||||||
#include "netif/dhcp_state.h"
|
#include "netif/dhcp_state.h"
|
||||||
#include "sntp/sntp_get_set_time.h"
|
#include "sntp/sntp_get_set_time.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Enable all Espressif-only options */
|
/* Enable all Espressif-only options */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -231,6 +236,33 @@
|
|||||||
*/
|
*/
|
||||||
#define ESP_DHCP_DISABLE_CLIENT_ID CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID
|
#define ESP_DHCP_DISABLE_CLIENT_ID CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID
|
||||||
|
|
||||||
|
#define DHCP_DEFINE_CUSTOM_TIMEOUTS 1
|
||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
#define DHCP_REQUEST_TIMEOUT_SEQUENCE(state, tries) (state == DHCP_STATE_REQUESTING ? \
|
||||||
|
(uint16_t)(1 * 1000) : \
|
||||||
|
(uint16_t)(((tries) < 6 ? 1 << (tries) : 60) * 250))
|
||||||
|
|
||||||
|
#define DHCP_COARSE_TIMER_SECS CONFIG_LWIP_DHCP_COARSE_TIMER_SECS
|
||||||
|
|
||||||
|
static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min)
|
||||||
|
{
|
||||||
|
uint32_t timeout = lease;
|
||||||
|
if (timeout == 0) {
|
||||||
|
timeout = min;
|
||||||
|
}
|
||||||
|
timeout = (timeout + DHCP_COARSE_TIMER_SECS - 1) / DHCP_COARSE_TIMER_SECS;
|
||||||
|
return timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DHCP_CALC_TIMEOUT_FROM_OFFERED_T0_LEASE(dhcp) \
|
||||||
|
timeout_from_offered((dhcp)->offered_t0_lease, 120)
|
||||||
|
#define DHCP_CALC_TIMEOUT_FROM_OFFERED_T1_RENEW(dhcp) \
|
||||||
|
timeout_from_offered((dhcp)->offered_t1_renew, (dhcp)->t0_timeout >> 1 /* 50% */)
|
||||||
|
#define DHCP_CALC_TIMEOUT_FROM_OFFERED_T2_REBIND(dhcp) \
|
||||||
|
timeout_from_offered((dhcp)->offered_t2_rebind, ((dhcp)->t0_timeout / 8) * 7 /* 87.5% */)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CONFIG_LWIP_DHCP_RESTORE_LAST_IP==1: Last valid IP address obtained from DHCP server
|
* CONFIG_LWIP_DHCP_RESTORE_LAST_IP==1: Last valid IP address obtained from DHCP server
|
||||||
* is restored after reset/power-up.
|
* is restored after reset/power-up.
|
||||||
@@ -1111,4 +1143,8 @@
|
|||||||
|
|
||||||
#define SOC_SEND_LOG //printf
|
#define SOC_SEND_LOG //printf
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __LWIPOPTS_H__ */
|
#endif /* __LWIPOPTS_H__ */
|
||||||
|
Reference in New Issue
Block a user