From 198d7d47547c296ae4d9a8500410e461fd58ba2e Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 8 Apr 2019 19:30:32 +0800 Subject: [PATCH] =?UTF-8?q?tcpip=5Fadapter:=20unregister=20shutdown=20hand?= =?UTF-8?q?lers,=20don=E2=80=99t=20fail=20on=20repeated=20registration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/tcpip_adapter/event_handlers.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/tcpip_adapter/event_handlers.c b/components/tcpip_adapter/event_handlers.c index ff7847b28..99e4342a4 100644 --- a/components/tcpip_adapter/event_handlers.c +++ b/components/tcpip_adapter/event_handlers.c @@ -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; }