]> granicus.if.org Git - esp-idf/commitdiff
tcpip_adapter: unregister shutdown handlers, don’t fail on repeated registration
authorIvan Grokhotkov <ivan@espressif.com>
Mon, 8 Apr 2019 11:30:32 +0000 (19:30 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Thu, 11 Apr 2019 04:04:58 +0000 (12:04 +0800)
components/tcpip_adapter/event_handlers.c

index ff7847b286e4d6165d6539c3e327c046ed737163..99e4342a42020c8373c07a56d0c0365a1ac063b0 100644 (file)
@@ -242,7 +242,7 @@ esp_err_t tcpip_adapter_set_default_wifi_handlers()
     }
 
     err = esp_register_shutdown_handler((shutdown_handler_t)esp_wifi_stop);
-    if (err != ESP_OK) {
+    if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) {
         goto fail;
     }
 
@@ -263,8 +263,7 @@ esp_err_t tcpip_adapter_clear_default_wifi_handlers()
     esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_AP_STOP, handle_ap_stop);
     esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, handle_sta_got_ip);
     esp_event_handler_unregister(IP_EVENT, IP_EVENT_ETH_GOT_IP, handle_eth_got_ip);
-
-    /* TODO: introduce esp_unregister_shutdown_handler or similar, call it here */
+    esp_unregister_shutdown_handler((shutdown_handler_t)esp_wifi_stop);
 
     return ESP_OK;
 }