From cf645ab6393ee0b05fd3f1d0522961fc576f548c Mon Sep 17 00:00:00 2001 From: Zhang Jun Hao Date: Mon, 6 Aug 2018 18:01:46 +0800 Subject: [PATCH] feat(lwip): make lwip timeouts to 3000ms in light sleep --- components/lwip/lwip/src/core/timeouts.c | 15 +++++++++++++++ components/tcpip_adapter/tcpip_adapter_lwip.c | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/components/lwip/lwip/src/core/timeouts.c b/components/lwip/lwip/src/core/timeouts.c index 6d64ac48..3f8b9b1f 100644 --- a/components/lwip/lwip/src/core/timeouts.c +++ b/components/lwip/lwip/src/core/timeouts.c @@ -112,6 +112,9 @@ const struct lwip_cyclic_timer lwip_cyclic_timers[] = { static struct sys_timeo *next_timeout; static u32_t timeouts_last_time; +/** For light sleep. time out. limit is 3000ms */ +u32_t LwipTimOutLim = 0; + #if LWIP_TCP /** global variable that shows if the tcp timer is currently scheduled or not */ static int tcpip_tcp_timer_active; @@ -196,6 +199,7 @@ void sys_timeouts_init(void) * @param handler callback function to call when msecs have elapsed * @param arg argument to pass to the callback function */ + #if LWIP_DEBUG_TIMERNAMES void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name) @@ -224,7 +228,18 @@ sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg) timeout->next = NULL; timeout->h = handler; timeout->arg = arg; + +#ifdef ESP_LWIP + if ((msecs + diff) < LwipTimOutLim) { + timeout->time = LwipTimOutLim; + msecs = LwipTimOutLim; + } else { + timeout->time = msecs + diff; + } +#else timeout->time = msecs + diff; +#endif + #if LWIP_DEBUG_TIMERNAMES timeout->handler_name = handler_name; LWIP_DEBUGF(TIMERS_DEBUG, ("sys_timeout: %p msecs=%"U32_F" handler=%s arg=%p\n", diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 5dd762e2..a29ba990 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -73,8 +73,6 @@ static bool tcpip_inited = false; static const char* TAG = "tcpip_adapter"; -u32_t LwipTimOutLim = 0; // For light sleep. time out. limit is 3000ms - /* Avoid warning. No header file has include these function */ err_t ethernetif_init(struct netif* netif); void system_station_got_ip_set();