Merge branch 'feature/use_os_timer_instead_of_lwip_timer_list' into 'master'

feat(tcpip_adapter): use os timer instead of lwip timer list

See merge request sdk/ESP8266_RTOS_SDK!317
This commit is contained in:
Wu Jian Gang
2018-07-20 16:58:02 +08:00

View File

@ -72,6 +72,7 @@ void system_station_got_ip_set();
static int dhcp_fail_time; static int dhcp_fail_time;
static tcpip_adapter_ip_info_t esp_ip[TCPIP_ADAPTER_IF_MAX]; 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]) 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]) ; 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 (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_STA])) {
if (clientdhcp->state == DHCP_STATE_BOUND) { if (clientdhcp->state == DHCP_STATE_BOUND) {
/*send event here*/ /*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)) { } else if (dhcp_fail_time < (CONFIG_IP_LOST_TIMER_INTERVAL * 1000 / 500)) {
ESP_LOGD(TAG,"dhcpc time(ms): %d\n", dhcp_fail_time * 500); ESP_LOGD(TAG,"dhcpc time(ms): %d\n", dhcp_fail_time * 500);
dhcp_fail_time ++; 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 { } else {
ESP_LOGD(TAG,"ERROR dhcp get ip error\n"); 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; 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"); ESP_LOGD(TAG, "dhcp client start successfully");
dhcpc_status[tcpip_if] = TCPIP_ADAPTER_DHCP_STARTED; dhcpc_status[tcpip_if] = TCPIP_ADAPTER_DHCP_STARTED;
return ESP_OK; return ESP_OK;