From 0f63b925010aedd0c2c91d4ef36638d9f0053a7f Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Tue, 9 Sep 2025 16:26:56 +0530 Subject: [PATCH] fix(esp_wifi): remove esp_interface.h and update usages --- .../esp_hw_support/include/esp_interface.h | 30 ------------------- .../esp_supplicant/src/esp_common.c | 2 +- components/wpa_supplicant/src/ap/wpa_auth.c | 2 +- .../low-power-mode/low-power-mode-wifi.rst | 2 +- .../low-power-mode/low-power-mode-wifi.rst | 2 +- examples/network/sta2eth/main/sta2eth_main.c | 8 ++--- .../usb/device/tusb_ncm/main/tusb_ncm_main.c | 6 ++-- .../http_server/captive_portal/main/main.c | 2 +- examples/wifi/espnow/main/espnow_example.h | 4 +-- examples/wifi/ftm/main/ftm_main.c | 22 +++++++------- .../dpp-enrollee/main/dpp_enrollee_main.c | 2 +- 11 files changed, 26 insertions(+), 56 deletions(-) delete mode 100644 components/esp_hw_support/include/esp_interface.h diff --git a/components/esp_hw_support/include/esp_interface.h b/components/esp_hw_support/include/esp_interface.h deleted file mode 100644 index 278825bee0..0000000000 --- a/components/esp_hw_support/include/esp_interface.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - - -#ifndef __ESP_INTERFACE_H__ -#define __ESP_INTERFACE_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - ESP_IF_WIFI_STA = 0, /**< Station interface */ - ESP_IF_WIFI_AP, /**< Soft-AP interface */ - ESP_IF_WIFI_NAN, /**< NAN interface */ - ESP_IF_ETH, /**< Ethernet interface */ - ESP_IF_MAX -} esp_interface_t; - -#ifdef __cplusplus -} -#endif - - -#endif /* __ESP_INTERFACE_TYPES_H__ */ diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index 0200a9f648..9e7f3656fc 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -139,7 +139,7 @@ static void register_mgmt_frames(struct wpa_supplicant *wpa_s) #ifdef CONFIG_IEEE80211R /* register auth/assoc frames if FT is enabled */ - if (esp_wifi_is_ft_enabled_internal(ESP_IF_WIFI_STA)) + if (esp_wifi_is_ft_enabled_internal(WIFI_IF_STA)) wpa_s->type |= (1 << WLAN_FC_STYPE_AUTH) | (1 << WLAN_FC_STYPE_ASSOC_RESP) | (1 << WLAN_FC_STYPE_REASSOC_RESP); diff --git a/components/wpa_supplicant/src/ap/wpa_auth.c b/components/wpa_supplicant/src/ap/wpa_auth.c index 6f1e6ae7f2..d38f6082a2 100644 --- a/components/wpa_supplicant/src/ap/wpa_auth.c +++ b/components/wpa_supplicant/src/ap/wpa_auth.c @@ -174,7 +174,7 @@ static inline int wpa_auth_set_key(struct wpa_authenticator *wpa_auth, } else { return -1; } - ret = esp_wifi_set_igtk_internal(ESP_IF_WIFI_AP, igtk); + ret = esp_wifi_set_igtk_internal(WIFI_IF_AP, igtk); os_free(igtk); return ret; diff --git a/docs/en/api-guides/low-power-mode/low-power-mode-wifi.rst b/docs/en/api-guides/low-power-mode/low-power-mode-wifi.rst index c09170b364..57fed47709 100644 --- a/docs/en/api-guides/low-power-mode/low-power-mode-wifi.rst +++ b/docs/en/api-guides/low-power-mode/low-power-mode-wifi.rst @@ -331,7 +331,7 @@ Modem-sleep Mode Configuration }, }; ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); ESP_ERROR_CHECK(esp_wifi_start()); - Recommended Configuration diff --git a/docs/zh_CN/api-guides/low-power-mode/low-power-mode-wifi.rst b/docs/zh_CN/api-guides/low-power-mode/low-power-mode-wifi.rst index 2ffe3331e9..532cf46196 100644 --- a/docs/zh_CN/api-guides/low-power-mode/low-power-mode-wifi.rst +++ b/docs/zh_CN/api-guides/low-power-mode/low-power-mode-wifi.rst @@ -331,7 +331,7 @@ Modem-sleep 模式配置 }, }; ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); ESP_ERROR_CHECK(esp_wifi_start()); - 推荐配置 diff --git a/examples/network/sta2eth/main/sta2eth_main.c b/examples/network/sta2eth/main/sta2eth_main.c index 7d5b1b61e5..6f745a608b 100644 --- a/examples/network/sta2eth/main/sta2eth_main.c +++ b/examples/network/sta2eth/main/sta2eth_main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -40,7 +40,7 @@ static esp_err_t wired_recv_callback(void *buffer, uint16_t len, void *ctx) { if (s_wifi_is_connected) { mac_spoof(FROM_WIRED, buffer, len, s_sta_mac); - if (esp_wifi_internal_tx(ESP_IF_WIFI_STA, buffer, len) != ESP_OK) { + if (esp_wifi_internal_tx(WIFI_IF_STA, buffer, len) != ESP_OK) { ESP_LOGD(TAG, "Failed to send packet to WiFi!"); } } @@ -68,14 +68,14 @@ static void event_handler(void *arg, esp_event_base_t event_base, if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { ESP_LOGI(TAG, "Wi-Fi STA disconnected"); s_wifi_is_connected = false; - esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_STA, NULL); + esp_wifi_internal_reg_rxcb(WIFI_IF_STA, NULL); esp_wifi_connect(); xEventGroupClearBits(s_event_flags, CONNECTED_BIT); xEventGroupSetBits(s_event_flags, DISCONNECTED_BIT); } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_CONNECTED) { ESP_LOGI(TAG, "Wi-Fi STA connected"); - esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_STA, wifi_recv_callback); + esp_wifi_internal_reg_rxcb(WIFI_IF_STA, wifi_recv_callback); s_wifi_is_connected = true; xEventGroupClearBits(s_event_flags, DISCONNECTED_BIT); xEventGroupSetBits(s_event_flags, CONNECTED_BIT); diff --git a/examples/peripherals/usb/device/tusb_ncm/main/tusb_ncm_main.c b/examples/peripherals/usb/device/tusb_ncm/main/tusb_ncm_main.c index be3a695f57..c95379a0f1 100644 --- a/examples/peripherals/usb/device/tusb_ncm/main/tusb_ncm_main.c +++ b/examples/peripherals/usb/device/tusb_ncm/main/tusb_ncm_main.c @@ -31,7 +31,7 @@ static esp_err_t usb_recv_callback(void *buffer, uint16_t len, void *ctx) { bool *is_wifi_connected = ctx; if (*is_wifi_connected) { - esp_wifi_internal_tx(ESP_IF_WIFI_STA, buffer, len); + esp_wifi_internal_tx(WIFI_IF_STA, buffer, len); } return ESP_OK; } @@ -57,11 +57,11 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base, if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { ESP_LOGI(TAG, "WiFi STA disconnected"); *is_connected = false; - esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_STA, NULL); + esp_wifi_internal_reg_rxcb(WIFI_IF_STA, NULL); esp_wifi_connect(); } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_CONNECTED) { ESP_LOGI(TAG, "WiFi STA connected"); - esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_STA, pkt_wifi2usb); + esp_wifi_internal_reg_rxcb(WIFI_IF_STA, pkt_wifi2usb); *is_connected = true; } } diff --git a/examples/protocols/http_server/captive_portal/main/main.c b/examples/protocols/http_server/captive_portal/main/main.c index 8fd8ef3ade..787003c4ea 100644 --- a/examples/protocols/http_server/captive_portal/main/main.c +++ b/examples/protocols/http_server/captive_portal/main/main.c @@ -65,7 +65,7 @@ static void wifi_init_softap(void) } ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP)); - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config)); ESP_ERROR_CHECK(esp_wifi_start()); esp_netif_ip_info_t ip_info; diff --git a/examples/wifi/espnow/main/espnow_example.h b/examples/wifi/espnow/main/espnow_example.h index 2de4f4a00e..4787fc6d79 100644 --- a/examples/wifi/espnow/main/espnow_example.h +++ b/examples/wifi/espnow/main/espnow_example.h @@ -13,10 +13,10 @@ /* ESPNOW can work in both station and softap mode. It is configured in menuconfig. */ #if CONFIG_ESPNOW_WIFI_MODE_STATION #define ESPNOW_WIFI_MODE WIFI_MODE_STA -#define ESPNOW_WIFI_IF ESP_IF_WIFI_STA +#define ESPNOW_WIFI_IF WIFI_IF_STA #else #define ESPNOW_WIFI_MODE WIFI_MODE_AP -#define ESPNOW_WIFI_IF ESP_IF_WIFI_AP +#define ESPNOW_WIFI_IF WIFI_IF_AP #endif #define ESPNOW_QUEUE_SIZE 6 diff --git a/examples/wifi/ftm/main/ftm_main.c b/examples/wifi/ftm/main/ftm_main.c index 87e65ee0b4..de6444b0f6 100644 --- a/examples/wifi/ftm/main/ftm_main.c +++ b/examples/wifi/ftm/main/ftm_main.c @@ -302,7 +302,7 @@ static bool wifi_cmd_sta_join(const char *ssid, const char *pass) if (pass) { strlcpy((char *) wifi_config.sta.password, pass, sizeof(wifi_config.sta.password)); } - ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); + ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); ESP_ERROR_CHECK( esp_wifi_connect() ); s_reconnect = true; s_retry_num = 0; @@ -436,27 +436,27 @@ static bool wifi_cmd_ap_set(const char* ssid, const char* pass, uint8_t channel, if (bw == 40) { proto.ghz_2g = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N; proto.ghz_5g = 0; - esp_wifi_set_protocols(ESP_IF_WIFI_AP, &proto); + esp_wifi_set_protocols(WIFI_IF_AP, &proto); bws.ghz_2g = WIFI_BW_HT40; - esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws); + esp_wifi_set_bandwidths(WIFI_IF_AP, &bws); } else { bws.ghz_2g = WIFI_BW_HT20; - esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws); + esp_wifi_set_bandwidths(WIFI_IF_AP, &bws); } } else { #if CONFIG_SOC_WIFI_SUPPORT_5G if (bw == 40) { proto.ghz_2g = 0; proto.ghz_5g = WIFI_PROTOCOL_11N | WIFI_PROTOCOL_11A; - esp_wifi_set_protocols(ESP_IF_WIFI_AP, &proto); + esp_wifi_set_protocols(WIFI_IF_AP, &proto); bws.ghz_5g=WIFI_BW_HT40; - esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws); + esp_wifi_set_bandwidths(WIFI_IF_AP, &bws); } else { proto.ghz_2g = 0; proto.ghz_5g = WIFI_PROTOCOL_11AC | WIFI_PROTOCOL_11A | WIFI_PROTOCOL_11AX; - esp_wifi_set_protocols(ESP_IF_WIFI_AP, &proto); + esp_wifi_set_protocols(WIFI_IF_AP, &proto); bws.ghz_5g = WIFI_BW_HT20; - esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws); + esp_wifi_set_bandwidths(WIFI_IF_AP, &bws); } #endif } @@ -464,7 +464,7 @@ static bool wifi_cmd_ap_set(const char* ssid, const char* pass, uint8_t channel, g_ap_config.ap.authmode = WIFI_AUTH_OPEN; } g_ap_config.ap.channel = channel; - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &g_ap_config)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &g_ap_config)); ESP_LOGI(TAG_AP, "Starting SoftAP with FTM Responder support, SSID - %s, Password - %s, Primary Channel - %d, Bandwidth - %dMHz", ap_args.ssid->sval[0], ap_args.password->sval[0], channel, bw); @@ -667,7 +667,7 @@ ftm_responder: return 0; } g_ap_config.ap.ftm_responder = true; - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &g_ap_config)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &g_ap_config)); ESP_LOGI(TAG_AP, "Re-starting SoftAP with FTM Responder enabled"); return 0; @@ -679,7 +679,7 @@ ftm_responder: return 0; } g_ap_config.ap.ftm_responder = false; - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &g_ap_config)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &g_ap_config)); ESP_LOGI(TAG_AP, "Re-starting SoftAP with FTM Responder disabled"); } diff --git a/examples/wifi/wifi_easy_connect/dpp-enrollee/main/dpp_enrollee_main.c b/examples/wifi/wifi_easy_connect/dpp-enrollee/main/dpp_enrollee_main.c index 97243704b3..5796b65207 100644 --- a/examples/wifi/wifi_easy_connect/dpp-enrollee/main/dpp_enrollee_main.c +++ b/examples/wifi/wifi_easy_connect/dpp-enrollee/main/dpp_enrollee_main.c @@ -85,7 +85,7 @@ static void event_handler(void *arg, esp_event_base_t event_base, wifi_event_dpp_config_received_t *config = event_data; memcpy(&s_dpp_wifi_config, &config->wifi_cfg, sizeof(s_dpp_wifi_config)); s_retry_num = 0; - esp_wifi_set_config(ESP_IF_WIFI_STA, &s_dpp_wifi_config); + esp_wifi_set_config(WIFI_IF_STA, &s_dpp_wifi_config); esp_wifi_connect(); break; case WIFI_EVENT_DPP_FAILED: