diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index b7ba00f235..e5ec55b3d1 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -513,7 +513,7 @@ lmacRecycleMPDU = 0x40001b44; lmacRxDone = 0x40001b48; /*lmacSetTxFrame = 0x40001b4c;*/ lmacTxDone = 0x40001b50; -lmacTxFrame = 0x40001b54; +/*lmacTxFrame = 0x40001b54;*/ mac_tx_set_duration = 0x40001b58; mac_tx_set_htsig = 0x40001b5c; mac_tx_set_plcp0 = 0x40001b60; diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 51a293eecd..1cae06012e 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1789,6 +1789,29 @@ esp_err_t esp_wifi_set_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t* bw); */ esp_err_t esp_wifi_get_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw); +/** + * @brief Send action frame on target channel + * + * @param req action tx request structure containing relevant fields + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_NO_MEM: failed to allocate memory + * - ESP_FAIL: failed to send frame + */ +esp_err_t esp_wifi_action_tx_req(wifi_action_tx_req_t *req); + +/** + * @brief Remain on the target channel for required duration + * + * @param req roc request structure containing relevant fields + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_NO_MEM: failed to allocate memory + * - ESP_FAIL: failed to perform roc operation + */ +esp_err_t esp_wifi_remain_on_channel(wifi_roc_req_t * req); #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index bca0eb3cc8..a20b35fb00 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -41,15 +41,15 @@ typedef enum { WIFI_IF_MAX /**< Maximum number of interfaces */ } wifi_interface_t; -enum { +typedef enum { WIFI_OFFCHAN_TX_CANCEL, /**< Cancel off-channel transmission */ WIFI_OFFCHAN_TX_REQ, /**< Request off-channel transmission */ -}; +} wifi_action_tx_t; -enum { +typedef enum { WIFI_ROC_CANCEL, /**< Cancel remain on channel */ WIFI_ROC_REQ, /**< Request remain on channel */ -}; +} wifi_roc_t; /** * @brief Wi-Fi country policy */ @@ -776,8 +776,11 @@ typedef int (* wifi_action_rx_cb_t)(uint8_t *hdr, uint8_t *payload, typedef struct { wifi_interface_t ifx; /**< Wi-Fi interface to send request to */ uint8_t dest_mac[6]; /**< Destination MAC address */ + wifi_action_tx_t type; /**< ACTION TX operation type */ + uint8_t channel; /**< Channel on which to perform ACTION TX Operation */ + uint32_t wait_time_ms; /**< Duration to wait for on target channel */ bool no_ack; /**< Indicates no ack required */ - wifi_action_rx_cb_t rx_cb; /**< Rx Callback to receive any response */ + wifi_action_rx_cb_t rx_cb; /**< Rx Callback to receive action frames */ uint8_t op_id; /**< Unique Identifier for operation provided by wifi driver */ uint32_t data_len; /**< Length of the appended Data */ uint8_t data[0]; /**< Appended Data payload */ @@ -807,7 +810,7 @@ typedef void (* wifi_action_roc_done_cb_t)(uint32_t context, uint8_t op_id, */ typedef struct { wifi_interface_t ifx; /**< WiFi interface to send request to */ - uint8_t type; /**< ROC operation type */ + wifi_roc_t type; /**< ROC operation type */ uint8_t channel; /**< Channel on which to perform ROC Operation */ wifi_second_chan_t sec_channel; /**< Secondary channel */ uint32_t wait_time_ms; /**< Duration to wait for on target channel */ @@ -1274,6 +1277,7 @@ typedef struct { #define WIFI_STATIS_ALL (-1) /**< All status */ /** Status codes for WIFI_EVENT_ACTION_TX_STATUS evt */ +/** There will be back to back events in success case TX_DONE and TX_DURATION_COMPLETED */ typedef enum { WIFI_ACTION_TX_DONE = 0, /**< ACTION_TX operation was completed successfully */ WIFI_ACTION_TX_FAILED, /**< ACTION_TX operation failed during tx */ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 047a871bad..ff51fc60a1 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 047a871bada53b210101b7d931080eeee3d24895 +Subproject commit ff51fc60a1a02fda40dcdc6b63287a049992625c diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c index 8eb43cc1db..a28ad57592 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -101,7 +101,7 @@ static void esp_dpp_auth_conf_wait_timeout(void *eloop_ctx, void *timeout_ctx) esp_err_t esp_dpp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint32_t len, uint8_t channel, uint32_t wait_time_ms) { - wifi_action_tx_req_t *req = os_zalloc(sizeof(*req) + len);; + wifi_action_tx_req_t *req = os_zalloc(sizeof(*req) + len); if (!req) { return ESP_FAIL; } @@ -111,13 +111,15 @@ esp_err_t esp_dpp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint3 req->no_ack = false; req->data_len = len; req->rx_cb = s_action_rx_cb; + req->channel = channel; + req->wait_time_ms = wait_time_ms; + req->type = WIFI_OFFCHAN_TX_REQ; memcpy(req->data, buf, req->data_len); wpa_printf(MSG_DEBUG, "DPP: Mgmt Tx - MAC:" MACSTR ", Channel-%d, WaitT-%d", MAC2STR(dest_mac), channel, wait_time_ms); - if (ESP_OK != esp_wifi_action_tx_req(WIFI_OFFCHAN_TX_REQ, channel, - wait_time_ms, req)) { + if (ESP_OK != esp_wifi_action_tx_req(req)) { wpa_printf(MSG_ERROR, "DPP: Failed to perform offchannel operation"); esp_dpp_call_cb(ESP_SUPP_DPP_FAIL, (void *)ESP_ERR_DPP_TX_FAILURE); os_free(req); @@ -665,8 +667,8 @@ static void offchan_event_handler(void *arg, esp_event_base_t event_base, wifi_event_action_tx_status_t *evt = (wifi_event_action_tx_status_t *)event_data; if (evt->op_id == s_current_tx_op_id) { - wpa_printf(MSG_DEBUG, "Mgmt Tx Status - %d, Context - 0x%x Operation ID : %d", - evt->status, (uint32_t)evt->context, evt->op_id); + wpa_printf(MSG_DEBUG, + "Mgmt Tx Status - %d, Context - 0x%x Operation ID : %d", evt->status, (uint32_t)evt->context, evt->op_id); if (evt->status == WIFI_ACTION_TX_FAILED) { eloop_cancel_timeout(esp_dpp_auth_conf_wait_timeout, NULL, NULL); diff --git a/components/wpa_supplicant/port/include/os.h b/components/wpa_supplicant/port/include/os.h index 3ed465b3ae..af4677cae6 100644 --- a/components/wpa_supplicant/port/include/os.h +++ b/components/wpa_supplicant/port/include/os.h @@ -25,6 +25,7 @@ #include "esp_wifi.h" /* Modifying datatype for platform and compiler independence */ + typedef uint64_t os_time_t; /** diff --git a/components/wpa_supplicant/test_apps/main/test_offchannel.c b/components/wpa_supplicant/test_apps/main/test_offchannel.c index f8043e8a10..b616c19961 100644 --- a/components/wpa_supplicant/test_apps/main/test_offchannel.c +++ b/components/wpa_supplicant/test_apps/main/test_offchannel.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 * @@ -137,12 +137,16 @@ void esp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint32_t len, req->no_ack = false; req->data_len = len; req->rx_cb = dummy_rx_action; + req->channel = channel; + req->wait_time_ms = wait_time_ms; + req->type = WIFI_OFFCHAN_TX_REQ; + memcpy(req->data, buf, req->data_len); ESP_LOGI(TAG, "Action Tx - MAC:" MACSTR ", Channel-%d, WaitT-%" PRId32 "", MAC2STR(dest_mac), channel, wait_time_ms); - TEST_ESP_OK(esp_wifi_action_tx_req(WIFI_OFFCHAN_TX_REQ, channel, wait_time_ms, req)); + TEST_ESP_OK(esp_wifi_action_tx_req(req)); os_free(req); }