]> granicus.if.org Git - esp-idf/commitdiff
tcpip_adpater: set ip to zero in tcpip_adapter_down
authorWu Jian Gang <wujiangang@espressif.com>
Fri, 26 Aug 2016 04:03:52 +0000 (12:03 +0800)
committerWu Jian Gang <wujiangang@espressif.com>
Fri, 26 Aug 2016 11:06:38 +0000 (19:06 +0800)
In some cases, there will have "ip unchanged", and have no event posted
when station reconnected.

components/tcpip_adapter/tcpip_adapter_lwip.c

index d6ad20ad83792a91ba7c590dffe870fcf0777161..a2a37be4725c6223618e1ee37b97fde2a6e6bb00 100644 (file)
@@ -139,7 +139,7 @@ esp_err_t tcpip_adapter_up(tcpip_adapter_if_t tcpip_if)
 esp_err_t tcpip_adapter_down(tcpip_adapter_if_t tcpip_if)
 {
     if (tcpip_if == TCPIP_ADAPTER_IF_STA) {
-        if (esp_netif[tcpip_if] == NULL){
+        if (esp_netif[tcpip_if] == NULL) {
             return ESP_ERR_TCPIP_ADAPTER_IF_NOT_READY;
         }
 
@@ -155,6 +155,10 @@ esp_err_t tcpip_adapter_down(tcpip_adapter_if_t tcpip_if)
             netif_set_down(esp_netif[tcpip_if]);
             netif_set_addr(esp_netif[tcpip_if], IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY);
         }
+
+        ip4_addr_set_zero(&esp_ip[tcpip_if].ip);
+        ip4_addr_set_zero(&esp_ip[tcpip_if].gw);
+        ip4_addr_set_zero(&esp_ip[tcpip_if].netmask);
     }
 
     return ESP_OK;