diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 17f4e89f..f7df67da 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -72,6 +72,7 @@ void system_station_got_ip_set(); static int dhcp_fail_time; static tcpip_adapter_ip_info_t esp_ip[TCPIP_ADAPTER_IF_MAX]; +static os_timer_t dhcp_check_timer; static void tcpip_adapter_dhcps_cb(u8_t client_ip[4]) { @@ -101,6 +102,7 @@ static void tcpip_adapter_dhcpc_done() { struct dhcp *clientdhcp = netif_dhcp_data(esp_netif[TCPIP_ADAPTER_IF_STA]) ; + os_timer_disarm(&dhcp_check_timer); if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_STA])) { if (clientdhcp->state == DHCP_STATE_BOUND) { /*send event here*/ @@ -110,7 +112,8 @@ static void tcpip_adapter_dhcpc_done() } else if (dhcp_fail_time < (CONFIG_IP_LOST_TIMER_INTERVAL * 1000 / 500)) { ESP_LOGD(TAG,"dhcpc time(ms): %d\n", dhcp_fail_time * 500); dhcp_fail_time ++; - sys_timeout(500, tcpip_adapter_dhcpc_done, NULL); + os_timer_setfn(&dhcp_check_timer, (os_timer_func_t*)tcpip_adapter_dhcpc_done, NULL); + os_timer_arm(&dhcp_check_timer, 500, 0); } else { ESP_LOGD(TAG,"ERROR dhcp get ip error\n"); } @@ -958,7 +961,9 @@ esp_err_t tcpip_adapter_dhcpc_start(tcpip_adapter_if_t tcpip_if) return ESP_ERR_TCPIP_ADAPTER_DHCPC_START_FAILED; } - sys_timeout(500, tcpip_adapter_dhcpc_done, NULL); + os_timer_disarm(&dhcp_check_timer); + os_timer_setfn(&dhcp_check_timer, (os_timer_func_t*)tcpip_adapter_dhcpc_done, NULL); + os_timer_arm(&dhcp_check_timer, 500, 0); ESP_LOGD(TAG, "dhcp client start successfully"); dhcpc_status[tcpip_if] = TCPIP_ADAPTER_DHCP_STARTED; return ESP_OK;