diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index 164e19be75..81e54238e8 100644 --- a/components/esp_wifi/include/esp_now.h +++ b/components/esp_wifi/include/esp_now.h @@ -102,6 +102,31 @@ typedef wifi_tx_info_t esp_now_send_info_t; */ typedef wifi_tx_rate_config_t esp_now_rate_config_t; +/** + * @brief ESPNOW switch channel information + */ +typedef struct { + wifi_action_tx_t type; /**< ACTION TX operation type */ + uint8_t channel; /**< Channel on which to perform ESPNOW TX Operation */ + wifi_second_chan_t sec_channel; /**< Secondary channel */ + uint32_t wait_time_ms; /**< Duration to wait for on target channel */ + uint8_t op_id; /**< Unique Identifier for operation provided by wifi driver */ + uint8_t dest_mac[6]; /**< Destination MAC address */ + uint16_t data_len; /**< Length of the appended Data */ + uint8_t data[0]; /**< Appended Data payload */ +} esp_now_switch_channel_t; + +/** + * @brief ESPNOW remain on channel information + */ +typedef struct { + wifi_roc_t type; /**< ROC operation type */ + uint8_t channel; /**< Channel on which to perform ESPNOW ROC Operation */ + wifi_second_chan_t sec_channel; /**< Secondary channel */ + uint32_t wait_time_ms; /**< Duration to wait for on target channel */ + uint8_t op_id; /**< ID of this specific ROC operation provided by wifi driver */ +} esp_now_remain_on_channel_t; + /** * @brief Callback function of receiving ESPNOW data * @param esp_now_info received ESPNOW packet information @@ -394,6 +419,32 @@ esp_err_t esp_now_set_user_oui(uint8_t *oui); */ esp_err_t esp_now_get_user_oui(uint8_t *oui); +/** + * @brief ESPNOW switch to a specific channel for a required duration, and send one ESPNOW data. + * + * @param config ESPNOW switch channel relevant information + * + * @return + * - ESP_OK : succeed + * - ESP_ERR_NO_MEM: failed to allocate memory + * - ESP_ERR_INVALID_ARG: the pair is invalid + * - ESP_FAIL: failed to send frame + */ +esp_err_t esp_now_switch_channel_tx(esp_now_switch_channel_t *config); + +/** + * @brief ESPNOW remain on the target channel for required duration. + * + * @param config ESPNOW remain on channel relevant information + * + * @return + * - ESP_OK : succeed + * - ESP_ERR_NO_MEM: failed to allocate memory + * - ESP_ERR_INVALID_ARG: the pair is invalid + * - ESP_FAIL: failed to perform roc operation + */ +esp_err_t esp_now_remain_on_channel(esp_now_remain_on_channel_t *config); + /** * @} */ diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index e45c091363..abd4f5b053 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -1829,6 +1829,7 @@ esp_err_t esp_wifi_get_bandwidths(wifi_interface_t ifx, wifi_bandwidths_t *bw); * @return * - ESP_OK: succeed * - ESP_ERR_NO_MEM: failed to allocate memory + * - ESP_ERR_INVALID_ARG: the pair is invalid * - ESP_FAIL: failed to send frame */ esp_err_t esp_wifi_action_tx_req(wifi_action_tx_req_t *req); @@ -1841,6 +1842,7 @@ esp_err_t esp_wifi_action_tx_req(wifi_action_tx_req_t *req); * @return * - ESP_OK: succeed * - ESP_ERR_NO_MEM: failed to allocate memory + * - ESP_ERR_INVALID_ARG: the pair is invalid * - ESP_FAIL: failed to perform roc operation */ esp_err_t esp_wifi_remain_on_channel(wifi_roc_req_t * req); diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index 9494605707..e995cbc7ad 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -794,6 +794,7 @@ typedef struct { 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 */ + wifi_second_chan_t sec_channel; /**< Secondary channel */ 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 action frames */ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index dedfbcefb4..045f86a452 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit dedfbcefb450c85b413e5b2a7ba507fb0e399678 +Subproject commit 045f86a4527ddd4be1731ff3d2cc7e964c1d7410 diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c index 98189c53a5..bd8e11a44f 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c @@ -162,6 +162,7 @@ esp_err_t esp_dpp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint3 req->data_len = len; req->rx_cb = s_action_rx_cb; req->channel = channel; + req->sec_channel = WIFI_SECOND_CHAN_NONE; req->wait_time_ms = wait_time_ms; req->type = WIFI_OFFCHAN_TX_REQ; os_memcpy(req->data, buf, req->data_len); diff --git a/components/wpa_supplicant/test_apps/main/test_offchannel.c b/components/wpa_supplicant/test_apps/main/test_offchannel.c index e0ded0b572..0f73079e3b 100644 --- a/components/wpa_supplicant/test_apps/main/test_offchannel.c +++ b/components/wpa_supplicant/test_apps/main/test_offchannel.c @@ -135,6 +135,7 @@ void esp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint32_t len, req->data_len = len; req->rx_cb = dummy_rx_action; req->channel = channel; + req->sec_channel = WIFI_SECOND_CHAN_NONE; req->wait_time_ms = wait_time_ms; req->type = WIFI_OFFCHAN_TX_REQ;