mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(common_components): unregister event handler if wifi disconnect and stop reconnecting
This commit is contained in:
parent
c9f85be415
commit
35e36f2cab
@ -31,6 +31,42 @@ extern "C" {
|
|||||||
#define EXAMPLE_NETIF_DESC_ETH "example_netif_eth"
|
#define EXAMPLE_NETIF_DESC_ETH "example_netif_eth"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_CONNECT_PPP
|
||||||
|
#define EXAMPLE_NETIF_DESC_PPP "example_netif_ppp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_WIFI_SCAN_METHOD_FAST
|
||||||
|
#define EXAMPLE_WIFI_SCAN_METHOD WIFI_FAST_SCAN
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_SCAN_METHOD_ALL_CHANNEL
|
||||||
|
#define EXAMPLE_WIFI_SCAN_METHOD WIFI_ALL_CHANNEL_SCAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SIGNAL
|
||||||
|
#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SIGNAL
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SECURITY
|
||||||
|
#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SECURITY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_EXAMPLE_WIFI_AUTH_OPEN
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WEP
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_WPA2_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_ENTERPRISE
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_ENTERPRISE
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA3_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_WPA3_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK
|
||||||
|
#elif CONFIG_EXAMPLE_WIFI_AUTH_WAPI_PSK
|
||||||
|
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Example default interface, prefer the ethernet one if running in example-test (CI) configuration */
|
/* Example default interface, prefer the ethernet one if running in example-test (CI) configuration */
|
||||||
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
#if CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||||
#define EXAMPLE_INTERFACE get_example_netif_from_desc(EXAMPLE_NETIF_DESC_ETH)
|
#define EXAMPLE_INTERFACE get_example_netif_from_desc(EXAMPLE_NETIF_DESC_ETH)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -26,38 +26,6 @@ static SemaphoreHandle_t s_semph_get_ip_addrs = NULL;
|
|||||||
static SemaphoreHandle_t s_semph_get_ip6_addrs = NULL;
|
static SemaphoreHandle_t s_semph_get_ip6_addrs = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_EXAMPLE_WIFI_SCAN_METHOD_FAST
|
|
||||||
#define EXAMPLE_WIFI_SCAN_METHOD WIFI_FAST_SCAN
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_SCAN_METHOD_ALL_CHANNEL
|
|
||||||
#define EXAMPLE_WIFI_SCAN_METHOD WIFI_ALL_CHANNEL_SCAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SIGNAL
|
|
||||||
#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SIGNAL
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_CONNECT_AP_BY_SECURITY
|
|
||||||
#define EXAMPLE_WIFI_CONNECT_AP_SORT_METHOD WIFI_CONNECT_AP_BY_SECURITY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_EXAMPLE_WIFI_AUTH_OPEN
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WEP
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA_WPA2_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_ENTERPRISE
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_ENTERPRISE
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA3_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WPA2_WPA3_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK
|
|
||||||
#elif CONFIG_EXAMPLE_WIFI_AUTH_WAPI_PSK
|
|
||||||
#define EXAMPLE_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int s_retry_num = 0;
|
static int s_retry_num = 0;
|
||||||
|
|
||||||
static void example_handler_on_wifi_disconnect(void *arg, esp_event_base_t event_base,
|
static void example_handler_on_wifi_disconnect(void *arg, esp_event_base_t event_base,
|
||||||
@ -75,6 +43,7 @@ static void example_handler_on_wifi_disconnect(void *arg, esp_event_base_t event
|
|||||||
xSemaphoreGive(s_semph_get_ip6_addrs);
|
xSemaphoreGive(s_semph_get_ip6_addrs);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
example_wifi_sta_do_disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Wi-Fi disconnected, trying to reconnect...");
|
ESP_LOGI(TAG, "Wi-Fi disconnected, trying to reconnect...");
|
||||||
|
Loading…
Reference in New Issue
Block a user