From d0ace0d1c9faaa728cf2ed33eaf802cb5fc0e8f4 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Tue, 26 Sep 2023 07:43:43 +0200 Subject: [PATCH 1/6] feat(wifi_remote): Initial stubs for wifi-remote --- esp_wifi_remote/CMakeLists.txt | 8 +++ esp_wifi_remote/esp_wifi_remote.c | 52 ++++++++++++++ esp_wifi_remote/idf_component.yml | 1 + esp_wifi_remote/include/esp_wifi_remote.h | 27 ++++++++ esp_wifi_remote/wifi_remote_init.c | 32 +++++++++ esp_wifi_remote/wifi_remote_net.c | 82 +++++++++++++++++++++++ esp_wifi_remote/wifi_remote_rpc.c | 78 +++++++++++++++++++++ 7 files changed, 280 insertions(+) create mode 100644 esp_wifi_remote/CMakeLists.txt create mode 100644 esp_wifi_remote/esp_wifi_remote.c create mode 100644 esp_wifi_remote/idf_component.yml create mode 100644 esp_wifi_remote/include/esp_wifi_remote.h create mode 100644 esp_wifi_remote/wifi_remote_init.c create mode 100644 esp_wifi_remote/wifi_remote_net.c create mode 100644 esp_wifi_remote/wifi_remote_rpc.c diff --git a/esp_wifi_remote/CMakeLists.txt b/esp_wifi_remote/CMakeLists.txt new file mode 100644 index 0000000000..7d94483db5 --- /dev/null +++ b/esp_wifi_remote/CMakeLists.txt @@ -0,0 +1,8 @@ +if(NOT CONFIG_ESP_WIFI_ENABLED) + set(src_wifi_is_remote esp_wifi_remote.c) +endif() + +idf_component_register(INCLUDE_DIRS include + SRCS wifi_remote_rpc.c wifi_remote_net.c wifi_remote_init.c ${src_wifi_is_remote} + REQUIRES esp_event esp_netif + PRIV_REQUIRES esp_wifi esp_hosted) diff --git a/esp_wifi_remote/esp_wifi_remote.c b/esp_wifi_remote/esp_wifi_remote.c new file mode 100644 index 0000000000..9de43153f5 --- /dev/null +++ b/esp_wifi_remote/esp_wifi_remote.c @@ -0,0 +1,52 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "esp_wifi.h" +#include "esp_log.h" +#include "esp_wifi_remote.h" + +#define WEAK __attribute__((weak)) + +WEAK ESP_EVENT_DEFINE_BASE(WIFI_EVENT); + +WEAK wifi_osi_funcs_t g_wifi_osi_funcs; +WEAK const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; +WEAK uint64_t g_wifi_feature_caps; + +WEAK esp_err_t esp_wifi_connect(void) +{ + return remote_esp_wifi_connect(); +} + +WEAK esp_err_t esp_wifi_init(const wifi_init_config_t *config) +{ + return remote_esp_wifi_init(config); +} + +WEAK esp_err_t esp_wifi_set_mode(wifi_mode_t mode) +{ + return remote_esp_wifi_set_mode(mode); +} + +WEAK esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) +{ + return remote_esp_wifi_set_config(interface, conf); +} + +WEAK esp_err_t esp_wifi_start(void) +{ + return remote_esp_wifi_start(); +} + +WEAK esp_err_t esp_wifi_stop(void) +{ + return remote_esp_wifi_stop(); +} + +WEAK esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]) +{ + return remote_esp_wifi_get_mac(ifx, mac); +} diff --git a/esp_wifi_remote/idf_component.yml b/esp_wifi_remote/idf_component.yml new file mode 100644 index 0000000000..71e3fd1813 --- /dev/null +++ b/esp_wifi_remote/idf_component.yml @@ -0,0 +1 @@ +version: "1.0.0" diff --git a/esp_wifi_remote/include/esp_wifi_remote.h b/esp_wifi_remote/include/esp_wifi_remote.h new file mode 100644 index 0000000000..d324996107 --- /dev/null +++ b/esp_wifi_remote/include/esp_wifi_remote.h @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once +#include "esp_wifi.h" + +// Public API +esp_err_t remote_esp_wifi_connect(void); +esp_err_t remote_esp_wifi_init(const wifi_init_config_t *config); +esp_err_t remote_esp_wifi_set_mode(wifi_mode_t mode); +esp_err_t remote_esp_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf); +esp_err_t remote_esp_wifi_start(void); +esp_err_t remote_esp_wifi_stop(void); +esp_err_t remote_esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]); + + +// TODO: Move this to private include +// Private API +esp_err_t remote_esp_wifi_init_slave(void); + +// handling channels +esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, size_t len); +esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_err_t (*tx_cb)(void *, void *, size_t)); +esp_err_t esp_wifi_remote_rpc_channel_rx(void *h, void *buffer, size_t len); +esp_err_t esp_wifi_remote_rpc_channel_set(void *h, esp_err_t (*tx_cb)(void *, void *, size_t)); diff --git a/esp_wifi_remote/wifi_remote_init.c b/esp_wifi_remote/wifi_remote_init.c new file mode 100644 index 0000000000..b0ec6ba502 --- /dev/null +++ b/esp_wifi_remote/wifi_remote_init.c @@ -0,0 +1,32 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "esp_err.h" +#include +#include "esp_wifi_remote.h" + +esp_err_t remote_esp_wifi_init_slave(void) +{ + if (esp_hosted_setup() != ESP_OK) { + return ESP_FAIL; + } + esp_hosted_channel_fn_t tx_cb; + esp_hosted_channel_t * ch; + + // Add an RPC channel with default config (i.e. secure=true) + esp_hosted_channel_config_t config = ESP_HOSTED_CHANNEL_CONFIG_DEFAULT(); + ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_rpc_channel_rx); + esp_wifi_remote_rpc_channel_set(ch, tx_cb); + + // Add two other channels for the two WiFi interfaces (STA, softAP) in plain text + config.secure = false; + ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_channel_rx); // TODO: add checks for `ch` and `tx_cb` + esp_wifi_remote_channel_set(WIFI_IF_STA, ch, tx_cb); + ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_channel_rx); + esp_wifi_remote_channel_set(WIFI_IF_AP, ch, tx_cb); + + return ESP_OK; +} diff --git a/esp_wifi_remote/wifi_remote_net.c b/esp_wifi_remote/wifi_remote_net.c new file mode 100644 index 0000000000..8b21d84185 --- /dev/null +++ b/esp_wifi_remote/wifi_remote_net.c @@ -0,0 +1,82 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include "esp_err.h" +#include + +#define CHANNELS 2 + +static esp_hosted_channel_fn_t s_tx_cb[CHANNELS]; +static esp_hosted_channel_t *s_channel[CHANNELS]; +static wifi_rxcb_t s_rx_fn[CHANNELS]; + +esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, size_t len) +{ + if (h == s_channel[0]) { + return s_rx_fn[0](buffer, len, buffer); + } + if (h == s_channel[1]) { + return s_rx_fn[1](buffer, len, buffer); + } + return ESP_FAIL; +} + +esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_err_t (*tx_cb)(void *, void *, size_t)) +{ + if (ifx == WIFI_IF_STA) { + s_channel[0] = h; + s_tx_cb[0] = tx_cb; + return ESP_OK; + } + if (ifx == WIFI_IF_AP) { + s_channel[1] = h; + s_tx_cb[1] = tx_cb; + return ESP_OK; + } + return ESP_FAIL; +} + + +esp_err_t esp_wifi_internal_set_sta_ip(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_internal_reg_netstack_buf_cb(wifi_netstack_buf_ref_cb_t ref, wifi_netstack_buf_free_cb_t free) +{ + return ESP_OK; +} + +void esp_wifi_internal_free_rx_buffer(void* buffer) +{ +// free(buffer); +} + +int esp_wifi_internal_tx(wifi_interface_t ifx, void *buffer, uint16_t len) +{ + if (ifx == WIFI_IF_STA) { + return s_tx_cb[0](s_channel[0], buffer, len); + } + if (ifx == WIFI_IF_AP) { + return s_tx_cb[1](s_channel[1], buffer, len); + } + + return -1; +} + +esp_err_t esp_wifi_internal_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn) +{ + if (ifx == WIFI_IF_STA) { + s_rx_fn[0] = fn; + return ESP_OK; + } + if (ifx == WIFI_IF_AP) { + s_rx_fn[1] = fn; + return ESP_OK; + } + + return ESP_FAIL; +} diff --git a/esp_wifi_remote/wifi_remote_rpc.c b/esp_wifi_remote/wifi_remote_rpc.c new file mode 100644 index 0000000000..eaee8aceef --- /dev/null +++ b/esp_wifi_remote/wifi_remote_rpc.c @@ -0,0 +1,78 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include "esp_log.h" +#include "esp_err.h" +#include "esp_wifi.h" +#include "esp_wifi_remote.h" +#include "esp_hosted_api.h" + +static esp_hosted_channel_t *s_params_channel; +static esp_hosted_channel_fn_t s_params_tx; +static wifi_config_t s_last_wifi_conf; + +esp_err_t esp_wifi_remote_rpc_channel_rx(void *h, void *buffer, size_t len) +{ + if (h == s_params_channel && len == sizeof(s_last_wifi_conf)) { + memcpy(&s_last_wifi_conf, buffer, len); // TODO: use queue + return ESP_OK; + } + return ESP_FAIL; +} + +esp_err_t esp_wifi_remote_rpc_channel_set(void *h, esp_err_t (*tx_cb)(void *, void *, size_t)) +{ + s_params_channel =h; + s_params_tx = tx_cb; + return ESP_OK; +} + +esp_err_t remote_esp_wifi_connect(void) +{ + return test_wifi_connect(); +} + +esp_err_t remote_esp_wifi_init(const wifi_init_config_t *config) +{ + if (remote_esp_wifi_init_slave() != ESP_OK) { + return ESP_FAIL; + } + return test_wifi_init(config); +} + +esp_err_t remote_esp_wifi_set_mode(wifi_mode_t mode) +{ + return test_wifi_set_mode(mode); +} + +esp_err_t remote_esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) +{ + uint8_t *param = (uint8_t*)conf; + uint32_t checksum = 0; // TODO: generate a random number and add it to both + for (int i=0; i Date: Wed, 27 Sep 2023 09:59:35 +0200 Subject: [PATCH 2/6] fix(wifi_remote): Support for wifi_native injection --- esp_wifi_remote/CMakeLists.txt | 5 +- esp_wifi_remote/Kconfig | 144 +++++++++++++++ esp_wifi_remote/LICENSE | 202 ++++++++++++++++++++++ esp_wifi_remote/esp_wifi_remote.c | 1 + esp_wifi_remote/idf_component.yml | 7 +- esp_wifi_remote/include/esp_wifi_native.h | 16 ++ esp_wifi_remote/wifi_remote_net.c | 1 + esp_wifi_remote/wifi_remote_rpc.c | 14 +- 8 files changed, 381 insertions(+), 9 deletions(-) create mode 100644 esp_wifi_remote/Kconfig create mode 100644 esp_wifi_remote/LICENSE create mode 100644 esp_wifi_remote/include/esp_wifi_native.h diff --git a/esp_wifi_remote/CMakeLists.txt b/esp_wifi_remote/CMakeLists.txt index 7d94483db5..fd7d4a34fc 100644 --- a/esp_wifi_remote/CMakeLists.txt +++ b/esp_wifi_remote/CMakeLists.txt @@ -1,8 +1,11 @@ + if(NOT CONFIG_ESP_WIFI_ENABLED) set(src_wifi_is_remote esp_wifi_remote.c) endif() idf_component_register(INCLUDE_DIRS include SRCS wifi_remote_rpc.c wifi_remote_net.c wifi_remote_init.c ${src_wifi_is_remote} + ${INTERNAL_SRCS} REQUIRES esp_event esp_netif - PRIV_REQUIRES esp_wifi esp_hosted) + PRIV_INCLUDE_DIRS ${INTERNAL_INCLUDE_DIRS} + PRIV_REQUIRES esp_wifi esp_hosted_preview) diff --git a/esp_wifi_remote/Kconfig b/esp_wifi_remote/Kconfig new file mode 100644 index 0000000000..931ac6de35 --- /dev/null +++ b/esp_wifi_remote/Kconfig @@ -0,0 +1,144 @@ +menu "Wi-Fi Remote" + + config ESP_WIFI_REMOTE_ENABLED + bool + default y + + config ESP_WIFI_REMOTE_STATIC_RX_BUFFER_NUM + int "Max number of WiFi static RX buffers" + range 0 128 + default 0 + + config ESP_WIFI_REMOTE_DYNAMIC_RX_BUFFER_NUM + int "Max number of WiFi dynamic RX buffers" + range 0 1024 + default 0 + + choice ESP_WIFI_REMOTE_TX_BUFFER + prompt "Type of WiFi TX buffers" + default ESP_WIFI_REMOTE_DYNAMIC_TX_BUFFER + + config ESP_WIFI_REMOTE_STATIC_TX_BUFFER + bool "Static" + + config ESP_WIFI_REMOTE_DYNAMIC_TX_BUFFER + bool "Dynamic" + + endchoice + + config ESP_WIFI_REMOTE_TX_BUFFER_TYPE + int + default 0 if ESP_WIFI_REMOTE_STATIC_TX_BUFFER + default 1 if ESP_WIFI_REMOTE_DYNAMIC_TX_BUFFER + + config ESP_WIFI_REMOTE_STATIC_TX_BUFFER_NUM + int "Max number of WiFi static TX buffers" + depends on ESP_WIFI_REMOTE_STATIC_TX_BUFFER + range 0 64 + default 0 + + choice ESP_WIFI_REMOTE_MGMT_RX_BUFFER + prompt "Type of WiFi RX MGMT buffers" + default ESP_WIFI_REMOTE_STATIC_RX_MGMT_BUFFER + + config ESP_WIFI_REMOTE_STATIC_RX_MGMT_BUFFER + bool "Static" + config ESP_WIFI_REMOTE_DYNAMIC_RX_MGMT_BUFFER + bool "Dynamic" + endchoice + + config ESP_WIFI_REMOTE_DYNAMIC_RX_MGMT_BUF + int + default 0 if ESP_WIFI_REMOTE_STATIC_RX_MGMT_BUFFER + default 1 if ESP_WIFI_REMOTE_DYNAMIC_RX_MGMT_BUFFER + + config ESP_WIFI_REMOTE_RX_MGMT_BUF_NUM_DEF + int "Max number of WiFi RX MGMT buffers" + range 0 10 + default 0 + + config ESP_WIFI_REMOTE_CSI_ENABLED + bool "WiFi CSI(Channel State Information)" + depends on SOC_WIFI_REMOTE_CSI_SUPPORT + default n + + config ESP_WIFI_REMOTE_AMPDU_TX_ENABLED + bool "WiFi AMPDU TX" + default y + + config ESP_WIFI_REMOTE_TX_BA_WIN + int "WiFi AMPDU TX BA window size" + depends on ESP_WIFI_REMOTE_AMPDU_TX_ENABLED + range 0 64 if SOC_WIFI_REMOTE_HE_SUPPORT + default 0 + + config ESP_WIFI_REMOTE_AMPDU_RX_ENABLED + bool "WiFi AMPDU RX" + default y + + config ESP_REMOTE_WIFI_RX_BA_WIN + int "WiFi AMPDU RX BA window size" + depends on ESP_WIFI_REMOTE_AMPDU_RX_ENABLED + range 0 64 + default 0 + + config ESP_WIFI_REMOTE_ESPNOW_MAX_ENCRYPT_NUM + int "Maximum espnow encrypt peers number" + range 0 17 + default 0 + + if !ESP_WIFI_ENABLED + + config ESP_WIFI_STATIC_RX_BUFFER_NUM + int + default ESP_WIFI_REMOTE_STATIC_RX_BUFFER_NUM + + config ESP_WIFI_DYNAMIC_RX_BUFFER_NUM + int + default ESP_WIFI_REMOTE_DYNAMIC_RX_BUFFER_NUM + + config ESP_WIFI_TX_BUFFER_TYPE + int + default ESP_WIFI_REMOTE_TX_BUFFER_TYPE + + config ESP_WIFI_STATIC_TX_BUFFER_NUM + int + depends on ESP_WIFI_REMOTE_STATIC_TX_BUFFER + default ESP_WIFI_REMOTE_STATIC_TX_BUFFER_NUM + + config ESP_WIFI_DYNAMIC_RX_MGMT_BUF + int + default ESP_WIFI_REMOTE_DYNAMIC_RX_MGMT_BUF + + config ESP_WIFI_RX_MGMT_BUF_NUM_DEF + int + default ESP_WIFI_REMOTE_RX_MGMT_BUF_NUM_DEF + + config ESP_WIFI_CSI_ENABLED + bool + default ESP_WIFI_REMOTE_CSI_ENABLED + + config ESP_WIFI_AMPDU_TX_ENABLED + bool + default ESP_WIFI_REMOTE_AMPDU_TX_ENABLED + + config ESP_WIFI_TX_BA_WIN + int + default ESP_WIFI_REMOTE_TX_BA_WIN + + config ESP_WIFI_AMPDU_RX_ENABLED + bool + default ESP_WIFI_REMOTE_AMPDU_RX_ENABLED + + config ESP_WIFI_RX_BA_WIN + int + default ESP_REMOTE_WIFI_RX_BA_WIN + + config ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM + int + default ESP_WIFI_REMOTE_ESPNOW_MAX_ENCRYPT_NUM + + endif #!ESP_WIFI_ENABLED + + +endmenu # Wi-Fi remote diff --git a/esp_wifi_remote/LICENSE b/esp_wifi_remote/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/esp_wifi_remote/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/esp_wifi_remote/esp_wifi_remote.c b/esp_wifi_remote/esp_wifi_remote.c index 9de43153f5..4c2347d0df 100644 --- a/esp_wifi_remote/esp_wifi_remote.c +++ b/esp_wifi_remote/esp_wifi_remote.c @@ -5,6 +5,7 @@ */ #include "esp_wifi.h" +#include "esp_private/wifi_os_adapter.h" #include "esp_log.h" #include "esp_wifi_remote.h" diff --git a/esp_wifi_remote/idf_component.yml b/esp_wifi_remote/idf_component.yml index 71e3fd1813..f865f123af 100644 --- a/esp_wifi_remote/idf_component.yml +++ b/esp_wifi_remote/idf_component.yml @@ -1 +1,6 @@ -version: "1.0.0" +version: "0.0.5" +dependencies: + esp_hosted_preview: + version: "*" +# override_path: ${PREVIEW_PATH}/components/esp_hosted_preview + service_url: "https://components-staging.espressif.com/api" diff --git a/esp_wifi_remote/include/esp_wifi_native.h b/esp_wifi_remote/include/esp_wifi_native.h new file mode 100644 index 0000000000..2064a17753 --- /dev/null +++ b/esp_wifi_remote/include/esp_wifi_native.h @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + + +#define ESP_WIFI_MAX_CONN_NUM (15) /**< max number of stations which can connect to ESP32/ESP32S3/ESP32S2 soft-AP */ + +/** @brief List of stations associated with the Soft-AP */ +typedef struct wifi_sta_list_t { + wifi_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< station list */ + int num; /**< number of stations in the list (other entries are invalid) */ +} wifi_sta_list_t; \ No newline at end of file diff --git a/esp_wifi_remote/wifi_remote_net.c b/esp_wifi_remote/wifi_remote_net.c index 8b21d84185..b849cd8728 100644 --- a/esp_wifi_remote/wifi_remote_net.c +++ b/esp_wifi_remote/wifi_remote_net.c @@ -3,6 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ +#include "esp_wifi.h" #include #include "esp_err.h" #include diff --git a/esp_wifi_remote/wifi_remote_rpc.c b/esp_wifi_remote/wifi_remote_rpc.c index eaee8aceef..cb27ded88a 100644 --- a/esp_wifi_remote/wifi_remote_rpc.c +++ b/esp_wifi_remote/wifi_remote_rpc.c @@ -32,7 +32,7 @@ esp_err_t esp_wifi_remote_rpc_channel_set(void *h, esp_err_t (*tx_cb)(void *, vo esp_err_t remote_esp_wifi_connect(void) { - return test_wifi_connect(); + return esp_hosted_wifi_connect(); } esp_err_t remote_esp_wifi_init(const wifi_init_config_t *config) @@ -40,12 +40,12 @@ esp_err_t remote_esp_wifi_init(const wifi_init_config_t *config) if (remote_esp_wifi_init_slave() != ESP_OK) { return ESP_FAIL; } - return test_wifi_init(config); + return esp_hosted_wifi_init(config); } esp_err_t remote_esp_wifi_set_mode(wifi_mode_t mode) { - return test_wifi_set_mode(mode); + return esp_hosted_wifi_set_mode(mode); } esp_err_t remote_esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) @@ -59,20 +59,20 @@ esp_err_t remote_esp_wifi_set_config(wifi_interface_t interface, wifi_config_t * // s_params_tx(s_params_channel, param, sizeof(wifi_config_t)); // add only a checksum to the RPC - return test_wifi_set_config(interface, checksum); + return esp_hosted_wifi_set_config(interface, (wifi_config_t *)checksum); } esp_err_t remote_esp_wifi_start(void) { - return test_wifi_start(); + return esp_hosted_wifi_start(); } esp_err_t remote_esp_wifi_stop(void) { - return test_wifi_stop(); + return esp_hosted_wifi_stop(); } esp_err_t remote_esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]) { - return test_wifi_get_mac_addr(ifx, mac); + return esp_hosted_wifi_get_mac_addr(ifx, mac); } From edc3c2dee0c2b371041d54a9613054a0d97646ac Mon Sep 17 00:00:00 2001 From: Yogesh Mantri Date: Tue, 2 Jan 2024 17:09:37 +0800 Subject: [PATCH 3/6] feat(wifi_remote): Move to esp-protocols --- .pre-commit-config.yaml | 4 +- .../esp_wifi_remote}/CMakeLists.txt | 5 +- .../esp_wifi_remote}/Kconfig | 0 .../esp_wifi_remote}/LICENSE | 0 components/esp_wifi_remote/esp_wifi_remote.c | 215 ++++++++++++++++ components/esp_wifi_remote/idf_component.yml | 1 + .../include/esp_wifi_native.h | 2 +- .../esp_wifi_remote/include/esp_wifi_remote.h | 63 +++++ components/esp_wifi_remote/wifi_remote_init.c | 44 ++++ .../esp_wifi_remote}/wifi_remote_net.c | 29 ++- components/esp_wifi_remote/wifi_remote_rpc.c | 232 ++++++++++++++++++ esp_wifi_remote/esp_wifi_remote.c | 53 ---- esp_wifi_remote/idf_component.yml | 6 - esp_wifi_remote/include/esp_wifi_remote.h | 27 -- esp_wifi_remote/wifi_remote_init.c | 32 --- esp_wifi_remote/wifi_remote_rpc.c | 78 ------ 16 files changed, 577 insertions(+), 214 deletions(-) rename {esp_wifi_remote => components/esp_wifi_remote}/CMakeLists.txt (62%) rename {esp_wifi_remote => components/esp_wifi_remote}/Kconfig (100%) rename {esp_wifi_remote => components/esp_wifi_remote}/LICENSE (100%) create mode 100644 components/esp_wifi_remote/esp_wifi_remote.c create mode 100644 components/esp_wifi_remote/idf_component.yml rename {esp_wifi_remote => components/esp_wifi_remote}/include/esp_wifi_native.h (96%) create mode 100644 components/esp_wifi_remote/include/esp_wifi_remote.h create mode 100644 components/esp_wifi_remote/wifi_remote_init.c rename {esp_wifi_remote => components/esp_wifi_remote}/wifi_remote_net.c (64%) create mode 100644 components/esp_wifi_remote/wifi_remote_rpc.c delete mode 100644 esp_wifi_remote/esp_wifi_remote.c delete mode 100644 esp_wifi_remote/idf_component.yml delete mode 100644 esp_wifi_remote/include/esp_wifi_remote.h delete mode 100644 esp_wifi_remote/wifi_remote_init.c delete mode 100644 esp_wifi_remote/wifi_remote_rpc.c diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f60a43c21e..9b7ce9da4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,8 +61,8 @@ repos: - repo: local hooks: - id: commit message scopes - name: "commit message must be scoped with: mdns, modem, websocket, asio, mqtt_cxx, console, common, eppp" - entry: '\A(?!(feat|fix|ci|bump|test|docs)\((mdns|modem|common|console|websocket|asio|mqtt_cxx|examples|eppp)\)\:)' + name: "commit message must be scoped with: mdns, modem, websocket, asio, mqtt_cxx, console, common, eppp, wifi_remote" + entry: '\A(?!(feat|fix|ci|bump|test|docs)\((mdns|modem|common|console|websocket|asio|mqtt_cxx|examples|eppp|wifi_remote)\)\:)' language: pygrep args: [--multiline] stages: [commit-msg] diff --git a/esp_wifi_remote/CMakeLists.txt b/components/esp_wifi_remote/CMakeLists.txt similarity index 62% rename from esp_wifi_remote/CMakeLists.txt rename to components/esp_wifi_remote/CMakeLists.txt index fd7d4a34fc..7d94483db5 100644 --- a/esp_wifi_remote/CMakeLists.txt +++ b/components/esp_wifi_remote/CMakeLists.txt @@ -1,11 +1,8 @@ - if(NOT CONFIG_ESP_WIFI_ENABLED) set(src_wifi_is_remote esp_wifi_remote.c) endif() idf_component_register(INCLUDE_DIRS include SRCS wifi_remote_rpc.c wifi_remote_net.c wifi_remote_init.c ${src_wifi_is_remote} - ${INTERNAL_SRCS} REQUIRES esp_event esp_netif - PRIV_INCLUDE_DIRS ${INTERNAL_INCLUDE_DIRS} - PRIV_REQUIRES esp_wifi esp_hosted_preview) + PRIV_REQUIRES esp_wifi esp_hosted) diff --git a/esp_wifi_remote/Kconfig b/components/esp_wifi_remote/Kconfig similarity index 100% rename from esp_wifi_remote/Kconfig rename to components/esp_wifi_remote/Kconfig diff --git a/esp_wifi_remote/LICENSE b/components/esp_wifi_remote/LICENSE similarity index 100% rename from esp_wifi_remote/LICENSE rename to components/esp_wifi_remote/LICENSE diff --git a/components/esp_wifi_remote/esp_wifi_remote.c b/components/esp_wifi_remote/esp_wifi_remote.c new file mode 100644 index 0000000000..7b9fb31510 --- /dev/null +++ b/components/esp_wifi_remote/esp_wifi_remote.c @@ -0,0 +1,215 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "esp_wifi.h" +#include "esp_log.h" +#include "esp_wifi_remote.h" + +#define WEAK __attribute__((weak)) + +WEAK ESP_EVENT_DEFINE_BASE(WIFI_EVENT); + +WEAK wifi_osi_funcs_t g_wifi_osi_funcs; +WEAK const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; +WEAK uint64_t g_wifi_feature_caps = +#if CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE + CONFIG_FEATURE_WPA3_SAE_BIT | +#endif +#if CONFIG_SPIRAM + CONFIG_FEATURE_CACHE_TX_BUF_BIT | +#endif +#if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT + CONFIG_FEATURE_FTM_INITIATOR_BIT | +#endif +#if CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT + CONFIG_FEATURE_FTM_RESPONDER_BIT | +#endif + 0; + +WEAK esp_err_t esp_wifi_connect(void) +{ + return remote_esp_wifi_connect(); +} + +WEAK esp_err_t esp_wifi_disconnect(void) +{ + return remote_esp_wifi_disconnect(); +} + +WEAK esp_err_t esp_wifi_init(const wifi_init_config_t *config) +{ + return remote_esp_wifi_init(config); +} + +WEAK esp_err_t esp_wifi_deinit(void) +{ + return remote_esp_wifi_deinit(); +} + +WEAK esp_err_t esp_wifi_set_mode(wifi_mode_t mode) +{ + return remote_esp_wifi_set_mode(mode); +} + +WEAK esp_err_t esp_wifi_get_mode(wifi_mode_t *mode) +{ + return remote_esp_wifi_get_mode(mode); +} + +WEAK esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) +{ + return remote_esp_wifi_set_config(interface, conf); +} + +WEAK esp_err_t esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf) +{ + return remote_esp_wifi_get_config(interface, conf); +} + +WEAK esp_err_t esp_wifi_start(void) +{ + return remote_esp_wifi_start(); +} + +WEAK esp_err_t esp_wifi_stop(void) +{ + return remote_esp_wifi_stop(); +} + +WEAK esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]) +{ + return remote_esp_wifi_get_mac(ifx, mac); +} + +WEAK esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6]) +{ + return remote_esp_wifi_set_mac(ifx, mac); +} + +WEAK esp_err_t esp_wifi_scan_start(const wifi_scan_config_t *config, bool block) +{ + return remote_esp_wifi_scan_start(config, block); +} + +WEAK esp_err_t esp_wifi_scan_stop(void) +{ + return remote_esp_wifi_scan_stop(); +} + +WEAK esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number) +{ + return remote_esp_wifi_scan_get_ap_num(number); +} + +WEAK esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records) +{ + return remote_esp_wifi_scan_get_ap_records(number, ap_records); +} + +WEAK esp_err_t esp_wifi_clear_ap_list(void) +{ + return remote_esp_wifi_clear_ap_list(); +} + +WEAK esp_err_t esp_wifi_restore(void) +{ + return remote_esp_wifi_restore(); +} + +WEAK esp_err_t esp_wifi_clear_fast_connect(void) +{ + return remote_esp_wifi_clear_fast_connect(); +} + +WEAK esp_err_t esp_wifi_deauth_sta(uint16_t aid) +{ + return remote_esp_wifi_deauth_sta(aid); +} + +WEAK esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info) +{ + return remote_esp_wifi_sta_get_ap_info(ap_info); +} + +WEAK esp_err_t esp_wifi_set_ps(wifi_ps_type_t type) +{ + return remote_esp_wifi_set_ps(type); +} + +WEAK esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type) +{ + return remote_esp_wifi_get_ps(type); +} + +WEAK esp_err_t esp_wifi_set_storage(wifi_storage_t storage) +{ + return remote_esp_wifi_set_storage(storage); +} + +WEAK esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw) +{ + return remote_esp_wifi_set_bandwidth(ifx, bw); +} + +WEAK esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw) +{ + return remote_esp_wifi_get_bandwidth(ifx, bw); +} + +WEAK esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second) +{ + return remote_esp_wifi_set_channel(primary, second); +} + +WEAK esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second) +{ + return remote_esp_wifi_get_channel(primary, second); +} + +WEAK esp_err_t esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled) +{ + return remote_esp_wifi_set_country_code(country, ieee80211d_enabled); +} + +WEAK esp_err_t esp_wifi_get_country_code(char *country) +{ + return remote_esp_wifi_get_country_code(country); +} + +WEAK esp_err_t esp_wifi_set_country(const wifi_country_t *country) +{ + return remote_esp_wifi_set_country(country); +} + +WEAK esp_err_t esp_wifi_get_country(wifi_country_t *country) +{ + return remote_esp_wifi_get_country(country); +} + +WEAK esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta) +{ + return remote_esp_wifi_ap_get_sta_list(sta); +} + +WEAK esp_err_t esp_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid) +{ + return remote_esp_wifi_ap_get_sta_aid(mac, aid); +} + +WEAK esp_err_t esp_wifi_sta_get_rssi(int *rssi) +{ + return remote_esp_wifi_sta_get_rssi(rssi); +} + +WEAK esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap) +{ + return remote_esp_wifi_set_protocol(ifx, protocol_bitmap); +} + +WEAK esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap) +{ + return remote_esp_wifi_get_protocol(ifx, protocol_bitmap); +} diff --git a/components/esp_wifi_remote/idf_component.yml b/components/esp_wifi_remote/idf_component.yml new file mode 100644 index 0000000000..71e3fd1813 --- /dev/null +++ b/components/esp_wifi_remote/idf_component.yml @@ -0,0 +1 @@ +version: "1.0.0" diff --git a/esp_wifi_remote/include/esp_wifi_native.h b/components/esp_wifi_remote/include/esp_wifi_native.h similarity index 96% rename from esp_wifi_remote/include/esp_wifi_native.h rename to components/esp_wifi_remote/include/esp_wifi_native.h index 2064a17753..4c9f082bcb 100644 --- a/esp_wifi_remote/include/esp_wifi_native.h +++ b/components/esp_wifi_remote/include/esp_wifi_native.h @@ -13,4 +13,4 @@ typedef struct wifi_sta_list_t { wifi_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< station list */ int num; /**< number of stations in the list (other entries are invalid) */ -} wifi_sta_list_t; \ No newline at end of file +} wifi_sta_list_t; diff --git a/components/esp_wifi_remote/include/esp_wifi_remote.h b/components/esp_wifi_remote/include/esp_wifi_remote.h new file mode 100644 index 0000000000..d04f468e2d --- /dev/null +++ b/components/esp_wifi_remote/include/esp_wifi_remote.h @@ -0,0 +1,63 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once +#include "esp_wifi.h" + +typedef esp_err_t (*esp_remote_channel_rx_fn_t)(void *h, void *buffer, void *buff_to_free, size_t len); +typedef esp_err_t (*esp_remote_channel_tx_fn_t)(void *h, void *buffer, size_t len); + +typedef struct esp_remote_channel *esp_remote_channel_t; +typedef struct esp_remote_channel_config *esp_remote_channel_config_t; + +// Public API +esp_err_t remote_esp_wifi_connect(void); +esp_err_t remote_esp_wifi_disconnect(void); +esp_err_t remote_esp_wifi_init(const wifi_init_config_t *config); +esp_err_t remote_esp_wifi_deinit(void); +esp_err_t remote_esp_wifi_set_mode(wifi_mode_t mode); +esp_err_t remote_esp_wifi_get_mode(wifi_mode_t *mode); +esp_err_t remote_esp_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf); +esp_err_t remote_esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf); +esp_err_t remote_esp_wifi_start(void); +esp_err_t remote_esp_wifi_stop(void); +esp_err_t remote_esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]); +esp_err_t remote_esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6]); +esp_err_t remote_esp_wifi_scan_start(const wifi_scan_config_t *config, bool block); +esp_err_t remote_esp_wifi_scan_stop(void); +esp_err_t remote_esp_wifi_scan_get_ap_num(uint16_t *number); +esp_err_t remote_esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records); +esp_err_t remote_esp_wifi_clear_ap_list(void); +esp_err_t remote_esp_wifi_restore(void); +esp_err_t remote_esp_wifi_clear_fast_connect(void); +esp_err_t remote_esp_wifi_deauth_sta(uint16_t aid); +esp_err_t remote_esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info); +esp_err_t remote_esp_wifi_set_ps(wifi_ps_type_t type); +esp_err_t remote_esp_wifi_get_ps(wifi_ps_type_t *type); +esp_err_t remote_esp_wifi_set_storage(wifi_storage_t storage); +esp_err_t remote_esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw); +esp_err_t remote_esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw); +esp_err_t remote_esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second); +esp_err_t remote_esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second); +esp_err_t remote_esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled); +esp_err_t remote_esp_wifi_get_country_code(char *country); +esp_err_t remote_esp_wifi_set_country(const wifi_country_t *country); +esp_err_t remote_esp_wifi_get_country(wifi_country_t *country); +esp_err_t remote_esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta); +esp_err_t remote_esp_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid); +esp_err_t remote_esp_wifi_sta_get_rssi(int *rssi); +esp_err_t remote_esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap); +esp_err_t remote_esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap); + + +// TODO: Move this to private include +// Private API +esp_err_t remote_esp_wifi_init_slave(void); + +// handling channels +esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, void *buff_to_free, size_t len); +esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_remote_channel_tx_fn_t tx_cb); +esp_err_t esp_wifi_remote_rpc_channel_rx(void *h, void *buffer, size_t len); +esp_err_t esp_wifi_remote_rpc_channel_set(void *h, esp_remote_channel_tx_fn_t tx_cb); diff --git a/components/esp_wifi_remote/wifi_remote_init.c b/components/esp_wifi_remote/wifi_remote_init.c new file mode 100644 index 0000000000..77be4069a5 --- /dev/null +++ b/components/esp_wifi_remote/wifi_remote_init.c @@ -0,0 +1,44 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "esp_err.h" +#include "esp_log.h" +#include "esp_hosted_api.h" +#include "esp_wifi_remote.h" +const char *TAG = "esp_remote_wifi_init"; + +esp_err_t remote_esp_wifi_init_slave(void) +{ + ESP_LOGI(TAG, "** %s **", __func__); +#if 0 + if (esp_hosted_setup() != ESP_OK) { + return ESP_FAIL; + } +#endif + esp_remote_channel_tx_fn_t tx_cb; + esp_remote_channel_t ch; + + // Add an RPC channel with default config (i.e. secure=true) + struct esp_remote_channel_config config = ESP_HOSTED_CHANNEL_CONFIG_DEFAULT(); + config.if_type = ESP_SERIAL_IF; + //TODO: add rpc channel from here +//ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_rpc_channel_rx); +// esp_wifi_remote_rpc_channel_set(ch, tx_cb); + + // Add two other channels for the two WiFi interfaces (STA, softAP) in plain text + config.secure = false; + config.if_type = ESP_STA_IF; + ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_channel_rx); + esp_wifi_remote_channel_set(WIFI_IF_STA, ch, tx_cb); + + + config.secure = false; + config.if_type = ESP_AP_IF; + ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_channel_rx); + esp_wifi_remote_channel_set(WIFI_IF_AP, ch, tx_cb); + + return ESP_OK; +} diff --git a/esp_wifi_remote/wifi_remote_net.c b/components/esp_wifi_remote/wifi_remote_net.c similarity index 64% rename from esp_wifi_remote/wifi_remote_net.c rename to components/esp_wifi_remote/wifi_remote_net.c index b849cd8728..5bc3ec0cb0 100644 --- a/esp_wifi_remote/wifi_remote_net.c +++ b/components/esp_wifi_remote/wifi_remote_net.c @@ -1,31 +1,34 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ -#include "esp_wifi.h" #include #include "esp_err.h" -#include +#include "esp_wifi_remote.h" +#include "esp_log.h" #define CHANNELS 2 -static esp_hosted_channel_fn_t s_tx_cb[CHANNELS]; -static esp_hosted_channel_t *s_channel[CHANNELS]; +static esp_remote_channel_tx_fn_t s_tx_cb[CHANNELS]; +static esp_remote_channel_t s_channel[CHANNELS]; static wifi_rxcb_t s_rx_fn[CHANNELS]; -esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, size_t len) +esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, void *buff_to_free, size_t len) { + assert(h); if (h == s_channel[0]) { - return s_rx_fn[0](buffer, len, buffer); + assert(s_rx_fn[0]); + return s_rx_fn[0](buffer, len, buff_to_free); } if (h == s_channel[1]) { - return s_rx_fn[1](buffer, len, buffer); + assert(s_rx_fn[1]); + return s_rx_fn[1](buffer, len, buff_to_free); } return ESP_FAIL; } -esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_err_t (*tx_cb)(void *, void *, size_t)) +esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_remote_channel_tx_fn_t tx_cb) { if (ifx == WIFI_IF_STA) { s_channel[0] = h; @@ -51,14 +54,17 @@ esp_err_t esp_wifi_internal_reg_netstack_buf_cb(wifi_netstack_buf_ref_cb_t ref, return ESP_OK; } -void esp_wifi_internal_free_rx_buffer(void* buffer) +void esp_wifi_internal_free_rx_buffer(void *buffer) { -// free(buffer); + if (buffer) { + free(buffer); + } } int esp_wifi_internal_tx(wifi_interface_t ifx, void *buffer, uint16_t len) { if (ifx == WIFI_IF_STA) { + /* TODO: If not needed, remove arg3 */ return s_tx_cb[0](s_channel[0], buffer, len); } if (ifx == WIFI_IF_AP) { @@ -71,6 +77,7 @@ int esp_wifi_internal_tx(wifi_interface_t ifx, void *buffer, uint16_t len) esp_err_t esp_wifi_internal_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn) { if (ifx == WIFI_IF_STA) { + ESP_LOGI("esp_wifi_remote", "%s: sta: %p", __func__, fn); s_rx_fn[0] = fn; return ESP_OK; } diff --git a/components/esp_wifi_remote/wifi_remote_rpc.c b/components/esp_wifi_remote/wifi_remote_rpc.c new file mode 100644 index 0000000000..5f2494dce7 --- /dev/null +++ b/components/esp_wifi_remote/wifi_remote_rpc.c @@ -0,0 +1,232 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include "esp_log.h" +#include "esp_err.h" +#include "esp_wifi.h" +#include "esp_wifi_remote.h" +#include "esp_hosted_api.h" + +static esp_remote_channel_t s_params_channel; +static esp_remote_channel_tx_fn_t s_params_tx; +static wifi_config_t s_last_wifi_conf; + +esp_err_t esp_wifi_remote_rpc_channel_rx(void *h, void *buffer, size_t len) +{ + if (h == s_params_channel && len == sizeof(s_last_wifi_conf)) { + memcpy(&s_last_wifi_conf, buffer, len); // TODO: use queue + return ESP_OK; + } + return ESP_FAIL; +} + +esp_err_t esp_wifi_remote_rpc_channel_set(void *h, esp_err_t (*tx_cb)(void *, void *, size_t)) +{ + s_params_channel = h; + s_params_tx = tx_cb; + return ESP_OK; +} + +esp_err_t remote_esp_wifi_connect(void) +{ + return esp_hosted_wifi_connect(); +} + +esp_err_t remote_esp_wifi_disconnect(void) +{ + return esp_hosted_wifi_disconnect(); +} + +esp_err_t remote_esp_wifi_init(const wifi_init_config_t *config) +{ + if (remote_esp_wifi_init_slave() != ESP_OK) { + return ESP_FAIL; + } + return esp_hosted_wifi_init(config); +} + +esp_err_t remote_esp_wifi_deinit(void) +{ + return esp_hosted_wifi_deinit(); +} + +esp_err_t remote_esp_wifi_set_mode(wifi_mode_t mode) +{ + return esp_hosted_wifi_set_mode(mode); +} + +esp_err_t remote_esp_wifi_get_mode(wifi_mode_t *mode) +{ + return esp_hosted_wifi_get_mode(mode); +} + +esp_err_t remote_esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) +{ +#if 0 + uint8_t *param = (uint8_t *)conf; + uint32_t checksum = 0; // TODO: generate a random number and add it to both + for (int i = 0; i < sizeof(wifi_config_t); ++i) { + checksum += param[i]; + } + + // transmit the sensitive parameters over a secure channel +// s_params_tx(s_params_channel, param, sizeof(wifi_config_t)); + + // add only a checksum to the RPC + return esp_hosted_wifi_set_config(interface, checksum); +#endif + return esp_hosted_wifi_set_config(interface, conf); +} + +esp_err_t remote_esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf) +{ + return esp_hosted_wifi_get_config(interface, conf); +} + +esp_err_t remote_esp_wifi_start(void) +{ + return esp_hosted_wifi_start(); +} + +esp_err_t remote_esp_wifi_stop(void) +{ + return esp_hosted_wifi_stop(); +} + +esp_err_t remote_esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]) +{ + return esp_hosted_wifi_get_mac(ifx, mac); +} + +esp_err_t remote_esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6]) +{ + return esp_hosted_wifi_set_mac(ifx, mac); +} + +esp_err_t remote_esp_wifi_scan_start(const wifi_scan_config_t *config, bool block) +{ + return esp_hosted_wifi_scan_start(config, block); +} + +esp_err_t remote_esp_wifi_scan_stop(void) +{ + return esp_hosted_wifi_scan_stop(); +} + +esp_err_t remote_esp_wifi_scan_get_ap_num(uint16_t *number) +{ + return esp_hosted_wifi_scan_get_ap_num(number); +} + +esp_err_t remote_esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records) +{ + return esp_hosted_wifi_scan_get_ap_records(number, ap_records); +} + +esp_err_t remote_esp_wifi_clear_ap_list(void) +{ + return esp_hosted_wifi_clear_ap_list(); +} + +esp_err_t remote_esp_wifi_restore(void) +{ + return esp_hosted_wifi_restore(); +} + +esp_err_t remote_esp_wifi_clear_fast_connect(void) +{ + return esp_hosted_wifi_clear_fast_connect(); +} + +esp_err_t remote_esp_wifi_deauth_sta(uint16_t aid) +{ + return esp_hosted_wifi_deauth_sta(aid); +} + +esp_err_t remote_esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info) +{ + return esp_hosted_wifi_sta_get_ap_info(ap_info); +} + +esp_err_t remote_esp_wifi_set_ps(wifi_ps_type_t type) +{ + return esp_hosted_wifi_set_ps(type); +} + +esp_err_t remote_esp_wifi_get_ps(wifi_ps_type_t *type) +{ + return esp_hosted_wifi_get_ps(type); +} + +esp_err_t remote_esp_wifi_set_storage(wifi_storage_t storage) +{ + return esp_hosted_wifi_set_storage(storage); +} + +esp_err_t remote_esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw) +{ + return esp_hosted_wifi_set_bandwidth(ifx, bw); +} + +esp_err_t remote_esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw) +{ + return esp_hosted_wifi_get_bandwidth(ifx, bw); +} + +esp_err_t remote_esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second) +{ + return esp_hosted_wifi_set_channel(primary, second); +} + +esp_err_t remote_esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second) +{ + return esp_hosted_wifi_get_channel(primary, second); +} + +esp_err_t remote_esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled) +{ + return esp_hosted_wifi_set_country_code(country, ieee80211d_enabled); +} + +esp_err_t remote_esp_wifi_get_country_code(char *country) +{ + return esp_hosted_wifi_get_country_code(country); +} + +esp_err_t remote_esp_wifi_set_country(const wifi_country_t *country) +{ + return esp_hosted_wifi_set_country(country); +} + +esp_err_t remote_esp_wifi_get_country(wifi_country_t *country) +{ + return esp_hosted_wifi_get_country(country); +} + +esp_err_t remote_esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta) +{ + return esp_hosted_wifi_ap_get_sta_list(sta); +} + +esp_err_t remote_esp_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid) +{ + return esp_hosted_wifi_ap_get_sta_aid(mac, aid); +} + +esp_err_t remote_esp_wifi_sta_get_rssi(int *rssi) +{ + return esp_hosted_wifi_sta_get_rssi(rssi); +} + +esp_err_t remote_esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap) +{ + return esp_hosted_wifi_set_protocol(ifx, protocol_bitmap); +} + +esp_err_t remote_esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap) +{ + return esp_hosted_wifi_get_protocol(ifx, protocol_bitmap); +} diff --git a/esp_wifi_remote/esp_wifi_remote.c b/esp_wifi_remote/esp_wifi_remote.c deleted file mode 100644 index 4c2347d0df..0000000000 --- a/esp_wifi_remote/esp_wifi_remote.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "esp_wifi.h" -#include "esp_private/wifi_os_adapter.h" -#include "esp_log.h" -#include "esp_wifi_remote.h" - -#define WEAK __attribute__((weak)) - -WEAK ESP_EVENT_DEFINE_BASE(WIFI_EVENT); - -WEAK wifi_osi_funcs_t g_wifi_osi_funcs; -WEAK const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; -WEAK uint64_t g_wifi_feature_caps; - -WEAK esp_err_t esp_wifi_connect(void) -{ - return remote_esp_wifi_connect(); -} - -WEAK esp_err_t esp_wifi_init(const wifi_init_config_t *config) -{ - return remote_esp_wifi_init(config); -} - -WEAK esp_err_t esp_wifi_set_mode(wifi_mode_t mode) -{ - return remote_esp_wifi_set_mode(mode); -} - -WEAK esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) -{ - return remote_esp_wifi_set_config(interface, conf); -} - -WEAK esp_err_t esp_wifi_start(void) -{ - return remote_esp_wifi_start(); -} - -WEAK esp_err_t esp_wifi_stop(void) -{ - return remote_esp_wifi_stop(); -} - -WEAK esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]) -{ - return remote_esp_wifi_get_mac(ifx, mac); -} diff --git a/esp_wifi_remote/idf_component.yml b/esp_wifi_remote/idf_component.yml deleted file mode 100644 index f865f123af..0000000000 --- a/esp_wifi_remote/idf_component.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: "0.0.5" -dependencies: - esp_hosted_preview: - version: "*" -# override_path: ${PREVIEW_PATH}/components/esp_hosted_preview - service_url: "https://components-staging.espressif.com/api" diff --git a/esp_wifi_remote/include/esp_wifi_remote.h b/esp_wifi_remote/include/esp_wifi_remote.h deleted file mode 100644 index d324996107..0000000000 --- a/esp_wifi_remote/include/esp_wifi_remote.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once -#include "esp_wifi.h" - -// Public API -esp_err_t remote_esp_wifi_connect(void); -esp_err_t remote_esp_wifi_init(const wifi_init_config_t *config); -esp_err_t remote_esp_wifi_set_mode(wifi_mode_t mode); -esp_err_t remote_esp_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf); -esp_err_t remote_esp_wifi_start(void); -esp_err_t remote_esp_wifi_stop(void); -esp_err_t remote_esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]); - - -// TODO: Move this to private include -// Private API -esp_err_t remote_esp_wifi_init_slave(void); - -// handling channels -esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, size_t len); -esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_err_t (*tx_cb)(void *, void *, size_t)); -esp_err_t esp_wifi_remote_rpc_channel_rx(void *h, void *buffer, size_t len); -esp_err_t esp_wifi_remote_rpc_channel_set(void *h, esp_err_t (*tx_cb)(void *, void *, size_t)); diff --git a/esp_wifi_remote/wifi_remote_init.c b/esp_wifi_remote/wifi_remote_init.c deleted file mode 100644 index b0ec6ba502..0000000000 --- a/esp_wifi_remote/wifi_remote_init.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "esp_err.h" -#include -#include "esp_wifi_remote.h" - -esp_err_t remote_esp_wifi_init_slave(void) -{ - if (esp_hosted_setup() != ESP_OK) { - return ESP_FAIL; - } - esp_hosted_channel_fn_t tx_cb; - esp_hosted_channel_t * ch; - - // Add an RPC channel with default config (i.e. secure=true) - esp_hosted_channel_config_t config = ESP_HOSTED_CHANNEL_CONFIG_DEFAULT(); - ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_rpc_channel_rx); - esp_wifi_remote_rpc_channel_set(ch, tx_cb); - - // Add two other channels for the two WiFi interfaces (STA, softAP) in plain text - config.secure = false; - ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_channel_rx); // TODO: add checks for `ch` and `tx_cb` - esp_wifi_remote_channel_set(WIFI_IF_STA, ch, tx_cb); - ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_channel_rx); - esp_wifi_remote_channel_set(WIFI_IF_AP, ch, tx_cb); - - return ESP_OK; -} diff --git a/esp_wifi_remote/wifi_remote_rpc.c b/esp_wifi_remote/wifi_remote_rpc.c deleted file mode 100644 index cb27ded88a..0000000000 --- a/esp_wifi_remote/wifi_remote_rpc.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include -#include "esp_log.h" -#include "esp_err.h" -#include "esp_wifi.h" -#include "esp_wifi_remote.h" -#include "esp_hosted_api.h" - -static esp_hosted_channel_t *s_params_channel; -static esp_hosted_channel_fn_t s_params_tx; -static wifi_config_t s_last_wifi_conf; - -esp_err_t esp_wifi_remote_rpc_channel_rx(void *h, void *buffer, size_t len) -{ - if (h == s_params_channel && len == sizeof(s_last_wifi_conf)) { - memcpy(&s_last_wifi_conf, buffer, len); // TODO: use queue - return ESP_OK; - } - return ESP_FAIL; -} - -esp_err_t esp_wifi_remote_rpc_channel_set(void *h, esp_err_t (*tx_cb)(void *, void *, size_t)) -{ - s_params_channel =h; - s_params_tx = tx_cb; - return ESP_OK; -} - -esp_err_t remote_esp_wifi_connect(void) -{ - return esp_hosted_wifi_connect(); -} - -esp_err_t remote_esp_wifi_init(const wifi_init_config_t *config) -{ - if (remote_esp_wifi_init_slave() != ESP_OK) { - return ESP_FAIL; - } - return esp_hosted_wifi_init(config); -} - -esp_err_t remote_esp_wifi_set_mode(wifi_mode_t mode) -{ - return esp_hosted_wifi_set_mode(mode); -} - -esp_err_t remote_esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) -{ - uint8_t *param = (uint8_t*)conf; - uint32_t checksum = 0; // TODO: generate a random number and add it to both - for (int i=0; i Date: Mon, 4 Mar 2024 20:26:02 +0100 Subject: [PATCH 4/6] feat(wifi_remote): Added generation step for wifi_remote based on IDF --- .github/workflows/wifi_remote__build.yml | 51 ++ .pre-commit-config.yaml | 2 +- ci/ignore_astyle.txt | 2 + components/esp_wifi_remote/.cz.yaml | 8 + components/esp_wifi_remote/CMakeLists.txt | 13 +- components/esp_wifi_remote/Kconfig | 739 +++++++++++++++--- .../esp_wifi_remote/Kconfig.soc_wifi_caps.in | 229 ++++++ components/esp_wifi_remote/README.md | 26 + components/esp_wifi_remote/esp_wifi_remote.c | 191 +---- ...ifi_remote_net.c => esp_wifi_remote_net.c} | 33 +- .../esp_wifi_remote/esp_wifi_remote_weak.c | 397 ++++++++++ .../esp_wifi_remote/esp_wifi_with_remote.c | 393 ++++++++++ components/esp_wifi_remote/idf_component.yml | 9 +- .../esp_wifi_remote/include/esp_wifi_native.h | 16 - .../esp_wifi_remote/include/esp_wifi_remote.h | 76 +- .../include/esp_wifi_remote_api.h | 84 ++ .../include/esp_wifi_remote_with_hosted.h | 386 +++++++++ .../include/esp_wifi_types_native.h | 134 ++++ components/esp_wifi_remote/scripts/Kconfig | 633 +++++++++++++++ components/esp_wifi_remote/scripts/README.md | 38 + .../scripts/copyright_header.h | 6 + .../scripts/generate_and_check.py | 387 +++++++++ .../scripts/ignore_extensions.h | 13 + .../test/smoke_test/CMakeLists.txt | 8 + .../esp_wifi_remote/test/smoke_test/README.md | 5 + .../components/esp_hosted/CMakeLists.txt | 3 + .../smoke_test/components/esp_hosted/Kconfig | 21 + .../components/esp_hosted/esp_hosted_mock.c | 393 ++++++++++ .../components/esp_hosted/idf_component.yml | 1 + .../esp_hosted/include/esp_hosted_api.h | 21 + .../esp_hosted/include/esp_hosted_mock.h | 84 ++ .../esp_hosted/include/esp_hosted_wifi_api.h | 8 + .../test/smoke_test/main/CMakeLists.txt | 2 + .../test/smoke_test/main/all_wifi_calls.c | 411 ++++++++++ .../smoke_test/main/all_wifi_remote_calls.c | 411 ++++++++++ .../test/smoke_test/main/idf_component.yml | 8 + .../test/smoke_test/main/smoke_test.c | 21 + .../test/smoke_test/sdkconfig.ci.slave_esp32 | 1 + .../smoke_test/sdkconfig.ci.slave_esp32c2 | 1 + .../smoke_test/sdkconfig.ci.slave_esp32c3 | 1 + .../smoke_test/sdkconfig.ci.slave_esp32c6 | 1 + .../smoke_test/sdkconfig.ci.slave_esp32s2 | 1 + .../smoke_test/sdkconfig.ci.slave_esp32s3 | 1 + components/esp_wifi_remote/wifi_remote_init.c | 44 -- components/esp_wifi_remote/wifi_remote_rpc.c | 232 ------ 45 files changed, 4887 insertions(+), 658 deletions(-) create mode 100644 .github/workflows/wifi_remote__build.yml create mode 100644 ci/ignore_astyle.txt create mode 100644 components/esp_wifi_remote/.cz.yaml create mode 100644 components/esp_wifi_remote/Kconfig.soc_wifi_caps.in create mode 100644 components/esp_wifi_remote/README.md rename components/esp_wifi_remote/{wifi_remote_net.c => esp_wifi_remote_net.c} (57%) create mode 100644 components/esp_wifi_remote/esp_wifi_remote_weak.c create mode 100644 components/esp_wifi_remote/esp_wifi_with_remote.c delete mode 100644 components/esp_wifi_remote/include/esp_wifi_native.h create mode 100644 components/esp_wifi_remote/include/esp_wifi_remote_api.h create mode 100644 components/esp_wifi_remote/include/esp_wifi_remote_with_hosted.h create mode 100644 components/esp_wifi_remote/include/esp_wifi_types_native.h create mode 100644 components/esp_wifi_remote/scripts/Kconfig create mode 100644 components/esp_wifi_remote/scripts/README.md create mode 100644 components/esp_wifi_remote/scripts/copyright_header.h create mode 100644 components/esp_wifi_remote/scripts/generate_and_check.py create mode 100644 components/esp_wifi_remote/scripts/ignore_extensions.h create mode 100644 components/esp_wifi_remote/test/smoke_test/CMakeLists.txt create mode 100644 components/esp_wifi_remote/test/smoke_test/README.md create mode 100644 components/esp_wifi_remote/test/smoke_test/components/esp_hosted/CMakeLists.txt create mode 100644 components/esp_wifi_remote/test/smoke_test/components/esp_hosted/Kconfig create mode 100644 components/esp_wifi_remote/test/smoke_test/components/esp_hosted/esp_hosted_mock.c create mode 100644 components/esp_wifi_remote/test/smoke_test/components/esp_hosted/idf_component.yml create mode 100644 components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_api.h create mode 100644 components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_mock.h create mode 100644 components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_wifi_api.h create mode 100644 components/esp_wifi_remote/test/smoke_test/main/CMakeLists.txt create mode 100644 components/esp_wifi_remote/test/smoke_test/main/all_wifi_calls.c create mode 100644 components/esp_wifi_remote/test/smoke_test/main/all_wifi_remote_calls.c create mode 100644 components/esp_wifi_remote/test/smoke_test/main/idf_component.yml create mode 100644 components/esp_wifi_remote/test/smoke_test/main/smoke_test.c create mode 100644 components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32 create mode 100644 components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c2 create mode 100644 components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c3 create mode 100644 components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c6 create mode 100644 components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32s2 create mode 100644 components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32s3 delete mode 100644 components/esp_wifi_remote/wifi_remote_init.c delete mode 100644 components/esp_wifi_remote/wifi_remote_rpc.c diff --git a/.github/workflows/wifi_remote__build.yml b/.github/workflows/wifi_remote__build.yml new file mode 100644 index 0000000000..0309273db2 --- /dev/null +++ b/.github/workflows/wifi_remote__build.yml @@ -0,0 +1,51 @@ +name: "esp_wifi_remote: build-tests" + +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened, labeled] + +jobs: + wifi_remote_api_compat: + if: contains(github.event.pull_request.labels.*.name, 'wifi_remote') || github.event_name == 'push' + name: Check API compatibility of WiFi Remote + strategy: + matrix: + idf_ver: ["latest"] + runs-on: ubuntu-20.04 + container: espressif/idf:${{ matrix.idf_ver }} + steps: + - name: Checkout esp-protocols + uses: actions/checkout@v3 + - name: Check that headers are the same as generated + shell: bash + run: | + ${IDF_PATH}/install.sh --enable-pytest + . ${IDF_PATH}/export.sh + cd ./components/esp_wifi_remote/scripts + python generate_and_check.py + + build_wifi_remote: + if: contains(github.event.pull_request.labels.*.name, 'wifi_remote') || github.event_name == 'push' + name: Build WiFi Remote + strategy: + matrix: + idf_ver: ["latest"] + test: [ { app: smoke_test, path: "test/smoke_test" }] + runs-on: ubuntu-20.04 + container: espressif/idf:${{ matrix.idf_ver }} + steps: + - name: Checkout esp-protocols + uses: actions/checkout@v3 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ matrix.idf_ver }} + - name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }} + shell: bash + run: | + ${IDF_PATH}/install.sh --enable-pytest + . ${IDF_PATH}/export.sh + python ./ci/build_apps.py ./components/esp_wifi_remote/${{matrix.test.path}} -vv --preserve-all diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b7ce9da4e..9a2a622ec1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,7 +51,7 @@ repos: rev: c0013808882a15a0c0c2c1a9b5c903866c53a653 hooks: - id: astyle_py - args: ['--style=otbs', '--attach-namespaces', '--attach-classes', '--indent=spaces=4', '--convert-tabs', '--align-pointer=name', '--align-reference=name', '--keep-one-line-statements', '--pad-header', '--pad-oper'] + args: ['--style=otbs', '--attach-namespaces', '--attach-classes', '--indent=spaces=4', '--convert-tabs', '--align-pointer=name', '--align-reference=name', '--keep-one-line-statements', '--pad-header', '--pad-oper', '--exclude-list=ci/ignore_astyle.txt'] - repo: https://github.com/commitizen-tools/commitizen rev: v2.42.1 hooks: diff --git a/ci/ignore_astyle.txt b/ci/ignore_astyle.txt new file mode 100644 index 0000000000..e8c2695723 --- /dev/null +++ b/ci/ignore_astyle.txt @@ -0,0 +1,2 @@ +# The below file is generated from esp_wifi_types_native.h in IDF, which doesn't follow atyle +components/esp_wifi_remote/include/esp_wifi_types_native.h diff --git a/components/esp_wifi_remote/.cz.yaml b/components/esp_wifi_remote/.cz.yaml new file mode 100644 index 0000000000..8bc23f2aa8 --- /dev/null +++ b/components/esp_wifi_remote/.cz.yaml @@ -0,0 +1,8 @@ +--- +commitizen: + bump_message: 'bump(wifi_remote): $current_version -> $new_version' + pre_bump_hooks: python ../../ci/changelog.py esp_wifi_remote + tag_format: wifi_remote-v$version + version: 0.1.12 + version_files: + - idf_component.yml diff --git a/components/esp_wifi_remote/CMakeLists.txt b/components/esp_wifi_remote/CMakeLists.txt index 7d94483db5..577a37e008 100644 --- a/components/esp_wifi_remote/CMakeLists.txt +++ b/components/esp_wifi_remote/CMakeLists.txt @@ -1,8 +1,15 @@ if(NOT CONFIG_ESP_WIFI_ENABLED) - set(src_wifi_is_remote esp_wifi_remote.c) + set(src_wifi_is_remote esp_wifi_remote.c esp_wifi_with_remote.c) endif() idf_component_register(INCLUDE_DIRS include - SRCS wifi_remote_rpc.c wifi_remote_net.c wifi_remote_init.c ${src_wifi_is_remote} + SRCS ${src_wifi_is_remote} + esp_wifi_remote_net.c + esp_wifi_remote_weak.c REQUIRES esp_event esp_netif - PRIV_REQUIRES esp_wifi esp_hosted) + PRIV_REQUIRES esp_wifi) + +idf_component_optional_requires(PRIVATE esp_hosted) + +idf_component_get_property(wifi esp_wifi COMPONENT_LIB) +target_link_libraries(${wifi} PUBLIC ${COMPONENT_LIB}) diff --git a/components/esp_wifi_remote/Kconfig b/components/esp_wifi_remote/Kconfig index 931ac6de35..c59c60db75 100644 --- a/components/esp_wifi_remote/Kconfig +++ b/components/esp_wifi_remote/Kconfig @@ -1,144 +1,657 @@ +# This file is auto-generated menu "Wi-Fi Remote" - config ESP_WIFI_REMOTE_ENABLED bool default y - config ESP_WIFI_REMOTE_STATIC_RX_BUFFER_NUM - int "Max number of WiFi static RX buffers" - range 0 128 - default 0 - - config ESP_WIFI_REMOTE_DYNAMIC_RX_BUFFER_NUM - int "Max number of WiFi dynamic RX buffers" - range 0 1024 - default 0 - - choice ESP_WIFI_REMOTE_TX_BUFFER - prompt "Type of WiFi TX buffers" - default ESP_WIFI_REMOTE_DYNAMIC_TX_BUFFER - - config ESP_WIFI_REMOTE_STATIC_TX_BUFFER - bool "Static" - - config ESP_WIFI_REMOTE_DYNAMIC_TX_BUFFER - bool "Dynamic" - - endchoice - - config ESP_WIFI_REMOTE_TX_BUFFER_TYPE - int - default 0 if ESP_WIFI_REMOTE_STATIC_TX_BUFFER - default 1 if ESP_WIFI_REMOTE_DYNAMIC_TX_BUFFER - - config ESP_WIFI_REMOTE_STATIC_TX_BUFFER_NUM - int "Max number of WiFi static TX buffers" - depends on ESP_WIFI_REMOTE_STATIC_TX_BUFFER - range 0 64 - default 0 - - choice ESP_WIFI_REMOTE_MGMT_RX_BUFFER - prompt "Type of WiFi RX MGMT buffers" - default ESP_WIFI_REMOTE_STATIC_RX_MGMT_BUFFER - - config ESP_WIFI_REMOTE_STATIC_RX_MGMT_BUFFER - bool "Static" - config ESP_WIFI_REMOTE_DYNAMIC_RX_MGMT_BUFFER - bool "Dynamic" - endchoice - - config ESP_WIFI_REMOTE_DYNAMIC_RX_MGMT_BUF - int - default 0 if ESP_WIFI_REMOTE_STATIC_RX_MGMT_BUFFER - default 1 if ESP_WIFI_REMOTE_DYNAMIC_RX_MGMT_BUFFER - - config ESP_WIFI_REMOTE_RX_MGMT_BUF_NUM_DEF - int "Max number of WiFi RX MGMT buffers" - range 0 10 - default 0 - - config ESP_WIFI_REMOTE_CSI_ENABLED - bool "WiFi CSI(Channel State Information)" - depends on SOC_WIFI_REMOTE_CSI_SUPPORT - default n - - config ESP_WIFI_REMOTE_AMPDU_TX_ENABLED - bool "WiFi AMPDU TX" - default y - - config ESP_WIFI_REMOTE_TX_BA_WIN - int "WiFi AMPDU TX BA window size" - depends on ESP_WIFI_REMOTE_AMPDU_TX_ENABLED - range 0 64 if SOC_WIFI_REMOTE_HE_SUPPORT - default 0 - - config ESP_WIFI_REMOTE_AMPDU_RX_ENABLED - bool "WiFi AMPDU RX" - default y - - config ESP_REMOTE_WIFI_RX_BA_WIN - int "WiFi AMPDU RX BA window size" - depends on ESP_WIFI_REMOTE_AMPDU_RX_ENABLED - range 0 64 - default 0 - - config ESP_WIFI_REMOTE_ESPNOW_MAX_ENCRYPT_NUM - int "Maximum espnow encrypt peers number" - range 0 17 - default 0 - - if !ESP_WIFI_ENABLED + orsource "./Kconfig.soc_wifi_caps.in" config ESP_WIFI_STATIC_RX_BUFFER_NUM - int - default ESP_WIFI_REMOTE_STATIC_RX_BUFFER_NUM + int "Max number of WiFi static RX buffers" + range 2 25 if !SLAVE_SOC_WIFI_HE_SUPPORT + range 2 128 if SLAVE_SOC_WIFI_HE_SUPPORT + default 10 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + help + Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM. + The static rx buffers are allocated when esp_wifi_init is called, they are not freed + until esp_wifi_deinit is called. + + WiFi hardware use these buffers to receive all 802.11 frames. + A higher number may allow higher throughput but increases memory use. If ESP_WIFI_AMPDU_RX_ENABLED + is enabled, this value is recommended to set equal or bigger than ESP_WIFI_RX_BA_WIN in order to + achieve better throughput and compatibility with both stations and APs. config ESP_WIFI_DYNAMIC_RX_BUFFER_NUM - int - default ESP_WIFI_REMOTE_DYNAMIC_RX_BUFFER_NUM + int "Max number of WiFi dynamic RX buffers" + range 0 128 if !LWIP_WND_SCALE + range 0 1024 if LWIP_WND_SCALE + default 32 + help + Set the number of WiFi dynamic RX buffers, 0 means unlimited RX buffers will be allocated + (provided sufficient free RAM). The size of each dynamic RX buffer depends on the size of + the received data frame. + + For each received data frame, the WiFi driver makes a copy to an RX buffer and then delivers + it to the high layer TCP/IP stack. The dynamic RX buffer is freed after the higher layer has + successfully received the data frame. + + For some applications, WiFi data frames may be received faster than the application can + process them. In these cases we may run out of memory if RX buffer number is unlimited (0). + + If a dynamic RX buffer limit is set, it should be at least the number of static RX buffers. + + choice ESP_WIFI_TX_BUFFER + prompt "Type of WiFi TX buffers" + default ESP_WIFI_DYNAMIC_TX_BUFFER + help + Select type of WiFi TX buffers: + + If "Static" is selected, WiFi TX buffers are allocated when WiFi is initialized and released + when WiFi is de-initialized. The size of each static TX buffer is fixed to about 1.6KB. + + If "Dynamic" is selected, each WiFi TX buffer is allocated as needed when a data frame is + delivered to the Wifi driver from the TCP/IP stack. The buffer is freed after the data frame + has been sent by the WiFi driver. The size of each dynamic TX buffer depends on the length + of each data frame sent by the TCP/IP layer. + + If PSRAM is enabled, "Static" should be selected to guarantee enough WiFi TX buffers. + If PSRAM is disabled, "Dynamic" should be selected to improve the utilization of RAM. + + config ESP_WIFI_STATIC_TX_BUFFER + bool "Static" + config ESP_WIFI_DYNAMIC_TX_BUFFER + bool "Dynamic" + depends on !SPIRAM_USE_MALLOC + endchoice config ESP_WIFI_TX_BUFFER_TYPE int - default ESP_WIFI_REMOTE_TX_BUFFER_TYPE + default 0 if ESP_WIFI_STATIC_TX_BUFFER + default 1 if ESP_WIFI_DYNAMIC_TX_BUFFER config ESP_WIFI_STATIC_TX_BUFFER_NUM - int - depends on ESP_WIFI_REMOTE_STATIC_TX_BUFFER - default ESP_WIFI_REMOTE_STATIC_TX_BUFFER_NUM + int "Max number of WiFi static TX buffers" + depends on ESP_WIFI_STATIC_TX_BUFFER + range 1 64 + default 16 + help + Set the number of WiFi static TX buffers. Each buffer takes approximately 1.6KB of RAM. + The static RX buffers are allocated when esp_wifi_init() is called, they are not released + until esp_wifi_deinit() is called. + + For each transmitted data frame from the higher layer TCP/IP stack, the WiFi driver makes a + copy of it in a TX buffer. For some applications especially UDP applications, the upper + layer can deliver frames faster than WiFi layer can transmit. In these cases, we may run out + of TX buffers. + + config ESP_WIFI_CACHE_TX_BUFFER_NUM + int "Max number of WiFi cache TX buffers" + depends on SPIRAM + range 16 128 + default 32 + help + Set the number of WiFi cache TX buffer number. + + For each TX packet from uplayer, such as LWIP etc, WiFi driver needs to allocate a static TX + buffer and makes a copy of uplayer packet. If WiFi driver fails to allocate the static TX buffer, + it caches the uplayer packets to a dedicated buffer queue, this option is used to configure the + size of the cached TX queue. + + config ESP_WIFI_DYNAMIC_TX_BUFFER_NUM + int "Max number of WiFi dynamic TX buffers" + depends on ESP_WIFI_DYNAMIC_TX_BUFFER + range 1 128 + default 32 + help + Set the number of WiFi dynamic TX buffers. The size of each dynamic TX buffer is not fixed, + it depends on the size of each transmitted data frame. + + For each transmitted frame from the higher layer TCP/IP stack, the WiFi driver makes a copy + of it in a TX buffer. For some applications, especially UDP applications, the upper layer + can deliver frames faster than WiFi layer can transmit. In these cases, we may run out of TX + buffers. + + choice ESP_WIFI_MGMT_RX_BUFFER + prompt "Type of WiFi RX MGMT buffers" + default ESP_WIFI_STATIC_RX_MGMT_BUFFER + help + Select type of WiFi RX MGMT buffers: + + If "Static" is selected, WiFi RX MGMT buffers are allocated when WiFi is initialized and released + when WiFi is de-initialized. The size of each static RX MGMT buffer is fixed to about 500 Bytes. + + If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated as needed when a MGMT data frame is + received. The MGMT buffer is freed after the MGMT data frame has been processed by the WiFi driver. + + + config ESP_WIFI_STATIC_RX_MGMT_BUFFER + bool "Static" + config ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER + bool "Dynamic" + endchoice config ESP_WIFI_DYNAMIC_RX_MGMT_BUF int - default ESP_WIFI_REMOTE_DYNAMIC_RX_MGMT_BUF + default 0 if ESP_WIFI_STATIC_RX_MGMT_BUFFER + default 1 if ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER config ESP_WIFI_RX_MGMT_BUF_NUM_DEF - int - default ESP_WIFI_REMOTE_RX_MGMT_BUF_NUM_DEF + int "Max number of WiFi RX MGMT buffers" + range 1 10 + default 5 + help + Set the number of WiFi RX_MGMT buffers. + + For Management buffers, the number of dynamic and static management buffers is the same. + In order to prevent memory fragmentation, the management buffer type should be set to static first. config ESP_WIFI_CSI_ENABLED - bool - default ESP_WIFI_REMOTE_CSI_ENABLED + bool "WiFi CSI(Channel State Information)" + depends on SLAVE_SOC_WIFI_CSI_SUPPORT + default n + help + Select this option to enable CSI(Channel State Information) feature. CSI takes about + CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM KB of RAM. If CSI is not used, it is better to disable + this feature in order to save memory. config ESP_WIFI_AMPDU_TX_ENABLED - bool - default ESP_WIFI_REMOTE_AMPDU_TX_ENABLED + bool "WiFi AMPDU TX" + default y + help + Select this option to enable AMPDU TX feature + config ESP_WIFI_TX_BA_WIN - int - default ESP_WIFI_REMOTE_TX_BA_WIN + int "WiFi AMPDU TX BA window size" + depends on ESP_WIFI_AMPDU_TX_ENABLED + range 2 32 if !SLAVE_SOC_WIFI_HE_SUPPORT + range 2 64 if SLAVE_SOC_WIFI_HE_SUPPORT + default 6 + help + Set the size of WiFi Block Ack TX window. Generally a bigger value means higher throughput but + more memory. Most of time we should NOT change the default value unless special reason, e.g. + test the maximum UDP TX throughput with iperf etc. For iperf test in shieldbox, the recommended + value is 9~12. config ESP_WIFI_AMPDU_RX_ENABLED - bool - default ESP_WIFI_REMOTE_AMPDU_RX_ENABLED + bool "WiFi AMPDU RX" + default y + help + Select this option to enable AMPDU RX feature config ESP_WIFI_RX_BA_WIN - int - default ESP_REMOTE_WIFI_RX_BA_WIN + int "WiFi AMPDU RX BA window size" + depends on ESP_WIFI_AMPDU_RX_ENABLED + range 2 32 if !SLAVE_SOC_WIFI_HE_SUPPORT + range 2 64 if SLAVE_SOC_WIFI_HE_SUPPORT + default 6 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + help + Set the size of WiFi Block Ack RX window. Generally a bigger value means higher throughput and better + compatibility but more memory. Most of time we should NOT change the default value unless special + reason, e.g. test the maximum UDP RX throughput with iperf etc. For iperf test in shieldbox, the + recommended value is 9~12. If PSRAM is used and WiFi memory is prefered to allocat in PSRAM first, + the default and minimum value should be 16 to achieve better throughput and compatibility with both + stations and APs. + + config ESP_WIFI_AMSDU_TX_ENABLED + bool "WiFi AMSDU TX" + depends on SPIRAM + default n + help + Select this option to enable AMSDU TX feature + + config ESP_WIFI_NVS_ENABLED + bool "WiFi NVS flash" + default y + help + Select this option to enable WiFi NVS flash + + choice ESP_WIFI_TASK_CORE_ID + depends on !FREERTOS_UNICORE + prompt "WiFi Task Core ID" + default ESP_WIFI_TASK_PINNED_TO_CORE_0 + help + Pinned WiFi task to core 0 or core 1. + + config ESP_WIFI_TASK_PINNED_TO_CORE_0 + bool "Core 0" + config ESP_WIFI_TASK_PINNED_TO_CORE_1 + bool "Core 1" + endchoice + + config ESP_WIFI_SOFTAP_BEACON_MAX_LEN + int "Max length of WiFi SoftAP Beacon" + range 752 1256 + default 752 + help + ESP-MESH utilizes beacon frames to detect and resolve root node conflicts (see documentation). However + the default length of a beacon frame can simultaneously hold only five root node identifier structures, + meaning that a root node conflict of up to five nodes can be detected at one time. In the occurence of + more root nodes conflict involving more than five root nodes, the conflict resolution process will + detect five of the root nodes, resolve the conflict, and re-detect more root nodes. This process will + repeat until all root node conflicts are resolved. However this process can generally take a very long + time. + + To counter this situation, the beacon frame length can be increased such that more root nodes can be + detected simultaneously. Each additional root node will require 36 bytes and should be added ontop of + the default beacon frame length of + 752 bytes. For example, if you want to detect 10 root nodes simultaneously, you need to set the beacon + frame length as + 932 (752+36*5). + + Setting a longer beacon length also assists with debugging as the conflicting root nodes can be + identified more quickly. + + config ESP_WIFI_MGMT_SBUF_NUM + int "WiFi mgmt short buffer number" + range 6 32 + default 32 + help + Set the number of WiFi management short buffer. + + config ESP_WIFI_IRAM_OPT + bool "WiFi IRAM speed optimization" + default n if (BT_ENABLED && SPIRAM && SLAVE_IDF_TARGET_ESP32) + default y + help + Select this option to place frequently called Wi-Fi library functions in IRAM. + When this option is disabled, more than 10Kbytes of IRAM memory will be saved + but Wi-Fi throughput will be reduced. + + config ESP_WIFI_EXTRA_IRAM_OPT + bool "WiFi EXTRA IRAM speed optimization" + default y if SLAVE_IDF_TARGET_ESP32C6 + default n + help + Select this option to place additional frequently called Wi-Fi library functions + in IRAM. When this option is disabled, more than 5Kbytes of IRAM memory will be saved + but Wi-Fi throughput will be reduced. + + config ESP_WIFI_RX_IRAM_OPT + bool "WiFi RX IRAM speed optimization" + default n if (BT_ENABLED && SPIRAM && SLAVE_IDF_TARGET_ESP32) + default y + help + Select this option to place frequently called Wi-Fi library RX functions in IRAM. + When this option is disabled, more than 17Kbytes of IRAM memory will be saved + but Wi-Fi performance will be reduced. + + config ESP_WIFI_ENABLE_WPA3_SAE + bool "Enable WPA3-Personal" + default y + select ESP_WIFI_MBEDTLS_CRYPTO + help + Select this option to allow the device to establish a WPA3-Personal connection with eligible AP's. + PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be + explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide + for details. + + config ESP_WIFI_ENABLE_SAE_PK + bool "Enable SAE-PK" + default y + depends on ESP_WIFI_ENABLE_WPA3_SAE + help + Select this option to enable SAE-PK + + config ESP_WIFI_SOFTAP_SAE_SUPPORT + bool "Enable WPA3 Personal(SAE) SoftAP" + default y + depends on ESP_WIFI_ENABLE_WPA3_SAE + depends on ESP_WIFI_SOFTAP_SUPPORT + help + Select this option to enable SAE support in softAP mode. + + config ESP_WIFI_ENABLE_WPA3_OWE_STA + bool "Enable OWE STA" + default y + select ESP_WIFI_MBEDTLS_CRYPTO + help + Select this option to allow the device to establish OWE connection with eligible AP's. + PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be + explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide + for details. + + config ESP_WIFI_SLP_IRAM_OPT + bool "WiFi SLP IRAM speed optimization" + select PM_SLP_DEFAULT_PARAMS_OPT + select PERIPH_CTRL_FUNC_IN_IRAM + help + Select this option to place called Wi-Fi library TBTT process and receive beacon functions in IRAM. + Some functions can be put in IRAM either by ESP_WIFI_IRAM_OPT and ESP_WIFI_RX_IRAM_OPT, or this one. + If already enabled ESP_WIFI_IRAM_OPT, the other 7.3KB IRAM memory would be taken by this option. + If already enabled ESP_WIFI_RX_IRAM_OPT, the other 1.3KB IRAM memory would be taken by this option. + If neither of them are enabled, the other 7.4KB IRAM memory would be taken by this option. + Wi-Fi power-save mode average current would be reduced if this option is enabled. + + config ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME + int "Minimum active time" + range 8 60 + default 50 + depends on ESP_WIFI_SLP_IRAM_OPT + help + The minimum timeout for waiting to receive data, unit: milliseconds. + + config ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME + int "Maximum keep alive time" + range 10 60 + default 10 + depends on ESP_WIFI_SLP_IRAM_OPT + help + The maximum time that wifi keep alive, unit: seconds. + + config ESP_WIFI_FTM_ENABLE + bool "WiFi FTM" + default n + depends on SLAVE_SOC_WIFI_FTM_SUPPORT + help + Enable feature Fine Timing Measurement for calculating WiFi Round-Trip-Time (RTT). + + config ESP_WIFI_FTM_INITIATOR_SUPPORT + bool "FTM Initiator support" + default y + depends on ESP_WIFI_FTM_ENABLE + + config ESP_WIFI_FTM_RESPONDER_SUPPORT + bool "FTM Responder support" + default y + depends on ESP_WIFI_FTM_ENABLE + + config ESP_WIFI_STA_DISCONNECTED_PM_ENABLE + bool "Power Management for station at disconnected" + default y + help + Select this option to enable power_management for station when disconnected. + Chip will do modem-sleep when rf module is not in use any more. + + config ESP_WIFI_GCMP_SUPPORT + bool "WiFi GCMP Support(GCMP128 and GCMP256)" + default n + depends on SLAVE_SOC_WIFI_GCMP_SUPPORT + help + Select this option to enable GCMP support. GCMP support is compulsory for WiFi Suite-B support. + + config ESP_WIFI_GMAC_SUPPORT + bool "WiFi GMAC Support(GMAC128 and GMAC256)" + default n + help + Select this option to enable GMAC support. GMAC support is compulsory for WiFi 192 bit certification. + + config ESP_WIFI_SOFTAP_SUPPORT + bool "WiFi SoftAP Support" + default y + help + WiFi module can be compiled without SoftAP to save code size. + + config ESP_WIFI_ENHANCED_LIGHT_SLEEP + bool "WiFi modem automatically receives the beacon" + default n + depends on ESP_PHY_MAC_BB_PD && SOC_PM_SUPPORT_BEACON_WAKEUP + help + The wifi modem automatically receives the beacon frame during light sleep. + + config ESP_WIFI_SLP_BEACON_LOST_OPT + bool "Wifi sleep optimize when beacon lost" + help + Enable wifi sleep optimization when beacon loss occurs and immediately enter + sleep mode when the WiFi module detects beacon loss. + + config ESP_WIFI_SLP_BEACON_LOST_TIMEOUT + int "Beacon loss timeout" + range 5 100 + default 10 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT + help + Timeout time for close rf phy when beacon loss occurs, Unit: 1024 microsecond. + + config ESP_WIFI_SLP_BEACON_LOST_THRESHOLD + int "Maximum number of consecutive lost beacons allowed" + range 0 8 + default 3 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT + help + Maximum number of consecutive lost beacons allowed, WiFi keeps Rx state when + the number of consecutive beacons lost is greater than the given threshold. + + config ESP_WIFI_SLP_PHY_ON_DELTA_EARLY_TIME + int "Delta early time for RF PHY on" + range 0 100 + default 2 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + help + Delta early time for rf phy on, When the beacon is lost, the next rf phy on will + be earlier the time specified by the configuration item, Unit: 32 microsecond. + + config ESP_WIFI_SLP_PHY_OFF_DELTA_TIMEOUT_TIME + int "Delta timeout time for RF PHY off" + range 0 8 + default 2 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + help + Delta timeout time for rf phy off, When the beacon is lost, the next rf phy off will + be delayed for the time specified by the configuration item. Unit: 1024 microsecond. config ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM - int - default ESP_WIFI_REMOTE_ESPNOW_MAX_ENCRYPT_NUM - - endif #!ESP_WIFI_ENABLED - - -endmenu # Wi-Fi remote + int "Maximum espnow encrypt peers number" + range 0 4 if SLAVE_IDF_TARGET_ESP32C2 + range 0 17 if (!SLAVE_IDF_TARGET_ESP32C2) + default 2 if SLAVE_IDF_TARGET_ESP32C2 + default 7 if (!SLAVE_IDF_TARGET_ESP32C2) + help + Maximum number of encrypted peers supported by espnow. + The number of hardware keys for encryption is fixed. And the espnow and SoftAP share the same + hardware keys. So this configuration will affect the maximum connection number of SoftAP. + Maximum espnow encrypted peers number + maximum number of connections of SoftAP = Max hardware + keys number. When using ESP mesh, this value should be set to a maximum of 6. + + config ESP_WIFI_NAN_ENABLE + bool "WiFi Aware" + default n + depends on SLAVE_SOC_WIFI_NAN_SUPPORT + help + Enable WiFi Aware (NAN) feature. + + config ESP_WIFI_ENABLE_WIFI_TX_STATS + bool "Enable Wi-Fi transmission statistics" + depends on SLAVE_SOC_WIFI_HE_SUPPORT + default "y" + help + Enable Wi-Fi transmission statistics. Total support 4 access category. Each access category + will use 346 bytes memory. + + config ESP_WIFI_MBEDTLS_CRYPTO + bool "Use MbedTLS crypto APIs" + default y + select MBEDTLS_AES_C + select MBEDTLS_ECP_C + select MBEDTLS_ECDH_C + select MBEDTLS_ECDSA_C + select MBEDTLS_CMAC_C + select MBEDTLS_ECP_DP_SECP256R1_ENABLED + help + Select this option to enable the use of MbedTLS crypto APIs. + The internal crypto support within the supplicant is limited + and may not suffice for all new security features, including WPA3. + + It is recommended to always keep this option enabled. Additionally, + note that MbedTLS can leverage hardware acceleration if available, + resulting in significantly faster cryptographic operations. + + if ESP_WIFI_MBEDTLS_CRYPTO + config ESP_WIFI_MBEDTLS_TLS_CLIENT + bool "Use MbedTLS TLS client for WiFi Enterprise connection" + depends on ESP_WIFI_ENTERPRISE_SUPPORT + default y + select MBEDTLS_TLS_ENABLED + help + Select this option to use MbedTLS TLS client for WPA2 enterprise connection. + Please note that from MbedTLS-3.0 onwards, MbedTLS does not support SSL-3.0 + TLS-v1.0, TLS-v1.1 versions. Incase your server is using one of these version, + it is advisable to update your server. + Please disable this option for compatibilty with older TLS versions. + + config ESP_WIFI_EAP_TLS1_3 + bool "Enable EAP-TLS v1.3 Support for WiFi Enterprise connection" + default n + select MBEDTLS_SSL_PROTO_TLS1_3 + depends on ESP_WIFI_MBEDTLS_TLS_CLIENT && IDF_EXPERIMENTAL_FEATURES + help + Select this option to support EAP with TLS v1.3. + This configuration still supports compatibility with EAP-TLS v1.2. + Please note that enabling this configuration will cause every application which + uses TLS go for TLS1.3 if server supports that. TLS1.3 is still in development in mbedtls + and there may be interoperability issues with this. Please modify your application to set + max version as TLS1.2 if you want to enable TLS1.3 only for WiFi connection. + + endif + + config ESP_WIFI_WAPI_PSK + bool "Enable WAPI PSK support" + depends on SLAVE_SOC_WIFI_WAPI_SUPPORT + default n + help + Select this option to enable WAPI-PSK + which is a Chinese National Standard Encryption for Wireless LANs (GB 15629.11-2003). + + config ESP_WIFI_SUITE_B_192 + bool "Enable NSA suite B support with 192 bit key" + default n + depends on SLAVE_SOC_WIFI_GCMP_SUPPORT + select ESP_WIFI_GCMP_SUPPORT + select ESP_WIFI_GMAC_SUPPORT + help + Select this option to enable 192 bit NSA suite-B. + This is necessary to support WPA3 192 bit security. + + config ESP_WIFI_11KV_SUPPORT + bool "Enable 802.11k, 802.11v APIs Support" + default n + help + Select this option to enable 802.11k 802.11v APIs(RRM and BTM support). + Only APIs which are helpful for network assisted roaming + are supported for now. + Enable this option with BTM and RRM enabled in sta config + to make device ready for network assisted roaming. + BTM: BSS transition management enables an AP to request a station to transition + to a specific AP, or to indicate to a station a set of preferred APs. + RRM: Radio measurements enable STAs to understand the radio environment, + it enables STAs to observe and gather data on radio link performance + and on the radio environment. Current implementation adds beacon report, + link measurement, neighbor report. + + config ESP_WIFI_SCAN_CACHE + bool "Keep scan results in cache" + depends on ESP_WIFI_11KV_SUPPORT + default n + help + Keep scan results in cache, if not enabled, those + will be flushed immediately. + + config ESP_WIFI_MBO_SUPPORT + bool "Enable Multi Band Operation Certification Support" + default n + select ESP_WIFI_11KV_SUPPORT + select ESP_WIFI_SCAN_CACHE + help + Select this option to enable WiFi Multiband operation certification support. + + config ESP_WIFI_DPP_SUPPORT + bool "Enable DPP support" + default n + select ESP_WIFI_MBEDTLS_CRYPTO + help + Select this option to enable WiFi Easy Connect Support. + + config ESP_WIFI_11R_SUPPORT + bool "Enable 802.11R (Fast Transition) Support" + default n + help + Select this option to enable WiFi Fast Transition Support. + + config ESP_WIFI_WPS_SOFTAP_REGISTRAR + bool "Add WPS Registrar support in SoftAP mode" + depends on ESP_WIFI_SOFTAP_SUPPORT + default n + help + Select this option to enable WPS registrar support in softAP mode. + + config ESP_WIFI_ENABLE_WIFI_RX_STATS + bool "Enable Wi-Fi reception statistics" + depends on SLAVE_SOC_WIFI_HE_SUPPORT + default "y" + help + Enable Wi-Fi reception statistics. Total support 2 access category. Each access category + will use 190 bytes memory. + + config ESP_WIFI_ENABLE_WIFI_RX_MU_STATS + bool "Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics" + depends on ESP_WIFI_ENABLE_WIFI_RX_STATS + default "y" + help + Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics. Will use 10932 bytes memory. + + menu "WPS Configuration Options" + config ESP_WIFI_WPS_STRICT + bool "Strictly validate all WPS attributes" + default n + help + Select this option to enable validate each WPS attribute + rigorously. Disabling this add the workaorunds with various APs. + Enabling this may cause inter operability issues with some APs. + + config ESP_WIFI_WPS_PASSPHRASE + bool "Get WPA2 passphrase in WPS config" + default n + help + Select this option to get passphrase during WPS configuration. + This option fakes the virtual display capabilites to get the + configuration in passphrase mode. + Not recommanded to be used since WPS credentials should not + be shared to other devices, making it in readable format increases + that risk, also passphrase requires pbkdf2 to convert in psk. + + endmenu # "WPS Configuration Options" + + + config ESP_WIFI_DEBUG_PRINT + bool "Print debug messages from WPA Supplicant" + default n + help + Select this option to print logging information from WPA supplicant, + this includes handshake information and key hex dumps depending + on the project logging level. + + Enabling this could increase the build size ~60kb + depending on the project logging level. + + config ESP_WIFI_TESTING_OPTIONS + bool "Add DPP testing code" + default n + help + Select this to enable unity test for DPP. + + config ESP_WIFI_ENTERPRISE_SUPPORT + bool "Enable enterprise option" + default y + help + Select this to enable/disable enterprise connection support. + + disabling this will reduce binary size. + disabling this will disable the use of any esp_wifi_sta_wpa2_ent_* (as APIs will be meaningless) + + Note that when using bigger certificates on low-power chips without crypto + hardware acceleration, it is recommended to adjust the task watchdog timer (TWDT) + if it is enabled. For precise information on timing requirements, you can check + performance numbers at https://github.com/espressif/mbedtls/wiki/Performance-Numbers. + + config ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER + bool "Free dynamic buffers during WiFi enterprise connection" + depends on ESP_WIFI_ENTERPRISE_SUPPORT + default y if SLAVE_IDF_TARGET_ESP32C2 + default n if !SLAVE_IDF_TARGET_ESP32C2 + help + Select this configuration to free dynamic buffers during WiFi enterprise connection. + This will enable chip to reduce heap consumption during WiFi enterprise connection. + +endmenu # Wi-Fi Remote diff --git a/components/esp_wifi_remote/Kconfig.soc_wifi_caps.in b/components/esp_wifi_remote/Kconfig.soc_wifi_caps.in new file mode 100644 index 0000000000..a0aee080a2 --- /dev/null +++ b/components/esp_wifi_remote/Kconfig.soc_wifi_caps.in @@ -0,0 +1,229 @@ +# This file is auto-generated + +if SLAVE_IDF_TARGET_ESP32 + + config SLAVE_SOC_WIFI_SUPPORTED + bool + default y + + config SLAVE_SOC_WIFI_WAPI_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_CSI_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_MESH_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + bool + default y + + config SLAVE_SOC_WIFI_NAN_SUPPORT + bool + default y + +endif # ESP32 + +if SLAVE_IDF_TARGET_ESP32S2 + + config SLAVE_SOC_WIFI_SUPPORTED + bool + default y + + config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH + int + default 12 + + config SLAVE_SOC_WIFI_HW_TSF + bool + default y + + config SLAVE_SOC_WIFI_FTM_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_WAPI_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_CSI_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_MESH_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + bool + default y + + config SLAVE_SOC_WIFI_NAN_SUPPORT + bool + default y + +endif # ESP32S2 + +if SLAVE_IDF_TARGET_ESP32C3 + + config SLAVE_SOC_WIFI_SUPPORTED + bool + default y + + config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH + int + default 12 + + config SLAVE_SOC_WIFI_HW_TSF + bool + default y + + config SLAVE_SOC_WIFI_FTM_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_GCMP_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_WAPI_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_CSI_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_MESH_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + bool + default y + + config SLAVE_SOC_WIFI_PHY_NEEDS_USB_WORKAROUND + bool + default y + +endif # ESP32C3 + +if SLAVE_IDF_TARGET_ESP32S3 + + config SLAVE_SOC_WIFI_SUPPORTED + bool + default y + + config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH + int + default 12 + + config SLAVE_SOC_WIFI_HW_TSF + bool + default y + + config SLAVE_SOC_WIFI_FTM_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_GCMP_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_WAPI_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_CSI_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_MESH_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + bool + default y + + config SLAVE_SOC_WIFI_PHY_NEEDS_USB_WORKAROUND + bool + default y + +endif # ESP32S3 + +if SLAVE_IDF_TARGET_ESP32C2 + + config SLAVE_SOC_WIFI_SUPPORTED + bool + default y + + config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH + int + default 12 + + config SLAVE_SOC_WIFI_HW_TSF + bool + default y + + config SLAVE_SOC_WIFI_FTM_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + bool + default y + + config SLAVE_SOC_WIFI_PHY_NEEDS_USB_WORKAROUND + bool + default y + +endif # ESP32C2 + +if SLAVE_IDF_TARGET_ESP32C6 + + config SLAVE_SOC_WIFI_SUPPORTED + bool + default y + + config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH + int + default 12 + + config SLAVE_SOC_WIFI_HW_TSF + bool + default y + + config SLAVE_SOC_WIFI_FTM_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_GCMP_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_WAPI_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_CSI_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_MESH_SUPPORT + bool + default y + + config SLAVE_SOC_WIFI_HE_SUPPORT + bool + default y + +endif # ESP32C6 + +if SLAVE_IDF_TARGET_ESP32H2 + +endif # ESP32H2 diff --git a/components/esp_wifi_remote/README.md b/components/esp_wifi_remote/README.md new file mode 100644 index 0000000000..f15c9dbeeb --- /dev/null +++ b/components/esp_wifi_remote/README.md @@ -0,0 +1,26 @@ +# esp_wifi_remote + +[![Component Registry](https://components.espressif.com/components/espressif/esp_wifi_remote/badge.svg)](https://components.espressif.com/components/espressif/esp_wifi_remote) + +The `esp_wifi_remote` component is designed to extend WiFi functionality to ESP chipsets that lack native WiFi support. By simply adding a dependency to this component from your project, you gain access to WiFi capabilities via the WiFi-remote menuconfig and standard `esp_wifi` interface. + +Moreover, `esp_wifi_remote` can be utilized on ESP chipsets that do support native WiFi, providing an additional WiFi interface through the `esp_wifi_remote` API. + +To employ this component, a slave device -- capable of WiFi connectivity -- must be connected to your target device in a specified manner, as defined by the transport layer of [`esp_hosted`](https://github.com/espressif/esp-hosted). + +Functionally, `esp_wifi_remote` wraps the public API of `esp_wifi`, offering a set of function call namespaces prefixed with esp_wifi_remote. These calls are translated into Remote Procedure Calls (RPC) to another target device (referred to as the "slave" device), which then executes the appropriate `esp_wifi` APIs. + +Notably, `esp_wifi_remote` heavily relies on a specific version of the `esp_wifi` component. Consequently, the majority of its headers, sources, and configuration files are pre-generated based on the actual version of `esp_wifi`. + +It's important to highlight that `esp_wifi_remote` does not directly implement the RPC calls; rather, it relies on dependencies for this functionality. Presently, only esp_hosted is supported to provide the RPC functionality required by esp_wifi_remote. + + +## Dependencies on `esp_wifi` + +Public API needs to correspond exactly to the `esp_wifi` API. Some of the internal types depend on the actual wifi target, as well as some default configuration values. Therefore it's easier to maintain consistency between this component and the exact version of `esp_wifi` automatically in CI: + +* We extract function prototypes from `esp_wifi.h` and use them to generate `esp_wifi_remote` function declarations. +* We process the local `esp_wifi_types_native.h` and replace `CONFIG_IDF_TARGET` to `CONFIG_SLAVE_IDF_TARGET` and `CONFIG_SOC_WIFI_...` to `CONFIG_SLAVE_....` +* Similarly we process `esp_wifi`'s Kconfig, so the dependencies are on the slave target and slave SOC capabilities. + +Please check the [README.md](./scripts/README.md) for more details on the generation step and testing consistency. diff --git a/components/esp_wifi_remote/esp_wifi_remote.c b/components/esp_wifi_remote/esp_wifi_remote.c index 7b9fb31510..adf9fe3856 100644 --- a/components/esp_wifi_remote/esp_wifi_remote.c +++ b/components/esp_wifi_remote/esp_wifi_remote.c @@ -12,10 +12,14 @@ WEAK ESP_EVENT_DEFINE_BASE(WIFI_EVENT); +#if !CONFIG_SOC_WIFI_SUPPORTED +struct wifi_osi_funcs_t { }; +#endif + WEAK wifi_osi_funcs_t g_wifi_osi_funcs; WEAK const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; WEAK uint64_t g_wifi_feature_caps = -#if CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE +#if CONFIG_ESP_WIFI_ENABLE_WPA3_SAE CONFIG_FEATURE_WPA3_SAE_BIT | #endif #if CONFIG_SPIRAM @@ -28,188 +32,3 @@ WEAK uint64_t g_wifi_feature_caps = CONFIG_FEATURE_FTM_RESPONDER_BIT | #endif 0; - -WEAK esp_err_t esp_wifi_connect(void) -{ - return remote_esp_wifi_connect(); -} - -WEAK esp_err_t esp_wifi_disconnect(void) -{ - return remote_esp_wifi_disconnect(); -} - -WEAK esp_err_t esp_wifi_init(const wifi_init_config_t *config) -{ - return remote_esp_wifi_init(config); -} - -WEAK esp_err_t esp_wifi_deinit(void) -{ - return remote_esp_wifi_deinit(); -} - -WEAK esp_err_t esp_wifi_set_mode(wifi_mode_t mode) -{ - return remote_esp_wifi_set_mode(mode); -} - -WEAK esp_err_t esp_wifi_get_mode(wifi_mode_t *mode) -{ - return remote_esp_wifi_get_mode(mode); -} - -WEAK esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) -{ - return remote_esp_wifi_set_config(interface, conf); -} - -WEAK esp_err_t esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf) -{ - return remote_esp_wifi_get_config(interface, conf); -} - -WEAK esp_err_t esp_wifi_start(void) -{ - return remote_esp_wifi_start(); -} - -WEAK esp_err_t esp_wifi_stop(void) -{ - return remote_esp_wifi_stop(); -} - -WEAK esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]) -{ - return remote_esp_wifi_get_mac(ifx, mac); -} - -WEAK esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6]) -{ - return remote_esp_wifi_set_mac(ifx, mac); -} - -WEAK esp_err_t esp_wifi_scan_start(const wifi_scan_config_t *config, bool block) -{ - return remote_esp_wifi_scan_start(config, block); -} - -WEAK esp_err_t esp_wifi_scan_stop(void) -{ - return remote_esp_wifi_scan_stop(); -} - -WEAK esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number) -{ - return remote_esp_wifi_scan_get_ap_num(number); -} - -WEAK esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records) -{ - return remote_esp_wifi_scan_get_ap_records(number, ap_records); -} - -WEAK esp_err_t esp_wifi_clear_ap_list(void) -{ - return remote_esp_wifi_clear_ap_list(); -} - -WEAK esp_err_t esp_wifi_restore(void) -{ - return remote_esp_wifi_restore(); -} - -WEAK esp_err_t esp_wifi_clear_fast_connect(void) -{ - return remote_esp_wifi_clear_fast_connect(); -} - -WEAK esp_err_t esp_wifi_deauth_sta(uint16_t aid) -{ - return remote_esp_wifi_deauth_sta(aid); -} - -WEAK esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info) -{ - return remote_esp_wifi_sta_get_ap_info(ap_info); -} - -WEAK esp_err_t esp_wifi_set_ps(wifi_ps_type_t type) -{ - return remote_esp_wifi_set_ps(type); -} - -WEAK esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type) -{ - return remote_esp_wifi_get_ps(type); -} - -WEAK esp_err_t esp_wifi_set_storage(wifi_storage_t storage) -{ - return remote_esp_wifi_set_storage(storage); -} - -WEAK esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw) -{ - return remote_esp_wifi_set_bandwidth(ifx, bw); -} - -WEAK esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw) -{ - return remote_esp_wifi_get_bandwidth(ifx, bw); -} - -WEAK esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second) -{ - return remote_esp_wifi_set_channel(primary, second); -} - -WEAK esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second) -{ - return remote_esp_wifi_get_channel(primary, second); -} - -WEAK esp_err_t esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled) -{ - return remote_esp_wifi_set_country_code(country, ieee80211d_enabled); -} - -WEAK esp_err_t esp_wifi_get_country_code(char *country) -{ - return remote_esp_wifi_get_country_code(country); -} - -WEAK esp_err_t esp_wifi_set_country(const wifi_country_t *country) -{ - return remote_esp_wifi_set_country(country); -} - -WEAK esp_err_t esp_wifi_get_country(wifi_country_t *country) -{ - return remote_esp_wifi_get_country(country); -} - -WEAK esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta) -{ - return remote_esp_wifi_ap_get_sta_list(sta); -} - -WEAK esp_err_t esp_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid) -{ - return remote_esp_wifi_ap_get_sta_aid(mac, aid); -} - -WEAK esp_err_t esp_wifi_sta_get_rssi(int *rssi) -{ - return remote_esp_wifi_sta_get_rssi(rssi); -} - -WEAK esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap) -{ - return remote_esp_wifi_set_protocol(ifx, protocol_bitmap); -} - -WEAK esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap) -{ - return remote_esp_wifi_get_protocol(ifx, protocol_bitmap); -} diff --git a/components/esp_wifi_remote/wifi_remote_net.c b/components/esp_wifi_remote/esp_wifi_remote_net.c similarity index 57% rename from components/esp_wifi_remote/wifi_remote_net.c rename to components/esp_wifi_remote/esp_wifi_remote_net.c index 5bc3ec0cb0..65fab99336 100644 --- a/components/esp_wifi_remote/wifi_remote_net.c +++ b/components/esp_wifi_remote/esp_wifi_remote_net.c @@ -9,26 +9,25 @@ #include "esp_log.h" #define CHANNELS 2 +#define WEAK __attribute__((weak)) static esp_remote_channel_tx_fn_t s_tx_cb[CHANNELS]; static esp_remote_channel_t s_channel[CHANNELS]; static wifi_rxcb_t s_rx_fn[CHANNELS]; -esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, void *buff_to_free, size_t len) +WEAK esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, void *buff_to_free, size_t len) { assert(h); - if (h == s_channel[0]) { - assert(s_rx_fn[0]); + if (h == s_channel[0] && s_rx_fn[0]) { return s_rx_fn[0](buffer, len, buff_to_free); } - if (h == s_channel[1]) { - assert(s_rx_fn[1]); + if (h == s_channel[1] && s_rx_fn[1]) { return s_rx_fn[1](buffer, len, buff_to_free); } return ESP_FAIL; } -esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_remote_channel_tx_fn_t tx_cb) +WEAK esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_remote_channel_tx_fn_t tx_cb) { if (ifx == WIFI_IF_STA) { s_channel[0] = h; @@ -43,38 +42,38 @@ esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_remote_ return ESP_FAIL; } - -esp_err_t esp_wifi_internal_set_sta_ip(void) +WEAK esp_err_t esp_wifi_internal_set_sta_ip(void) { + // TODO: Pass this information to the slave target + // Note that this function is called from the default event loop, so we shouldn't block here return ESP_OK; } -esp_err_t esp_wifi_internal_reg_netstack_buf_cb(wifi_netstack_buf_ref_cb_t ref, wifi_netstack_buf_free_cb_t free) +WEAK esp_err_t esp_wifi_internal_reg_netstack_buf_cb(wifi_netstack_buf_ref_cb_t ref, wifi_netstack_buf_free_cb_t free) { return ESP_OK; } -void esp_wifi_internal_free_rx_buffer(void *buffer) +WEAK void esp_wifi_internal_free_rx_buffer(void *buffer) { - if (buffer) { - free(buffer); - } + free(buffer); } -int esp_wifi_internal_tx(wifi_interface_t ifx, void *buffer, uint16_t len) +WEAK int esp_wifi_internal_tx(wifi_interface_t ifx, void *buffer, uint16_t len) { - if (ifx == WIFI_IF_STA) { + if (ifx == WIFI_IF_STA && s_tx_cb[0]) { + /* TODO: If not needed, remove arg3 */ return s_tx_cb[0](s_channel[0], buffer, len); } - if (ifx == WIFI_IF_AP) { + if (ifx == WIFI_IF_AP && s_tx_cb[1]) { return s_tx_cb[1](s_channel[1], buffer, len); } return -1; } -esp_err_t esp_wifi_internal_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn) +WEAK esp_err_t esp_wifi_internal_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn) { if (ifx == WIFI_IF_STA) { ESP_LOGI("esp_wifi_remote", "%s: sta: %p", __func__, fn); diff --git a/components/esp_wifi_remote/esp_wifi_remote_weak.c b/components/esp_wifi_remote/esp_wifi_remote_weak.c new file mode 100644 index 0000000000..3bee295c03 --- /dev/null +++ b/components/esp_wifi_remote/esp_wifi_remote_weak.c @@ -0,0 +1,397 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +// This file is auto-generated +#include "esp_wifi_remote.h" +#include "esp_log.h" + +#define WEAK __attribute__((weak)) +#define LOG_UNSUPPORTED_AND_RETURN(ret) ESP_LOGW("esp_wifi_remote_weak", "%s unsupported", __func__); \ + return ret; + +WEAK esp_err_t esp_wifi_remote_init(const wifi_init_config_t *config) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_deinit(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_mode(wifi_mode_t *mode) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_start(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_stop(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_restore(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_connect(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_disconnect(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_clear_fast_connect(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_deauth_sta(uint16_t aid) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_scan_start(const wifi_scan_config_t *config, _Bool block) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_scan_stop(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_scan_get_ap_num(uint16_t *number) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_scan_get_ap_record(wifi_ap_record_t *ap_record) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_clear_ap_list(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_sta_get_ap_info(wifi_ap_record_t *ap_info) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_ps(wifi_ps_type_t type) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_ps(wifi_ps_type_t *type) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_channel(uint8_t primary, wifi_second_chan_t second) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_channel(uint8_t *primary, wifi_second_chan_t *second) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_country(const wifi_country_t *country) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_country(wifi_country_t *country) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_mac(wifi_interface_t ifx, const uint8_t mac[6]) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_mac(wifi_interface_t ifx, uint8_t mac[6]) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_promiscuous(_Bool en) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_promiscuous(_Bool *en) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_promiscuous_filter(const wifi_promiscuous_filter_t *filter) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_promiscuous_filter(wifi_promiscuous_filter_t *filter) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *filter) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_config(wifi_interface_t interface, wifi_config_t *conf) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_config(wifi_interface_t interface, wifi_config_t *conf) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_ap_get_sta_list(wifi_sta_list_t *sta) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_vendor_ie(_Bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_max_tx_power(int8_t power) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_max_tx_power(int8_t *power) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_event_mask(uint32_t mask) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_event_mask(uint32_t *mask) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_80211_tx(wifi_interface_t ifx, const void *buffer, int len, _Bool en_sys_seq) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_csi_config(const wifi_csi_config_t *config) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_csi(_Bool en) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_ant_gpio(const wifi_ant_gpio_config_t *config) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_ant_gpio(wifi_ant_gpio_config_t *config) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_ant(const wifi_ant_config_t *config) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_ant(wifi_ant_config_t *config) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK int64_t esp_wifi_remote_get_tsf_time(wifi_interface_t interface) +{ + LOG_UNSUPPORTED_AND_RETURN(-1); +} + +WEAK esp_err_t esp_wifi_remote_set_inactive_time(wifi_interface_t ifx, uint16_t sec) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_inactive_time(wifi_interface_t ifx, uint16_t *sec) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_statis_dump(uint32_t modules) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_rssi_threshold(int32_t rssi) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_ftm_end_session(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_ftm_resp_set_offset(int16_t offset_cm) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_ftm_get_report(wifi_ftm_report_entry_t *report, uint8_t num_entries) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_config_11b_rate(wifi_interface_t ifx, _Bool disable) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_connectionless_module_set_wake_interval(uint16_t wake_interval) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_force_wakeup_acquire(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_force_wakeup_release(void) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_country_code(const char *country, _Bool ieee80211d_enabled) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_get_country_code(char *country) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_disable_pmf_config(wifi_interface_t ifx) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_sta_get_aid(uint16_t *aid) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_set_dynamic_cs(_Bool enabled) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} + +WEAK esp_err_t esp_wifi_remote_sta_get_rssi(int *rssi) +{ + LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED); +} diff --git a/components/esp_wifi_remote/esp_wifi_with_remote.c b/components/esp_wifi_remote/esp_wifi_with_remote.c new file mode 100644 index 0000000000..66b202fc93 --- /dev/null +++ b/components/esp_wifi_remote/esp_wifi_with_remote.c @@ -0,0 +1,393 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +// This file is auto-generated +#include "esp_wifi.h" +#include "esp_wifi_remote.h" + +esp_err_t esp_wifi_init(const wifi_init_config_t *config) +{ + return esp_wifi_remote_init(config); +} + +esp_err_t esp_wifi_deinit(void) +{ + return esp_wifi_remote_deinit(); +} + +esp_err_t esp_wifi_set_mode(wifi_mode_t mode) +{ + return esp_wifi_remote_set_mode(mode); +} + +esp_err_t esp_wifi_get_mode(wifi_mode_t *mode) +{ + return esp_wifi_remote_get_mode(mode); +} + +esp_err_t esp_wifi_start(void) +{ + return esp_wifi_remote_start(); +} + +esp_err_t esp_wifi_stop(void) +{ + return esp_wifi_remote_stop(); +} + +esp_err_t esp_wifi_restore(void) +{ + return esp_wifi_remote_restore(); +} + +esp_err_t esp_wifi_connect(void) +{ + return esp_wifi_remote_connect(); +} + +esp_err_t esp_wifi_disconnect(void) +{ + return esp_wifi_remote_disconnect(); +} + +esp_err_t esp_wifi_clear_fast_connect(void) +{ + return esp_wifi_remote_clear_fast_connect(); +} + +esp_err_t esp_wifi_deauth_sta(uint16_t aid) +{ + return esp_wifi_remote_deauth_sta(aid); +} + +esp_err_t esp_wifi_scan_start(const wifi_scan_config_t *config, _Bool block) +{ + return esp_wifi_remote_scan_start(config, block); +} + +esp_err_t esp_wifi_scan_stop(void) +{ + return esp_wifi_remote_scan_stop(); +} + +esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number) +{ + return esp_wifi_remote_scan_get_ap_num(number); +} + +esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records) +{ + return esp_wifi_remote_scan_get_ap_records(number, ap_records); +} + +esp_err_t esp_wifi_scan_get_ap_record(wifi_ap_record_t *ap_record) +{ + return esp_wifi_remote_scan_get_ap_record(ap_record); +} + +esp_err_t esp_wifi_clear_ap_list(void) +{ + return esp_wifi_remote_clear_ap_list(); +} + +esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info) +{ + return esp_wifi_remote_sta_get_ap_info(ap_info); +} + +esp_err_t esp_wifi_set_ps(wifi_ps_type_t type) +{ + return esp_wifi_remote_set_ps(type); +} + +esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type) +{ + return esp_wifi_remote_get_ps(type); +} + +esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap) +{ + return esp_wifi_remote_set_protocol(ifx, protocol_bitmap); +} + +esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap) +{ + return esp_wifi_remote_get_protocol(ifx, protocol_bitmap); +} + +esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw) +{ + return esp_wifi_remote_set_bandwidth(ifx, bw); +} + +esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw) +{ + return esp_wifi_remote_get_bandwidth(ifx, bw); +} + +esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second) +{ + return esp_wifi_remote_set_channel(primary, second); +} + +esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second) +{ + return esp_wifi_remote_get_channel(primary, second); +} + +esp_err_t esp_wifi_set_country(const wifi_country_t *country) +{ + return esp_wifi_remote_set_country(country); +} + +esp_err_t esp_wifi_get_country(wifi_country_t *country) +{ + return esp_wifi_remote_get_country(country); +} + +esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6]) +{ + return esp_wifi_remote_set_mac(ifx, mac); +} + +esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]) +{ + return esp_wifi_remote_get_mac(ifx, mac); +} + +esp_err_t esp_wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb) +{ + return esp_wifi_remote_set_promiscuous_rx_cb(cb); +} + +esp_err_t esp_wifi_set_promiscuous(_Bool en) +{ + return esp_wifi_remote_set_promiscuous(en); +} + +esp_err_t esp_wifi_get_promiscuous(_Bool *en) +{ + return esp_wifi_remote_get_promiscuous(en); +} + +esp_err_t esp_wifi_set_promiscuous_filter(const wifi_promiscuous_filter_t *filter) +{ + return esp_wifi_remote_set_promiscuous_filter(filter); +} + +esp_err_t esp_wifi_get_promiscuous_filter(wifi_promiscuous_filter_t *filter) +{ + return esp_wifi_remote_get_promiscuous_filter(filter); +} + +esp_err_t esp_wifi_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *filter) +{ + return esp_wifi_remote_set_promiscuous_ctrl_filter(filter); +} + +esp_err_t esp_wifi_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter) +{ + return esp_wifi_remote_get_promiscuous_ctrl_filter(filter); +} + +esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) +{ + return esp_wifi_remote_set_config(interface, conf); +} + +esp_err_t esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf) +{ + return esp_wifi_remote_get_config(interface, conf); +} + +esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta) +{ + return esp_wifi_remote_ap_get_sta_list(sta); +} + +esp_err_t esp_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid) +{ + return esp_wifi_remote_ap_get_sta_aid(mac, aid); +} + +esp_err_t esp_wifi_set_storage(wifi_storage_t storage) +{ + return esp_wifi_remote_set_storage(storage); +} + +esp_err_t esp_wifi_set_vendor_ie(_Bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie) +{ + return esp_wifi_remote_set_vendor_ie(enable, type, idx, vnd_ie); +} + +esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx) +{ + return esp_wifi_remote_set_vendor_ie_cb(cb, ctx); +} + +esp_err_t esp_wifi_set_max_tx_power(int8_t power) +{ + return esp_wifi_remote_set_max_tx_power(power); +} + +esp_err_t esp_wifi_get_max_tx_power(int8_t *power) +{ + return esp_wifi_remote_get_max_tx_power(power); +} + +esp_err_t esp_wifi_set_event_mask(uint32_t mask) +{ + return esp_wifi_remote_set_event_mask(mask); +} + +esp_err_t esp_wifi_get_event_mask(uint32_t *mask) +{ + return esp_wifi_remote_get_event_mask(mask); +} + +esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, _Bool en_sys_seq) +{ + return esp_wifi_remote_80211_tx(ifx, buffer, len, en_sys_seq); +} + +esp_err_t esp_wifi_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx) +{ + return esp_wifi_remote_set_csi_rx_cb(cb, ctx); +} + +esp_err_t esp_wifi_set_csi_config(const wifi_csi_config_t *config) +{ + return esp_wifi_remote_set_csi_config(config); +} + +esp_err_t esp_wifi_set_csi(_Bool en) +{ + return esp_wifi_remote_set_csi(en); +} + +esp_err_t esp_wifi_set_ant_gpio(const wifi_ant_gpio_config_t *config) +{ + return esp_wifi_remote_set_ant_gpio(config); +} + +esp_err_t esp_wifi_get_ant_gpio(wifi_ant_gpio_config_t *config) +{ + return esp_wifi_remote_get_ant_gpio(config); +} + +esp_err_t esp_wifi_set_ant(const wifi_ant_config_t *config) +{ + return esp_wifi_remote_set_ant(config); +} + +esp_err_t esp_wifi_get_ant(wifi_ant_config_t *config) +{ + return esp_wifi_remote_get_ant(config); +} + +int64_t esp_wifi_get_tsf_time(wifi_interface_t interface) +{ + return esp_wifi_remote_get_tsf_time(interface); +} + +esp_err_t esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec) +{ + return esp_wifi_remote_set_inactive_time(ifx, sec); +} + +esp_err_t esp_wifi_get_inactive_time(wifi_interface_t ifx, uint16_t *sec) +{ + return esp_wifi_remote_get_inactive_time(ifx, sec); +} + +esp_err_t esp_wifi_statis_dump(uint32_t modules) +{ + return esp_wifi_remote_statis_dump(modules); +} + +esp_err_t esp_wifi_set_rssi_threshold(int32_t rssi) +{ + return esp_wifi_remote_set_rssi_threshold(rssi); +} + +esp_err_t esp_wifi_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg) +{ + return esp_wifi_remote_ftm_initiate_session(cfg); +} + +esp_err_t esp_wifi_ftm_end_session(void) +{ + return esp_wifi_remote_ftm_end_session(); +} + +esp_err_t esp_wifi_ftm_resp_set_offset(int16_t offset_cm) +{ + return esp_wifi_remote_ftm_resp_set_offset(offset_cm); +} + +esp_err_t esp_wifi_ftm_get_report(wifi_ftm_report_entry_t *report, uint8_t num_entries) +{ + return esp_wifi_remote_ftm_get_report(report, num_entries); +} + +esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, _Bool disable) +{ + return esp_wifi_remote_config_11b_rate(ifx, disable); +} + +esp_err_t esp_wifi_connectionless_module_set_wake_interval(uint16_t wake_interval) +{ + return esp_wifi_remote_connectionless_module_set_wake_interval(wake_interval); +} + +esp_err_t esp_wifi_force_wakeup_acquire(void) +{ + return esp_wifi_remote_force_wakeup_acquire(); +} + +esp_err_t esp_wifi_force_wakeup_release(void) +{ + return esp_wifi_remote_force_wakeup_release(); +} + +esp_err_t esp_wifi_set_country_code(const char *country, _Bool ieee80211d_enabled) +{ + return esp_wifi_remote_set_country_code(country, ieee80211d_enabled); +} + +esp_err_t esp_wifi_get_country_code(char *country) +{ + return esp_wifi_remote_get_country_code(country); +} + +esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate) +{ + return esp_wifi_remote_config_80211_tx_rate(ifx, rate); +} + +esp_err_t esp_wifi_disable_pmf_config(wifi_interface_t ifx) +{ + return esp_wifi_remote_disable_pmf_config(ifx); +} + +esp_err_t esp_wifi_sta_get_aid(uint16_t *aid) +{ + return esp_wifi_remote_sta_get_aid(aid); +} + +esp_err_t esp_wifi_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode) +{ + return esp_wifi_remote_sta_get_negotiated_phymode(phymode); +} + +esp_err_t esp_wifi_set_dynamic_cs(_Bool enabled) +{ + return esp_wifi_remote_set_dynamic_cs(enabled); +} + +esp_err_t esp_wifi_sta_get_rssi(int *rssi) +{ + return esp_wifi_remote_sta_get_rssi(rssi); +} diff --git a/components/esp_wifi_remote/idf_component.yml b/components/esp_wifi_remote/idf_component.yml index 71e3fd1813..8ef35fc4a9 100644 --- a/components/esp_wifi_remote/idf_component.yml +++ b/components/esp_wifi_remote/idf_component.yml @@ -1 +1,8 @@ -version: "1.0.0" +version: 0.1.12 +url: https://github.com/espressif/esp-protocols/tree/master/components/esp_wifi_remote +description: Utility wrapper for esp_wifi functionality on remote targets +dependencies: + idf: + version: '5.3' +# espressif/esp_hosted: +# version: '*' diff --git a/components/esp_wifi_remote/include/esp_wifi_native.h b/components/esp_wifi_remote/include/esp_wifi_native.h deleted file mode 100644 index 4c9f082bcb..0000000000 --- a/components/esp_wifi_remote/include/esp_wifi_native.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - - -#define ESP_WIFI_MAX_CONN_NUM (15) /**< max number of stations which can connect to ESP32/ESP32S3/ESP32S2 soft-AP */ - -/** @brief List of stations associated with the Soft-AP */ -typedef struct wifi_sta_list_t { - wifi_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< station list */ - int num; /**< number of stations in the list (other entries are invalid) */ -} wifi_sta_list_t; diff --git a/components/esp_wifi_remote/include/esp_wifi_remote.h b/components/esp_wifi_remote/include/esp_wifi_remote.h index d04f468e2d..f6f2c93c65 100644 --- a/components/esp_wifi_remote/include/esp_wifi_remote.h +++ b/components/esp_wifi_remote/include/esp_wifi_remote.h @@ -5,59 +5,45 @@ */ #pragma once #include "esp_wifi.h" +#include "esp_wifi_remote_api.h" +/** + * @brief Remote channel Rx function pointer + */ typedef esp_err_t (*esp_remote_channel_rx_fn_t)(void *h, void *buffer, void *buff_to_free, size_t len); + +/** + * @brief Remote channel Tx function pointer + */ typedef esp_err_t (*esp_remote_channel_tx_fn_t)(void *h, void *buffer, size_t len); +/** + * @brief Remote channel handle + */ typedef struct esp_remote_channel *esp_remote_channel_t; -typedef struct esp_remote_channel_config *esp_remote_channel_config_t; - -// Public API -esp_err_t remote_esp_wifi_connect(void); -esp_err_t remote_esp_wifi_disconnect(void); -esp_err_t remote_esp_wifi_init(const wifi_init_config_t *config); -esp_err_t remote_esp_wifi_deinit(void); -esp_err_t remote_esp_wifi_set_mode(wifi_mode_t mode); -esp_err_t remote_esp_wifi_get_mode(wifi_mode_t *mode); -esp_err_t remote_esp_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf); -esp_err_t remote_esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf); -esp_err_t remote_esp_wifi_start(void); -esp_err_t remote_esp_wifi_stop(void); -esp_err_t remote_esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]); -esp_err_t remote_esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6]); -esp_err_t remote_esp_wifi_scan_start(const wifi_scan_config_t *config, bool block); -esp_err_t remote_esp_wifi_scan_stop(void); -esp_err_t remote_esp_wifi_scan_get_ap_num(uint16_t *number); -esp_err_t remote_esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records); -esp_err_t remote_esp_wifi_clear_ap_list(void); -esp_err_t remote_esp_wifi_restore(void); -esp_err_t remote_esp_wifi_clear_fast_connect(void); -esp_err_t remote_esp_wifi_deauth_sta(uint16_t aid); -esp_err_t remote_esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info); -esp_err_t remote_esp_wifi_set_ps(wifi_ps_type_t type); -esp_err_t remote_esp_wifi_get_ps(wifi_ps_type_t *type); -esp_err_t remote_esp_wifi_set_storage(wifi_storage_t storage); -esp_err_t remote_esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw); -esp_err_t remote_esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw); -esp_err_t remote_esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second); -esp_err_t remote_esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second); -esp_err_t remote_esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled); -esp_err_t remote_esp_wifi_get_country_code(char *country); -esp_err_t remote_esp_wifi_set_country(const wifi_country_t *country); -esp_err_t remote_esp_wifi_get_country(wifi_country_t *country); -esp_err_t remote_esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta); -esp_err_t remote_esp_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid); -esp_err_t remote_esp_wifi_sta_get_rssi(int *rssi); -esp_err_t remote_esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap); -esp_err_t remote_esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap); +/** + * @brief Remote channel configuration + */ +typedef struct esp_remote_channel_config *esp_remote_channel_config_t; -// TODO: Move this to private include -// Private API -esp_err_t remote_esp_wifi_init_slave(void); // handling channels +/** + * @brief Receive packet to the esp_wifi network layers + * @param h Channel handle + * @param buffer Packet buffer ptr + * @param buff_to_free Packet ptr to free + * @param len Packet len + * @return ESP_OK on success + */ esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, void *buff_to_free, size_t len); + +/** + * @brief Sets Tx callback for the remote channel + * @param ifx Wifi interface + * @param h Channel handle + * @param tx_cb Callback type + * @return ESP_OK on success + */ esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_remote_channel_tx_fn_t tx_cb); -esp_err_t esp_wifi_remote_rpc_channel_rx(void *h, void *buffer, size_t len); -esp_err_t esp_wifi_remote_rpc_channel_set(void *h, esp_remote_channel_tx_fn_t tx_cb); diff --git a/components/esp_wifi_remote/include/esp_wifi_remote_api.h b/components/esp_wifi_remote/include/esp_wifi_remote_api.h new file mode 100644 index 0000000000..420aa5e7e9 --- /dev/null +++ b/components/esp_wifi_remote/include/esp_wifi_remote_api.h @@ -0,0 +1,84 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +// This file is auto-generated +#pragma once +esp_err_t esp_wifi_remote_init(const wifi_init_config_t *config); +esp_err_t esp_wifi_remote_deinit(void); +esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode); +esp_err_t esp_wifi_remote_get_mode(wifi_mode_t *mode); +esp_err_t esp_wifi_remote_start(void); +esp_err_t esp_wifi_remote_stop(void); +esp_err_t esp_wifi_remote_restore(void); +esp_err_t esp_wifi_remote_connect(void); +esp_err_t esp_wifi_remote_disconnect(void); +esp_err_t esp_wifi_remote_clear_fast_connect(void); +esp_err_t esp_wifi_remote_deauth_sta(uint16_t aid); +esp_err_t esp_wifi_remote_scan_start(const wifi_scan_config_t *config, _Bool block); +esp_err_t esp_wifi_remote_scan_stop(void); +esp_err_t esp_wifi_remote_scan_get_ap_num(uint16_t *number); +esp_err_t esp_wifi_remote_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records); +esp_err_t esp_wifi_remote_scan_get_ap_record(wifi_ap_record_t *ap_record); +esp_err_t esp_wifi_remote_clear_ap_list(void); +esp_err_t esp_wifi_remote_sta_get_ap_info(wifi_ap_record_t *ap_info); +esp_err_t esp_wifi_remote_set_ps(wifi_ps_type_t type); +esp_err_t esp_wifi_remote_get_ps(wifi_ps_type_t *type); +esp_err_t esp_wifi_remote_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap); +esp_err_t esp_wifi_remote_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap); +esp_err_t esp_wifi_remote_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw); +esp_err_t esp_wifi_remote_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw); +esp_err_t esp_wifi_remote_set_channel(uint8_t primary, wifi_second_chan_t second); +esp_err_t esp_wifi_remote_get_channel(uint8_t *primary, wifi_second_chan_t *second); +esp_err_t esp_wifi_remote_set_country(const wifi_country_t *country); +esp_err_t esp_wifi_remote_get_country(wifi_country_t *country); +esp_err_t esp_wifi_remote_set_mac(wifi_interface_t ifx, const uint8_t mac[6]); +esp_err_t esp_wifi_remote_get_mac(wifi_interface_t ifx, uint8_t mac[6]); +esp_err_t esp_wifi_remote_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb); +esp_err_t esp_wifi_remote_set_promiscuous(_Bool en); +esp_err_t esp_wifi_remote_get_promiscuous(_Bool *en); +esp_err_t esp_wifi_remote_set_promiscuous_filter(const wifi_promiscuous_filter_t *filter); +esp_err_t esp_wifi_remote_get_promiscuous_filter(wifi_promiscuous_filter_t *filter); +esp_err_t esp_wifi_remote_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *filter); +esp_err_t esp_wifi_remote_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter); +esp_err_t esp_wifi_remote_set_config(wifi_interface_t interface, wifi_config_t *conf); +esp_err_t esp_wifi_remote_get_config(wifi_interface_t interface, wifi_config_t *conf); +esp_err_t esp_wifi_remote_ap_get_sta_list(wifi_sta_list_t *sta); +esp_err_t esp_wifi_remote_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid); +esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage); +esp_err_t esp_wifi_remote_set_vendor_ie(_Bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie); +esp_err_t esp_wifi_remote_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx); +esp_err_t esp_wifi_remote_set_max_tx_power(int8_t power); +esp_err_t esp_wifi_remote_get_max_tx_power(int8_t *power); +esp_err_t esp_wifi_remote_set_event_mask(uint32_t mask); +esp_err_t esp_wifi_remote_get_event_mask(uint32_t *mask); +esp_err_t esp_wifi_remote_80211_tx(wifi_interface_t ifx, const void *buffer, int len, _Bool en_sys_seq); +esp_err_t esp_wifi_remote_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx); +esp_err_t esp_wifi_remote_set_csi_config(const wifi_csi_config_t *config); +esp_err_t esp_wifi_remote_set_csi(_Bool en); +esp_err_t esp_wifi_remote_set_ant_gpio(const wifi_ant_gpio_config_t *config); +esp_err_t esp_wifi_remote_get_ant_gpio(wifi_ant_gpio_config_t *config); +esp_err_t esp_wifi_remote_set_ant(const wifi_ant_config_t *config); +esp_err_t esp_wifi_remote_get_ant(wifi_ant_config_t *config); +int64_t esp_wifi_remote_get_tsf_time(wifi_interface_t interface); +esp_err_t esp_wifi_remote_set_inactive_time(wifi_interface_t ifx, uint16_t sec); +esp_err_t esp_wifi_remote_get_inactive_time(wifi_interface_t ifx, uint16_t *sec); +esp_err_t esp_wifi_remote_statis_dump(uint32_t modules); +esp_err_t esp_wifi_remote_set_rssi_threshold(int32_t rssi); +esp_err_t esp_wifi_remote_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg); +esp_err_t esp_wifi_remote_ftm_end_session(void); +esp_err_t esp_wifi_remote_ftm_resp_set_offset(int16_t offset_cm); +esp_err_t esp_wifi_remote_ftm_get_report(wifi_ftm_report_entry_t *report, uint8_t num_entries); +esp_err_t esp_wifi_remote_config_11b_rate(wifi_interface_t ifx, _Bool disable); +esp_err_t esp_wifi_remote_connectionless_module_set_wake_interval(uint16_t wake_interval); +esp_err_t esp_wifi_remote_force_wakeup_acquire(void); +esp_err_t esp_wifi_remote_force_wakeup_release(void); +esp_err_t esp_wifi_remote_set_country_code(const char *country, _Bool ieee80211d_enabled); +esp_err_t esp_wifi_remote_get_country_code(char *country); +esp_err_t esp_wifi_remote_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); +esp_err_t esp_wifi_remote_disable_pmf_config(wifi_interface_t ifx); +esp_err_t esp_wifi_remote_sta_get_aid(uint16_t *aid); +esp_err_t esp_wifi_remote_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode); +esp_err_t esp_wifi_remote_set_dynamic_cs(_Bool enabled); +esp_err_t esp_wifi_remote_sta_get_rssi(int *rssi); diff --git a/components/esp_wifi_remote/include/esp_wifi_remote_with_hosted.h b/components/esp_wifi_remote/include/esp_wifi_remote_with_hosted.h new file mode 100644 index 0000000000..6797138f10 --- /dev/null +++ b/components/esp_wifi_remote/include/esp_wifi_remote_with_hosted.h @@ -0,0 +1,386 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "esp_hosted_wifi_api.h" + +static inline esp_err_t esp_wifi_remote_init(const wifi_init_config_t *config) +{ + return esp_hosted_wifi_init(config); +} + +static inline esp_err_t esp_wifi_remote_deinit(void) +{ + return esp_hosted_wifi_deinit(); +} + +static inline esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode) +{ + return esp_hosted_wifi_set_mode(mode); +} + +static inline esp_err_t esp_wifi_remote_get_mode(wifi_mode_t *mode) +{ + return esp_hosted_wifi_get_mode(mode); +} + +static inline esp_err_t esp_wifi_remote_start(void) +{ + return esp_hosted_wifi_start(); +} + +static inline esp_err_t esp_wifi_remote_stop(void) +{ + return esp_hosted_wifi_stop(); +} + +static inline esp_err_t esp_wifi_remote_restore(void) +{ + return esp_hosted_wifi_restore(); +} + +static inline esp_err_t esp_wifi_remote_connect(void) +{ + return esp_hosted_wifi_connect(); +} + +static inline esp_err_t esp_wifi_remote_disconnect(void) +{ + return esp_hosted_wifi_disconnect(); +} + +static inline esp_err_t esp_wifi_remote_clear_fast_connect(void) +{ + return esp_hosted_wifi_clear_fast_connect(); +} + +static inline esp_err_t esp_wifi_remote_deauth_sta(uint16_t aid) +{ + return esp_hosted_wifi_deauth_sta(aid); +} + +static inline esp_err_t esp_wifi_remote_scan_start(const wifi_scan_config_t *config, _Bool block) +{ + return esp_hosted_wifi_scan_start(config, block); +} + +static inline esp_err_t esp_wifi_remote_scan_stop(void) +{ + return esp_hosted_wifi_scan_stop(); +} + +static inline esp_err_t esp_wifi_remote_scan_get_ap_num(uint16_t *number) +{ + return esp_hosted_wifi_scan_get_ap_num(number); +} + +static inline esp_err_t esp_wifi_remote_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records) +{ + return esp_hosted_wifi_scan_get_ap_records(number, ap_records); +} + +static inline esp_err_t esp_wifi_remote_scan_get_ap_record(wifi_ap_record_t *ap_record) +{ + return esp_hosted_wifi_scan_get_ap_record(ap_record); +} + +static inline esp_err_t esp_wifi_remote_clear_ap_list(void) +{ + return esp_hosted_wifi_clear_ap_list(); +} + +static inline esp_err_t esp_wifi_remote_sta_get_ap_info(wifi_ap_record_t *ap_info) +{ + return esp_hosted_wifi_sta_get_ap_info(ap_info); +} + +static inline esp_err_t esp_wifi_remote_set_ps(wifi_ps_type_t type) +{ + return esp_hosted_wifi_set_ps(type); +} + +static inline esp_err_t esp_wifi_remote_get_ps(wifi_ps_type_t *type) +{ + return esp_hosted_wifi_get_ps(type); +} + +static inline esp_err_t esp_wifi_remote_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap) +{ + return esp_hosted_wifi_set_protocol(ifx, protocol_bitmap); +} + +static inline esp_err_t esp_wifi_remote_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap) +{ + return esp_hosted_wifi_get_protocol(ifx, protocol_bitmap); +} + +static inline esp_err_t esp_wifi_remote_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw) +{ + return esp_hosted_wifi_set_bandwidth(ifx, bw); +} + +static inline esp_err_t esp_wifi_remote_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw) +{ + return esp_hosted_wifi_get_bandwidth(ifx, bw); +} + +static inline esp_err_t esp_wifi_remote_set_channel(uint8_t primary, wifi_second_chan_t second) +{ + return esp_hosted_wifi_set_channel(primary, second); +} + +static inline esp_err_t esp_wifi_remote_get_channel(uint8_t *primary, wifi_second_chan_t *second) +{ + return esp_hosted_wifi_get_channel(primary, second); +} + +static inline esp_err_t esp_wifi_remote_set_country(const wifi_country_t *country) +{ + return esp_hosted_wifi_set_country(country); +} + +static inline esp_err_t esp_wifi_remote_get_country(wifi_country_t *country) +{ + return esp_hosted_wifi_get_country(country); +} + +static inline esp_err_t esp_wifi_remote_set_mac(wifi_interface_t ifx, const uint8_t mac[6]) +{ + return esp_hosted_wifi_set_mac(ifx, mac); +} + +static inline esp_err_t esp_wifi_remote_get_mac(wifi_interface_t ifx, uint8_t mac[6]) +{ + return esp_hosted_wifi_get_mac(ifx, mac); +} + +static inline esp_err_t esp_wifi_remote_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb) +{ + return esp_hosted_wifi_set_promiscuous_rx_cb(cb); +} + +static inline esp_err_t esp_wifi_remote_set_promiscuous(_Bool en) +{ + return esp_hosted_wifi_set_promiscuous(en); +} + +static inline esp_err_t esp_wifi_remote_get_promiscuous(_Bool *en) +{ + return esp_hosted_wifi_get_promiscuous(en); +} + +static inline esp_err_t esp_wifi_remote_set_promiscuous_filter(const wifi_promiscuous_filter_t *filter) +{ + return esp_hosted_wifi_set_promiscuous_filter(filter); +} + +static inline esp_err_t esp_wifi_remote_get_promiscuous_filter(wifi_promiscuous_filter_t *filter) +{ + return esp_hosted_wifi_get_promiscuous_filter(filter); +} + +static inline esp_err_t esp_wifi_remote_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *filter) +{ + return esp_hosted_wifi_set_promiscuous_ctrl_filter(filter); +} + +static inline esp_err_t esp_wifi_remote_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter) +{ + return esp_hosted_wifi_get_promiscuous_ctrl_filter(filter); +} + +static inline esp_err_t esp_wifi_remote_set_config(wifi_interface_t interface, wifi_config_t *conf) +{ + return esp_hosted_wifi_set_config(interface, conf); +} + +static inline esp_err_t esp_wifi_remote_get_config(wifi_interface_t interface, wifi_config_t *conf) +{ + return esp_hosted_wifi_get_config(interface, conf); +} + +static inline esp_err_t esp_wifi_remote_ap_get_sta_list(wifi_sta_list_t *sta) +{ + return esp_hosted_wifi_ap_get_sta_list(sta); +} + +static inline esp_err_t esp_wifi_remote_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid) +{ + return esp_hosted_wifi_ap_get_sta_aid(mac, aid); +} + +static inline esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage) +{ + return esp_hosted_wifi_set_storage(storage); +} + +static inline esp_err_t esp_wifi_remote_set_vendor_ie(_Bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie) +{ + return esp_hosted_wifi_set_vendor_ie(enable, type, idx, vnd_ie); +} + +static inline esp_err_t esp_wifi_remote_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx) +{ + return esp_hosted_wifi_set_vendor_ie_cb(cb, ctx); +} + +static inline esp_err_t esp_wifi_remote_set_max_tx_power(int8_t power) +{ + return esp_hosted_wifi_set_max_tx_power(power); +} + +static inline esp_err_t esp_wifi_remote_get_max_tx_power(int8_t *power) +{ + return esp_hosted_wifi_get_max_tx_power(power); +} + +static inline esp_err_t esp_wifi_remote_set_event_mask(uint32_t mask) +{ + return esp_hosted_wifi_set_event_mask(mask); +} + +static inline esp_err_t esp_wifi_remote_get_event_mask(uint32_t *mask) +{ + return esp_hosted_wifi_get_event_mask(mask); +} + +static inline esp_err_t esp_wifi_remote_80211_tx(wifi_interface_t ifx, const void *buffer, int len, _Bool en_sys_seq) +{ + return esp_hosted_wifi_80211_tx(ifx, buffer, len, en_sys_seq); +} + +static inline esp_err_t esp_wifi_remote_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx) +{ + return esp_hosted_wifi_set_csi_rx_cb(cb, ctx); +} + +static inline esp_err_t esp_wifi_remote_set_csi_config(const wifi_csi_config_t *config) +{ + return esp_hosted_wifi_set_csi_config(config); +} + +static inline esp_err_t esp_wifi_remote_set_csi(_Bool en) +{ + return esp_hosted_wifi_set_csi(en); +} + +static inline esp_err_t esp_wifi_remote_set_ant_gpio(const wifi_ant_gpio_config_t *config) +{ + return esp_hosted_wifi_set_ant_gpio(config); +} + +static inline esp_err_t esp_wifi_remote_get_ant_gpio(wifi_ant_gpio_config_t *config) +{ + return esp_hosted_wifi_get_ant_gpio(config); +} + +static inline esp_err_t esp_wifi_remote_set_ant(const wifi_ant_config_t *config) +{ + return esp_hosted_wifi_set_ant(config); +} + +static inline esp_err_t esp_wifi_remote_get_ant(wifi_ant_config_t *config) +{ + return esp_hosted_wifi_get_ant(config); +} + +static inline int64_t esp_wifi_remote_get_tsf_time(wifi_interface_t interface) +{ + return esp_hosted_wifi_get_tsf_time(interface); +} + +static inline esp_err_t esp_wifi_remote_set_inactive_time(wifi_interface_t ifx, uint16_t sec) +{ + return esp_hosted_wifi_set_inactive_time(ifx, sec); +} + +static inline esp_err_t esp_wifi_remote_get_inactive_time(wifi_interface_t ifx, uint16_t *sec) +{ + return esp_hosted_wifi_get_inactive_time(ifx, sec); +} + +static inline esp_err_t esp_wifi_remote_statis_dump(uint32_t modules) +{ + return esp_hosted_wifi_statis_dump(modules); +} + +static inline esp_err_t esp_wifi_remote_set_rssi_threshold(int32_t rssi) +{ + return esp_hosted_wifi_set_rssi_threshold(rssi); +} + +static inline esp_err_t esp_wifi_remote_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg) +{ + return esp_hosted_wifi_ftm_initiate_session(cfg); +} + +static inline esp_err_t esp_wifi_remote_ftm_end_session(void) +{ + return esp_hosted_wifi_ftm_end_session(); +} + +static inline esp_err_t esp_wifi_remote_ftm_resp_set_offset(int16_t offset_cm) +{ + return esp_hosted_wifi_ftm_resp_set_offset(offset_cm); +} + +static inline esp_err_t esp_wifi_remote_config_11b_rate(wifi_interface_t ifx, _Bool disable) +{ + return esp_hosted_wifi_config_11b_rate(ifx, disable); +} + +static inline esp_err_t esp_wifi_remote_connectionless_module_set_wake_interval(uint16_t wake_interval) +{ + return esp_hosted_wifi_connectionless_module_set_wake_interval(wake_interval); +} + +static inline esp_err_t esp_wifi_remote_force_wakeup_acquire(void) +{ + return esp_hosted_wifi_force_wakeup_acquire(); +} + +static inline esp_err_t esp_wifi_remote_force_wakeup_release(void) +{ + return esp_hosted_wifi_force_wakeup_release(); +} + +static inline esp_err_t esp_wifi_remote_set_country_code(const char *country, _Bool ieee80211d_enabled) +{ + return esp_hosted_wifi_set_country_code(country, ieee80211d_enabled); +} + +static inline esp_err_t esp_wifi_remote_get_country_code(char *country) +{ + return esp_hosted_wifi_get_country_code(country); +} + +static inline esp_err_t esp_wifi_remote_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate) +{ + return esp_hosted_wifi_config_80211_tx_rate(ifx, rate); +} + +static inline esp_err_t esp_wifi_remote_disable_pmf_config(wifi_interface_t ifx) +{ + return esp_hosted_wifi_disable_pmf_config(ifx); +} + +static inline esp_err_t esp_wifi_remote_sta_get_aid(uint16_t *aid) +{ + return esp_hosted_wifi_sta_get_aid(aid); +} + +static inline esp_err_t esp_wifi_remote_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode) +{ + return esp_hosted_wifi_sta_get_negotiated_phymode(phymode); +} + +static inline esp_err_t esp_wifi_remote_set_dynamic_cs(_Bool enabled) +{ + return esp_hosted_wifi_set_dynamic_cs(enabled); +} + +static inline esp_err_t esp_wifi_remote_sta_get_rssi(int *rssi) +{ + return esp_hosted_wifi_sta_get_rssi(rssi); +} diff --git a/components/esp_wifi_remote/include/esp_wifi_types_native.h b/components/esp_wifi_remote/include/esp_wifi_types_native.h new file mode 100644 index 0000000000..00047f899f --- /dev/null +++ b/components/esp_wifi_remote/include/esp_wifi_types_native.h @@ -0,0 +1,134 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" +#include "esp_wifi_types_generic.h" +#if CONFIG_SLAVE_SOC_WIFI_HE_SUPPORT +#include "esp_wifi_he_types.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if CONFIG_SLAVE_IDF_TARGET_ESP32C2 +#define ESP_WIFI_MAX_CONN_NUM (4) /**< max number of stations which can connect to ESP32C2 soft-AP */ +#elif CONFIG_SLAVE_IDF_TARGET_ESP32C3 || CONFIG_SLAVE_IDF_TARGET_ESP32C6 +#define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32C3 soft-AP */ +#else +#define ESP_WIFI_MAX_CONN_NUM (15) /**< max number of stations which can connect to ESP32/ESP32S3/ESP32S2 soft-AP */ +#endif + +/** @brief List of stations associated with the Soft-AP */ +typedef struct wifi_sta_list_t { + wifi_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< station list */ + int num; /**< number of stations in the list (other entries are invalid) */ +} wifi_sta_list_t; + +#if CONFIG_SLAVE_SOC_WIFI_HE_SUPPORT +typedef esp_wifi_rxctrl_t wifi_pkt_rx_ctrl_t; +#else +/** @brief Received packet radio metadata header, this is the common header at the beginning of all promiscuous mode RX callback buffers */ +typedef struct { + signed rssi:8; /**< Received Signal Strength Indicator(RSSI) of packet. unit: dBm */ + unsigned rate:5; /**< PHY rate encoding of the packet. Only valid for non HT(11bg) packet */ + unsigned :1; /**< reserved */ + unsigned sig_mode:2; /**< Protocol of the reveived packet, 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */ + unsigned :16; /**< reserved */ + unsigned mcs:7; /**< Modulation Coding Scheme. If is HT(11n) packet, shows the modulation, range from 0 to 76(MSC0 ~ MCS76) */ + unsigned cwb:1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */ + unsigned :16; /**< reserved */ + unsigned smoothing:1; /**< Set to 1 indicates that channel estimate smoothing is recommended. + Set to 0 indicates that only per-carrierindependent (unsmoothed) channel estimate is recommended. */ + unsigned not_sounding:1; /**< Set to 0 indicates that PPDU is a sounding PPDU. Set to 1indicates that the PPDU is not a sounding PPDU. + sounding PPDU is used for channel estimation by the request receiver */ + unsigned :1; /**< reserved */ + unsigned aggregation:1; /**< Aggregation. 0: MPDU packet; 1: AMPDU packet */ + unsigned stbc:2; /**< Space Time Block Code(STBC). 0: non STBC packet; 1: STBC packet */ + unsigned fec_coding:1; /**< Forward Error Correction(FEC). Flag is set for 11n packets which are LDPC */ + unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */ +#if CONFIG_SLAVE_IDF_TARGET_ESP32 + signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ +#elif CONFIG_SLAVE_IDF_TARGET_ESP32S2 || CONFIG_SLAVE_IDF_TARGET_ESP32S3 || CONFIG_SLAVE_IDF_TARGET_ESP32C3 || CONFIG_SLAVE_IDF_TARGET_ESP32C2 + unsigned :8; /**< reserved */ +#endif + unsigned ampdu_cnt:8; /**< the number of subframes aggregated in AMPDU */ + unsigned channel:4; /**< primary channel on which this packet is received */ + unsigned secondary_channel:4; /**< secondary channel on which this packet is received. 0: none; 1: above; 2: below */ + unsigned :8; /**< reserved */ + unsigned timestamp:32; /**< timestamp. The local time when this packet is received. It is precise only if modem sleep or light sleep is not enabled. unit: microsecond */ + unsigned :32; /**< reserved */ +#if CONFIG_SLAVE_IDF_TARGET_ESP32S2 + unsigned :32; /**< reserved */ +#elif CONFIG_SLAVE_IDF_TARGET_ESP32S3 || CONFIG_SLAVE_IDF_TARGET_ESP32C3 || CONFIG_SLAVE_IDF_TARGET_ESP32C2 + signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ + unsigned :24; /**< reserved */ + unsigned :32; /**< reserved */ +#endif + unsigned :31; /**< reserved */ + unsigned ant:1; /**< antenna number from which this packet is received. 0: WiFi antenna 0; 1: WiFi antenna 1 */ +#if CONFIG_SLAVE_IDF_TARGET_ESP32S2 + signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: dBm*/ + unsigned :24; /**< reserved */ +#elif CONFIG_SLAVE_IDF_TARGET_ESP32S3 || CONFIG_SLAVE_IDF_TARGET_ESP32C3 || CONFIG_SLAVE_IDF_TARGET_ESP32C2 + unsigned :32; /**< reserved */ + unsigned :32; /**< reserved */ + unsigned :32; /**< reserved */ +#endif + unsigned sig_len:12; /**< length of packet including Frame Check Sequence(FCS) */ + unsigned :12; /**< reserved */ + unsigned rx_state:8; /**< state of the packet. 0: no error; others: error numbers which are not public */ +} wifi_pkt_rx_ctrl_t; +#endif + +/** + * @brief Channel state information(CSI) configuration type + * + */ +#if CONFIG_SLAVE_SOC_WIFI_HE_SUPPORT +typedef wifi_csi_acquire_config_t wifi_csi_config_t; +#else +typedef struct { + bool lltf_en; /**< enable to receive legacy long training field(lltf) data. Default enabled */ + bool htltf_en; /**< enable to receive HT long training field(htltf) data. Default enabled */ + bool stbc_htltf2_en; /**< enable to receive space time block code HT long training field(stbc-htltf2) data. Default enabled */ + bool ltf_merge_en; /**< enable to generate htlft data by averaging lltf and ht_ltf data when receiving HT packet. Otherwise, use ht_ltf data directly. Default enabled */ + bool channel_filter_en; /**< enable to turn on channel filter to smooth adjacent sub-carrier. Disable it to keep independence of adjacent sub-carrier. Default enabled */ + bool manu_scale; /**< manually scale the CSI data by left shifting or automatically scale the CSI data. If set true, please set the shift bits. false: automatically. true: manually. Default false */ + uint8_t shift; /**< manually left shift bits of the scale of the CSI data. The range of the left shift bits is 0~15 */ + bool dump_ack_en; /**< enable to dump 802.11 ACK frame, default disabled */ +} wifi_csi_config_t; +#endif // !CONFIG_SLAVE_SOC_WIFI_HE_SUPPORT + + +/** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback. + */ +typedef struct { + wifi_pkt_rx_ctrl_t rx_ctrl; /**< metadata header */ + uint8_t payload[0]; /**< Data or management payload. Length of payload is described by rx_ctrl.sig_len. Type of content determined by packet type argument of callback. */ +} wifi_promiscuous_pkt_t; + +/** + * @brief CSI data type + * + */ +typedef struct wifi_csi_info_t { + wifi_pkt_rx_ctrl_t rx_ctrl;/**< received packet radio metadata header of the CSI data */ + uint8_t mac[6]; /**< source MAC address of the CSI data */ + uint8_t dmac[6]; /**< destination MAC address of the CSI data */ + bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not, true indicates the first four bytes is invalid due to hardware limition */ + int8_t *buf; /**< valid buffer of CSI data */ + uint16_t len; /**< valid length of CSI data */ + uint8_t *hdr; /**< header of the wifi packet */ + uint8_t *payload; /**< payload of the wifi packet */ + uint16_t payload_len; /**< payload len of the wifi packet */ +} wifi_csi_info_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/esp_wifi_remote/scripts/Kconfig b/components/esp_wifi_remote/scripts/Kconfig new file mode 100644 index 0000000000..e52b8e74f8 --- /dev/null +++ b/components/esp_wifi_remote/scripts/Kconfig @@ -0,0 +1,633 @@ +menu "Wi-Fi Remote" + orsource "./Kconfig.soc_wifi_caps.in" + + config ESP_WIFI_STATIC_RX_BUFFER_NUM + int "Max number of WiFi static RX buffers" + range 2 25 if !SLAVE_SOC_WIFI_HE_SUPPORT + range 2 128 if SLAVE_SOC_WIFI_HE_SUPPORT + default 10 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + help + Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM. + The static rx buffers are allocated when esp_wifi_init is called, they are not freed + until esp_wifi_deinit is called. + + WiFi hardware use these buffers to receive all 802.11 frames. + A higher number may allow higher throughput but increases memory use. If ESP_WIFI_AMPDU_RX_ENABLED + is enabled, this value is recommended to set equal or bigger than ESP_WIFI_RX_BA_WIN in order to + achieve better throughput and compatibility with both stations and APs. + + config ESP_WIFI_DYNAMIC_RX_BUFFER_NUM + int "Max number of WiFi dynamic RX buffers" + range 0 128 if !LWIP_WND_SCALE + range 0 1024 if LWIP_WND_SCALE + default 32 + help + Set the number of WiFi dynamic RX buffers, 0 means unlimited RX buffers will be allocated + (provided sufficient free RAM). The size of each dynamic RX buffer depends on the size of + the received data frame. + + For each received data frame, the WiFi driver makes a copy to an RX buffer and then delivers + it to the high layer TCP/IP stack. The dynamic RX buffer is freed after the higher layer has + successfully received the data frame. + + For some applications, WiFi data frames may be received faster than the application can + process them. In these cases we may run out of memory if RX buffer number is unlimited (0). + + If a dynamic RX buffer limit is set, it should be at least the number of static RX buffers. + + choice ESP_WIFI_TX_BUFFER + prompt "Type of WiFi TX buffers" + default ESP_WIFI_DYNAMIC_TX_BUFFER + help + Select type of WiFi TX buffers: + + If "Static" is selected, WiFi TX buffers are allocated when WiFi is initialized and released + when WiFi is de-initialized. The size of each static TX buffer is fixed to about 1.6KB. + + If "Dynamic" is selected, each WiFi TX buffer is allocated as needed when a data frame is + delivered to the Wifi driver from the TCP/IP stack. The buffer is freed after the data frame + has been sent by the WiFi driver. The size of each dynamic TX buffer depends on the length + of each data frame sent by the TCP/IP layer. + + If PSRAM is enabled, "Static" should be selected to guarantee enough WiFi TX buffers. + If PSRAM is disabled, "Dynamic" should be selected to improve the utilization of RAM. + + config ESP_WIFI_STATIC_TX_BUFFER + bool "Static" + config ESP_WIFI_DYNAMIC_TX_BUFFER + bool "Dynamic" + depends on !SPIRAM_USE_MALLOC + endchoice + + config ESP_WIFI_TX_BUFFER_TYPE + int + default 0 if ESP_WIFI_STATIC_TX_BUFFER + default 1 if ESP_WIFI_DYNAMIC_TX_BUFFER + + config ESP_WIFI_STATIC_TX_BUFFER_NUM + int "Max number of WiFi static TX buffers" + depends on ESP_WIFI_STATIC_TX_BUFFER + range 1 64 + default 16 + help + Set the number of WiFi static TX buffers. Each buffer takes approximately 1.6KB of RAM. + The static RX buffers are allocated when esp_wifi_init() is called, they are not released + until esp_wifi_deinit() is called. + + For each transmitted data frame from the higher layer TCP/IP stack, the WiFi driver makes a + copy of it in a TX buffer. For some applications especially UDP applications, the upper + layer can deliver frames faster than WiFi layer can transmit. In these cases, we may run out + of TX buffers. + + config ESP_WIFI_CACHE_TX_BUFFER_NUM + int "Max number of WiFi cache TX buffers" + depends on SPIRAM + range 16 128 + default 32 + help + Set the number of WiFi cache TX buffer number. + + For each TX packet from uplayer, such as LWIP etc, WiFi driver needs to allocate a static TX + buffer and makes a copy of uplayer packet. If WiFi driver fails to allocate the static TX buffer, + it caches the uplayer packets to a dedicated buffer queue, this option is used to configure the + size of the cached TX queue. + + config ESP_WIFI_DYNAMIC_TX_BUFFER_NUM + int "Max number of WiFi dynamic TX buffers" + depends on ESP_WIFI_DYNAMIC_TX_BUFFER + range 1 128 + default 32 + help + Set the number of WiFi dynamic TX buffers. The size of each dynamic TX buffer is not fixed, + it depends on the size of each transmitted data frame. + + For each transmitted frame from the higher layer TCP/IP stack, the WiFi driver makes a copy + of it in a TX buffer. For some applications, especially UDP applications, the upper layer + can deliver frames faster than WiFi layer can transmit. In these cases, we may run out of TX + buffers. + + choice ESP_WIFI_MGMT_RX_BUFFER + prompt "Type of WiFi RX MGMT buffers" + default ESP_WIFI_STATIC_RX_MGMT_BUFFER + help + Select type of WiFi RX MGMT buffers: + + If "Static" is selected, WiFi RX MGMT buffers are allocated when WiFi is initialized and released + when WiFi is de-initialized. The size of each static RX MGMT buffer is fixed to about 500 Bytes. + + If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated as needed when a MGMT data frame is + received. The MGMT buffer is freed after the MGMT data frame has been processed by the WiFi driver. + + + config ESP_WIFI_STATIC_RX_MGMT_BUFFER + bool "Static" + config ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER + bool "Dynamic" + endchoice + + config ESP_WIFI_DYNAMIC_RX_MGMT_BUF + int + default 0 if ESP_WIFI_STATIC_RX_MGMT_BUFFER + default 1 if ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER + + config ESP_WIFI_RX_MGMT_BUF_NUM_DEF + int "Max number of WiFi RX MGMT buffers" + range 1 10 + default 5 + help + Set the number of WiFi RX_MGMT buffers. + + For Management buffers, the number of dynamic and static management buffers is the same. + In order to prevent memory fragmentation, the management buffer type should be set to static first. + + config ESP_WIFI_CSI_ENABLED + bool "WiFi CSI(Channel State Information)" + depends on SLAVE_SOC_WIFI_CSI_SUPPORT + default n + help + Select this option to enable CSI(Channel State Information) feature. CSI takes about + CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM KB of RAM. If CSI is not used, it is better to disable + this feature in order to save memory. + + config ESP_WIFI_AMPDU_TX_ENABLED + bool "WiFi AMPDU TX" + default y + help + Select this option to enable AMPDU TX feature + + + config ESP_WIFI_TX_BA_WIN + int "WiFi AMPDU TX BA window size" + depends on ESP_WIFI_AMPDU_TX_ENABLED + range 2 32 if !SLAVE_SOC_WIFI_HE_SUPPORT + range 2 64 if SLAVE_SOC_WIFI_HE_SUPPORT + default 6 + help + Set the size of WiFi Block Ack TX window. Generally a bigger value means higher throughput but + more memory. Most of time we should NOT change the default value unless special reason, e.g. + test the maximum UDP TX throughput with iperf etc. For iperf test in shieldbox, the recommended + value is 9~12. + + config ESP_WIFI_AMPDU_RX_ENABLED + bool "WiFi AMPDU RX" + default y + help + Select this option to enable AMPDU RX feature + + config ESP_WIFI_RX_BA_WIN + int "WiFi AMPDU RX BA window size" + depends on ESP_WIFI_AMPDU_RX_ENABLED + range 2 32 if !SLAVE_SOC_WIFI_HE_SUPPORT + range 2 64 if SLAVE_SOC_WIFI_HE_SUPPORT + default 6 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + help + Set the size of WiFi Block Ack RX window. Generally a bigger value means higher throughput and better + compatibility but more memory. Most of time we should NOT change the default value unless special + reason, e.g. test the maximum UDP RX throughput with iperf etc. For iperf test in shieldbox, the + recommended value is 9~12. If PSRAM is used and WiFi memory is prefered to allocat in PSRAM first, + the default and minimum value should be 16 to achieve better throughput and compatibility with both + stations and APs. + + config ESP_WIFI_AMSDU_TX_ENABLED + bool "WiFi AMSDU TX" + depends on SPIRAM + default n + help + Select this option to enable AMSDU TX feature + + config ESP_WIFI_NVS_ENABLED + bool "WiFi NVS flash" + default y + help + Select this option to enable WiFi NVS flash + + choice ESP_WIFI_TASK_CORE_ID + depends on !FREERTOS_UNICORE + prompt "WiFi Task Core ID" + default ESP_WIFI_TASK_PINNED_TO_CORE_0 + help + Pinned WiFi task to core 0 or core 1. + + config ESP_WIFI_TASK_PINNED_TO_CORE_0 + bool "Core 0" + config ESP_WIFI_TASK_PINNED_TO_CORE_1 + bool "Core 1" + endchoice + + config ESP_WIFI_SOFTAP_BEACON_MAX_LEN + int "Max length of WiFi SoftAP Beacon" + range 752 1256 + default 752 + help + ESP-MESH utilizes beacon frames to detect and resolve root node conflicts (see documentation). However + the default length of a beacon frame can simultaneously hold only five root node identifier structures, + meaning that a root node conflict of up to five nodes can be detected at one time. In the occurence of + more root nodes conflict involving more than five root nodes, the conflict resolution process will + detect five of the root nodes, resolve the conflict, and re-detect more root nodes. This process will + repeat until all root node conflicts are resolved. However this process can generally take a very long + time. + + To counter this situation, the beacon frame length can be increased such that more root nodes can be + detected simultaneously. Each additional root node will require 36 bytes and should be added ontop of + the default beacon frame length of + 752 bytes. For example, if you want to detect 10 root nodes simultaneously, you need to set the beacon + frame length as + 932 (752+36*5). + + Setting a longer beacon length also assists with debugging as the conflicting root nodes can be + identified more quickly. + + config ESP_WIFI_MGMT_SBUF_NUM + int "WiFi mgmt short buffer number" + range 6 32 + default 32 + help + Set the number of WiFi management short buffer. + + config ESP_WIFI_IRAM_OPT + bool "WiFi IRAM speed optimization" + default n if (BT_ENABLED && SPIRAM && SLAVE_IDF_TARGET_ESP32) + default y + help + Select this option to place frequently called Wi-Fi library functions in IRAM. + When this option is disabled, more than 10Kbytes of IRAM memory will be saved + but Wi-Fi throughput will be reduced. + + config ESP_WIFI_EXTRA_IRAM_OPT + bool "WiFi EXTRA IRAM speed optimization" + default y if SLAVE_IDF_TARGET_ESP32C6 + default n + help + Select this option to place additional frequently called Wi-Fi library functions + in IRAM. When this option is disabled, more than 5Kbytes of IRAM memory will be saved + but Wi-Fi throughput will be reduced. + + config ESP_WIFI_RX_IRAM_OPT + bool "WiFi RX IRAM speed optimization" + default n if (BT_ENABLED && SPIRAM && SLAVE_IDF_TARGET_ESP32) + default y + help + Select this option to place frequently called Wi-Fi library RX functions in IRAM. + When this option is disabled, more than 17Kbytes of IRAM memory will be saved + but Wi-Fi performance will be reduced. + + config ESP_WIFI_ENABLE_WPA3_SAE + bool "Enable WPA3-Personal" + default y + select ESP_WIFI_MBEDTLS_CRYPTO + help + Select this option to allow the device to establish a WPA3-Personal connection with eligible AP's. + PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be + explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide + for details. + + config ESP_WIFI_ENABLE_SAE_PK + bool "Enable SAE-PK" + default y + depends on ESP_WIFI_ENABLE_WPA3_SAE + help + Select this option to enable SAE-PK + + config ESP_WIFI_SOFTAP_SAE_SUPPORT + bool "Enable WPA3 Personal(SAE) SoftAP" + default y + depends on ESP_WIFI_ENABLE_WPA3_SAE + depends on ESP_WIFI_SOFTAP_SUPPORT + help + Select this option to enable SAE support in softAP mode. + + config ESP_WIFI_ENABLE_WPA3_OWE_STA + bool "Enable OWE STA" + default y + select ESP_WIFI_MBEDTLS_CRYPTO + help + Select this option to allow the device to establish OWE connection with eligible AP's. + PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be + explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide + for details. + + config ESP_WIFI_SLP_IRAM_OPT + bool "WiFi SLP IRAM speed optimization" + select PM_SLP_DEFAULT_PARAMS_OPT + select PERIPH_CTRL_FUNC_IN_IRAM + help + Select this option to place called Wi-Fi library TBTT process and receive beacon functions in IRAM. + Some functions can be put in IRAM either by ESP_WIFI_IRAM_OPT and ESP_WIFI_RX_IRAM_OPT, or this one. + If already enabled ESP_WIFI_IRAM_OPT, the other 7.3KB IRAM memory would be taken by this option. + If already enabled ESP_WIFI_RX_IRAM_OPT, the other 1.3KB IRAM memory would be taken by this option. + If neither of them are enabled, the other 7.4KB IRAM memory would be taken by this option. + Wi-Fi power-save mode average current would be reduced if this option is enabled. + + config ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME + int "Minimum active time" + range 8 60 + default 50 + depends on ESP_WIFI_SLP_IRAM_OPT + help + The minimum timeout for waiting to receive data, unit: milliseconds. + + config ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME + int "Maximum keep alive time" + range 10 60 + default 10 + depends on ESP_WIFI_SLP_IRAM_OPT + help + The maximum time that wifi keep alive, unit: seconds. + + config ESP_WIFI_FTM_ENABLE + bool "WiFi FTM" + default n + depends on SLAVE_SOC_WIFI_FTM_SUPPORT + help + Enable feature Fine Timing Measurement for calculating WiFi Round-Trip-Time (RTT). + + config ESP_WIFI_FTM_INITIATOR_SUPPORT + bool "FTM Initiator support" + default y + depends on ESP_WIFI_FTM_ENABLE + + config ESP_WIFI_FTM_RESPONDER_SUPPORT + bool "FTM Responder support" + default y + depends on ESP_WIFI_FTM_ENABLE + + config ESP_WIFI_STA_DISCONNECTED_PM_ENABLE + bool "Power Management for station at disconnected" + default y + help + Select this option to enable power_management for station when disconnected. + Chip will do modem-sleep when rf module is not in use any more. + + config ESP_WIFI_GCMP_SUPPORT + bool "WiFi GCMP Support(GCMP128 and GCMP256)" + default n + depends on SLAVE_SOC_WIFI_GCMP_SUPPORT + help + Select this option to enable GCMP support. GCMP support is compulsory for WiFi Suite-B support. + + config ESP_WIFI_GMAC_SUPPORT + bool "WiFi GMAC Support(GMAC128 and GMAC256)" + default n + help + Select this option to enable GMAC support. GMAC support is compulsory for WiFi 192 bit certification. + + config ESP_WIFI_SOFTAP_SUPPORT + bool "WiFi SoftAP Support" + default y + help + WiFi module can be compiled without SoftAP to save code size. + + config ESP_WIFI_ENHANCED_LIGHT_SLEEP + bool "WiFi modem automatically receives the beacon" + default n + depends on ESP_PHY_MAC_BB_PD && SOC_PM_SUPPORT_BEACON_WAKEUP + help + The wifi modem automatically receives the beacon frame during light sleep. + + config ESP_WIFI_SLP_BEACON_LOST_OPT + bool "Wifi sleep optimize when beacon lost" + help + Enable wifi sleep optimization when beacon loss occurs and immediately enter + sleep mode when the WiFi module detects beacon loss. + + config ESP_WIFI_SLP_BEACON_LOST_TIMEOUT + int "Beacon loss timeout" + range 5 100 + default 10 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT + help + Timeout time for close rf phy when beacon loss occurs, Unit: 1024 microsecond. + + config ESP_WIFI_SLP_BEACON_LOST_THRESHOLD + int "Maximum number of consecutive lost beacons allowed" + range 0 8 + default 3 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT + help + Maximum number of consecutive lost beacons allowed, WiFi keeps Rx state when + the number of consecutive beacons lost is greater than the given threshold. + + config ESP_WIFI_SLP_PHY_ON_DELTA_EARLY_TIME + int "Delta early time for RF PHY on" + range 0 100 + default 2 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + help + Delta early time for rf phy on, When the beacon is lost, the next rf phy on will + be earlier the time specified by the configuration item, Unit: 32 microsecond. + + config ESP_WIFI_SLP_PHY_OFF_DELTA_TIMEOUT_TIME + int "Delta timeout time for RF PHY off" + range 0 8 + default 2 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW + help + Delta timeout time for rf phy off, When the beacon is lost, the next rf phy off will + be delayed for the time specified by the configuration item. Unit: 1024 microsecond. + + config ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM + int "Maximum espnow encrypt peers number" + range 0 4 if SLAVE_IDF_TARGET_ESP32C2 + range 0 17 if (!SLAVE_IDF_TARGET_ESP32C2) + default 2 if SLAVE_IDF_TARGET_ESP32C2 + default 7 if (!SLAVE_IDF_TARGET_ESP32C2) + help + Maximum number of encrypted peers supported by espnow. + The number of hardware keys for encryption is fixed. And the espnow and SoftAP share the same + hardware keys. So this configuration will affect the maximum connection number of SoftAP. + Maximum espnow encrypted peers number + maximum number of connections of SoftAP = Max hardware + keys number. When using ESP mesh, this value should be set to a maximum of 6. + + config ESP_WIFI_NAN_ENABLE + bool "WiFi Aware" + default n + depends on SLAVE_SOC_WIFI_NAN_SUPPORT + help + Enable WiFi Aware (NAN) feature. + + config ESP_WIFI_ENABLE_WIFI_TX_STATS + bool "Enable Wi-Fi transmission statistics" + depends on SLAVE_SOC_WIFI_HE_SUPPORT + default "y" + help + Enable Wi-Fi transmission statistics. Total support 4 access category. Each access category + will use 346 bytes memory. + + config ESP_WIFI_MBEDTLS_CRYPTO + bool "Use MbedTLS crypto APIs" + default y + select MBEDTLS_AES_C + select MBEDTLS_ECP_C + select MBEDTLS_ECDH_C + select MBEDTLS_ECDSA_C + select MBEDTLS_CMAC_C + select MBEDTLS_ECP_DP_SECP256R1_ENABLED + help + Select this option to enable the use of MbedTLS crypto APIs. + The internal crypto support within the supplicant is limited + and may not suffice for all new security features, including WPA3. + + It is recommended to always keep this option enabled. Additionally, + note that MbedTLS can leverage hardware acceleration if available, + resulting in significantly faster cryptographic operations. + + if ESP_WIFI_MBEDTLS_CRYPTO + config ESP_WIFI_MBEDTLS_TLS_CLIENT + bool "Use MbedTLS TLS client for WiFi Enterprise connection" + depends on ESP_WIFI_ENTERPRISE_SUPPORT + default y + select MBEDTLS_TLS_ENABLED + help + Select this option to use MbedTLS TLS client for WPA2 enterprise connection. + Please note that from MbedTLS-3.0 onwards, MbedTLS does not support SSL-3.0 + TLS-v1.0, TLS-v1.1 versions. Incase your server is using one of these version, + it is advisable to update your server. + Please disable this option for compatibilty with older TLS versions. + endif + + config ESP_WIFI_WAPI_PSK + bool "Enable WAPI PSK support" + depends on SLAVE_SOC_WIFI_WAPI_SUPPORT + default n + help + Select this option to enable WAPI-PSK + which is a Chinese National Standard Encryption for Wireless LANs (GB 15629.11-2003). + + config ESP_WIFI_SUITE_B_192 + bool "Enable NSA suite B support with 192 bit key" + default n + depends on SLAVE_SOC_WIFI_GCMP_SUPPORT + select ESP_WIFI_GCMP_SUPPORT + select ESP_WIFI_GMAC_SUPPORT + help + Select this option to enable 192 bit NSA suite-B. + This is necessary to support WPA3 192 bit security. + + config ESP_WIFI_11KV_SUPPORT + bool "Enable 802.11k, 802.11v APIs Support" + default n + help + Select this option to enable 802.11k 802.11v APIs(RRM and BTM support). + Only APIs which are helpful for network assisted roaming + are supported for now. + Enable this option with BTM and RRM enabled in sta config + to make device ready for network assisted roaming. + BTM: BSS transition management enables an AP to request a station to transition + to a specific AP, or to indicate to a station a set of preferred APs. + RRM: Radio measurements enable STAs to understand the radio environment, + it enables STAs to observe and gather data on radio link performance + and on the radio environment. Current implementation adds beacon report, + link measurement, neighbor report. + + config ESP_WIFI_SCAN_CACHE + bool "Keep scan results in cache" + depends on ESP_WIFI_11KV_SUPPORT + default n + help + Keep scan results in cache, if not enabled, those + will be flushed immediately. + + config ESP_WIFI_MBO_SUPPORT + bool "Enable Multi Band Operation Certification Support" + default n + select ESP_WIFI_11KV_SUPPORT + select ESP_WIFI_SCAN_CACHE + help + Select this option to enable WiFi Multiband operation certification support. + + config ESP_WIFI_DPP_SUPPORT + bool "Enable DPP support" + default n + select ESP_WIFI_MBEDTLS_CRYPTO + help + Select this option to enable WiFi Easy Connect Support. + + config ESP_WIFI_11R_SUPPORT + bool "Enable 802.11R (Fast Transition) Support" + default n + help + Select this option to enable WiFi Fast Transition Support. + + config ESP_WIFI_WPS_SOFTAP_REGISTRAR + bool "Add WPS Registrar support in SoftAP mode" + depends on ESP_WIFI_SOFTAP_SUPPORT + default n + help + Select this option to enable WPS registrar support in softAP mode. + + config ESP_WIFI_ENABLE_WIFI_RX_STATS + bool "Enable Wi-Fi reception statistics" + depends on SLAVE_SOC_WIFI_HE_SUPPORT + default "y" + help + Enable Wi-Fi reception statistics. Total support 2 access category. Each access category + will use 190 bytes memory. + + config ESP_WIFI_ENABLE_WIFI_RX_MU_STATS + bool "Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics" + depends on ESP_WIFI_ENABLE_WIFI_RX_STATS + default "y" + help + Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics. Will use 10932 bytes memory. + + menu "WPS Configuration Options" + config ESP_WIFI_WPS_STRICT + bool "Strictly validate all WPS attributes" + default n + help + Select this option to enable validate each WPS attribute + rigorously. Disabling this add the workaorunds with various APs. + Enabling this may cause inter operability issues with some APs. + + config ESP_WIFI_WPS_PASSPHRASE + bool "Get WPA2 passphrase in WPS config" + default n + help + Select this option to get passphrase during WPS configuration. + This option fakes the virtual display capabilites to get the + configuration in passphrase mode. + Not recommanded to be used since WPS credentials should not + be shared to other devices, making it in readable format increases + that risk, also passphrase requires pbkdf2 to convert in psk. + + endmenu # "WPS Configuration Options" + + + config ESP_WIFI_DEBUG_PRINT + bool "Print debug messages from WPA Supplicant" + default n + help + Select this option to print logging information from WPA supplicant, + this includes handshake information and key hex dumps depending + on the project logging level. + + Enabling this could increase the build size ~60kb + depending on the project logging level. + + config ESP_WIFI_TESTING_OPTIONS + bool "Add DPP testing code" + default n + help + Select this to enable unity test for DPP. + + config ESP_WIFI_ENTERPRISE_SUPPORT + bool "Enable enterprise option" + default y + help + Select this to enable/disable enterprise connection support. + + disabling this will reduce binary size. + disabling this will disable the use of any esp_wifi_sta_wpa2_ent_* (as APIs will be meaningless) + + config ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER + bool "Free dynamic buffers during WiFi enterprise connection" + depends on ESP_WIFI_ENTERPRISE_SUPPORT + default y if SLAVE_IDF_TARGET_ESP32C2 + default n if !SLAVE_IDF_TARGET_ESP32C2 + help + Select this configuration to free dynamic buffers during WiFi enterprise connection. + This will enable chip to reduce heap consumption during WiFi enterprise connection. + +endmenu # Wi-Fi Remote diff --git a/components/esp_wifi_remote/scripts/README.md b/components/esp_wifi_remote/scripts/README.md new file mode 100644 index 0000000000..777b04e2bc --- /dev/null +++ b/components/esp_wifi_remote/scripts/README.md @@ -0,0 +1,38 @@ +# Parsing and generating code + +This folder contains scripts for parsing `esp_wifi` component headers and configs and generates configs, headers and sources of `esp_wifi_remote`. + +The CI job runs the parse and generation step, after which the generated files appear locally in this folder. Then the CI jobs compares the generated files with the specific version files. In case of a mismatch (CI failure), please check if the generated file is correct. If so, update the component and create a new version. If not, update the scripts. + +## Parsing `esp_wifi` headers + +Extract prototypes from the selected wifi headers + +## Generating `Kconfig` + +* Kconfig -- we only replace `SOC_WIFI_` -> `SLAVE_SOC_WIFI_` and `IDF_TARGET_` -> `SLAVE_IDF_TARGET_` configs +* Kconfig.soc_wifi_caps.in -- we parse `IDF/components/soc/$SLAVE/include/soc/Kconfig.soc_caps.in` for all slaves and collect `SOC_WIFI_` configs, which we enclose with `if SLAVE_IDF_TARGET...` ... `endif`. +This way the slave's WiFi capabilities become runtime available in `esp_wifi_remote` submenu + +## Generating headers and forwarding to `esp_hosted` + +Based on extracted WiFi function prototypes we generate + +* `esp_wifi_remote_api.h` -- declares all wifi APIs with `esp_wifi_remote...()` prefix +* `esp_wifi_with_remote.c` -- defines all original wifi APIs that forward calls for `esp_wifi_remote` -- This file is used only for targets with no WiFi capabilities, so the original WiFi APIs could be called the same way as on WiFi targets. (this file is not compiled for targets with WiFi caps) +* `esp_wifi_remote_with_hosted.h` -- defines `static inline` functions that directly forward calls from `esp_wifi_remote` to `esp_hosted` + +## Generating slave's WiFi native types + +* `esp_wifi_types_native.h` -- defines specific WiFi types based on the selected WiFI slave and its capabilities. We use the original header and only replace `CONFIG_SOC_WIFI_` -> `CONFIG_SLAVE_SOC_WIFI_` and `CONFIG_IDF_TARGET_` -> `CONFIG_SLAVE_IDF_TARGET_` configs + +## Generating test cases + +This component includes a simple build-only test that exercises all APIs from `esp_wifi_remote` (and also from `esp_wifi`). The test is also generated by the same script, since we know the function prototypes, so we could tell what parameters we call the exercised APIs. +This test includes a mocked version of the `esp_hosted` component, so the generated files are: + +* `esp_hosted_mock.c` -- all WiFi APIs to just return a default value (typically `ESP_OK`) +* `esp_hosted_mock.h` -- declares all WiFi related APIs +* `Kconfig` -- selection of all SLAVE targets (with WiFi capabilities) +* `all_wifi_calls.c` -- calls all WiFi APIs (to check that targets without WiFi caps can use the original APIs) +* `all_wifi_remote_calls.c` -- calls all remote WiFi APIs (to check that also the targets with WiFi caps can use the remote wifi functionality) diff --git a/components/esp_wifi_remote/scripts/copyright_header.h b/components/esp_wifi_remote/scripts/copyright_header.h new file mode 100644 index 0000000000..f4f626a7cb --- /dev/null +++ b/components/esp_wifi_remote/scripts/copyright_header.h @@ -0,0 +1,6 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +// This file is auto-generated diff --git a/components/esp_wifi_remote/scripts/generate_and_check.py b/components/esp_wifi_remote/scripts/generate_and_check.py new file mode 100644 index 0000000000..c8df5b31a5 --- /dev/null +++ b/components/esp_wifi_remote/scripts/generate_and_check.py @@ -0,0 +1,387 @@ +# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Apache-2.0 +import argparse +import json +import os +import re +import subprocess +from collections import namedtuple + +from idf_build_apps.constants import SUPPORTED_TARGETS +from pycparser import c_ast, c_parser, preprocess_file + +Param = namedtuple('Param', ['ptr', 'array', 'qual', 'type', 'name']) + +AUTO_GENERATED = 'This file is auto-generated' +COPYRIGHT_HEADER = open('copyright_header.h', 'r').read() +NAMESPACE = re.compile(r'^esp_wifi') + + +class FunctionVisitor(c_ast.NodeVisitor): + def __init__(self, header): + self.function_prototypes = {} + self.ptr = 0 + self.array = 0 + self.content = open(header, 'r').read() + + def get_type(self, node, suffix='param'): + if suffix == 'param': + self.ptr = 0 + self.array = 0 + + if isinstance(node.type, c_ast.TypeDecl): + typename = node.type.declname + quals = '' + if node.type.quals: + quals = ' '.join(node.type.quals) + if node.type.type.names: + type = node.type.type.names[0] + return quals, type, typename + if isinstance(node.type, c_ast.PtrDecl): + quals, type, name = self.get_type(node.type, 'ptr') + self.ptr += 1 + return quals, type, name + + if isinstance(node.type, c_ast.ArrayDecl): + quals, type, name = self.get_type(node.type, 'array') + self.array = int(node.type.dim.value) + return quals, type, name + + def visit_FuncDecl(self, node): + if isinstance(node.type, c_ast.TypeDecl): + func_name = node.type.declname + if func_name.startswith('esp_wifi') and func_name in self.content: + ret = node.type.type.names[0] + args = [] + for param in node.args.params: + quals, type, name = self.get_type(param) + param = Param(ptr=self.ptr, array=self.array, qual=quals, type=type, name=name) + args.append(param) + self.function_prototypes[func_name] = (ret, args) + + +# Parse the header file and extract function prototypes +def extract_function_prototypes(header_code, header): + parser = c_parser.CParser() # Set debug parameter to False + ast = parser.parse(header_code) + visitor = FunctionVisitor(header) + visitor.visit(ast) + return visitor.function_prototypes + + +def exec_cmd(what, out_file=None): + p = subprocess.Popen(what, stdin=subprocess.PIPE, stdout=out_file if out_file is not None else subprocess.PIPE, stderr=subprocess.PIPE) + output_b, err_b = p.communicate() + rc = p.returncode + output: str = output_b.decode('utf-8') if output_b is not None else '' + err: str = err_b.decode('utf-8') if err_b is not None else '' + return rc, output, err, ' '.join(what) + + +def preprocess(idf_path, header): + project_dir = os.path.join(idf_path, 'examples', 'get-started', 'blink') + build_dir = os.path.join(project_dir, 'build') + subprocess.check_call(['idf.py', '-B', build_dir, 'reconfigure'], cwd=project_dir) + build_commands_json = os.path.join(build_dir, 'compile_commands.json') + with open(build_commands_json, 'r', encoding='utf-8') as f: + build_command = json.load(f)[0]['command'].split() + include_dir_flags = [] + include_dirs = [] + # process compilation flags (includes and defines) + for item in build_command: + if item.startswith('-I'): + include_dir_flags.append(item) + if 'components' in item: + include_dirs.append(item[2:]) # Removing the leading "-I" + if item.startswith('-D'): + include_dir_flags.append(item.replace('\\','')) # removes escaped quotes, eg: -DMBEDTLS_CONFIG_FILE=\\\"mbedtls/esp_config.h\\\" + include_dir_flags.append('-I' + os.path.join(build_dir, 'config')) + temp_file = 'esp_wifi_preprocessed.h' + with open(temp_file, 'w') as f: + f.write('#define asm\n') + f.write('#define volatile\n') + f.write('#define __asm__\n') + f.write('#define __volatile__\n') + with open(temp_file, 'a') as f: + rc, out, err, cmd = exec_cmd(['xtensa-esp32-elf-gcc', '-w', '-P', '-include', 'ignore_extensions.h', '-E', header] + include_dir_flags, f) + if rc != 0: + print(f'command {cmd} failed!') + print(err) + preprocessed_code = preprocess_file(temp_file) + return preprocessed_code + + +def get_args(parameters): + params = [] + names = [] + for param in parameters: + typename = param.type + if typename == 'void' and param.ptr == 0 and param.name is None: + params.append(f'{typename}') + continue + if param.qual != '': + typename = f'{param.qual} ' + typename + declname = param.name + names.append(f'{declname}') + if param.ptr > 0: + declname = '*' * param.ptr + declname + if param.array > 0: + declname += f'[{param.array}]' + params.append(f'{typename} {declname}') + comma_separated_params = ', '.join(params) + comma_separated_names = ', '.join(names) + return comma_separated_params, comma_separated_names + + +def get_vars(parameters): + definitions = '' + names = [] + for param in parameters: + typename = param.type + if typename == 'void' and param.ptr == 0 and param.name is None: + continue + default_value = '0' + declname = param.name + names.append(f'{declname}') + if param.qual != '': + typename = f'{param.qual} ' + typename + if param.ptr > 0: + declname = '*' * param.ptr + declname + default_value = 'NULL' + if param.array > 0: + declname += f'[{param.array}]' + default_value = '{}' + definitions += f' {typename} {declname} = {default_value};\n' + comma_separated_names = ', '.join(names) + return definitions, comma_separated_names + + +def generate_kconfig_wifi_caps(idf_path, component_path): + kconfig = os.path.join(component_path, 'Kconfig.soc_wifi_caps.in') + sdkconfig_files = [] + with open(kconfig, 'w') as out: + out.write(f'# {AUTO_GENERATED}\n') + for slave_target in SUPPORTED_TARGETS: + out.write(f'\nif SLAVE_IDF_TARGET_{slave_target.upper()}\n\n') + soc_caps = os.path.join(idf_path, 'components', 'soc', slave_target, 'include', 'soc', 'Kconfig.soc_caps.in') + with open(soc_caps, 'r') as f: + for line in f: + if line.strip().startswith('config SOC_WIFI_'): + if 'config SOC_WIFI_SUPPORTED' in line: + # if WiFi supported for this target, test it as a slave + sdkconfig = os.path.join(component_path, 'test', 'smoke_test', f'sdkconfig.ci.slave_{slave_target}') + open(sdkconfig, 'w').write(f'CONFIG_SLAVE_IDF_TARGET_{slave_target.upper()}=y\n') + sdkconfig_files.append(sdkconfig) + replaced = re.compile(r'SOC_WIFI_').sub('SLAVE_SOC_WIFI_', line) + out.write(f' {replaced}') + line = f.readline() # type + out.write(f' {line}') + line = f.readline() # default + out.write(f' {line}\n') + out.write(f'endif # {slave_target.upper()}\n') + return [kconfig] + sdkconfig_files + + +def generate_test_kconfig(component_path): + path = os.path.join(component_path, 'test','smoke_test','components','esp_hosted','Kconfig') + with open(path, 'w') as f: + f.write(f'# {AUTO_GENERATED}\n') + f.write('menu "ESP Hosted Mock"\n') + f.write(' choice SLAVE_IDF_TARGET\n') + f.write(' prompt "choose slave target"\n') + f.write(' default SLAVE_IDF_TARGET_ESP32\n') + for slave_target in SUPPORTED_TARGETS: + config = 'SLAVE_IDF_TARGET_' + slave_target.upper() + f.write(f' config {config}\n') + f.write(f' bool "{slave_target}"\n') + f.write(' endchoice\n') + f.write('endmenu\n') + return [path] + + +def generate_remote_wifi_api(function_prototypes, component_path): + header = os.path.join(component_path, 'include', 'esp_wifi_remote_api.h') + wifi_source = os.path.join(component_path, 'esp_wifi_with_remote.c') + remote_source = os.path.join(component_path, 'esp_wifi_remote_weak.c') + with open(header, 'w') as f: + f.write(COPYRIGHT_HEADER) + f.write('#pragma once\n') + for func_name, args in function_prototypes.items(): + params, _ = get_args(args[1]) + remote_func_name = NAMESPACE.sub('esp_wifi_remote', func_name) + f.write(f'{args[0]} {remote_func_name}({params});\n') + with open(wifi_source, 'w') as wifi, open(remote_source, 'w') as remote: + wifi.write(COPYRIGHT_HEADER) + wifi.write('#include "esp_wifi.h"\n') + wifi.write('#include "esp_wifi_remote.h"\n') + remote.write(COPYRIGHT_HEADER) + remote.write('#include "esp_wifi_remote.h"\n') + remote.write('#include "esp_log.h"\n\n') + remote.write('#define WEAK __attribute__((weak))\n') + remote.write('#define LOG_UNSUPPORTED_AND_RETURN(ret) ESP_LOGW("esp_wifi_remote_weak", "%s unsupported", __func__); \\\n return ret;\n') + for func_name, args in function_prototypes.items(): + remote_func_name = NAMESPACE.sub('esp_wifi_remote', func_name) + params, names = get_args(args[1]) + ret_type = args[0] + ret_value = '-1' # default return value indicating error + if (ret_type == 'esp_err_t'): + ret_value = 'ESP_ERR_NOT_SUPPORTED' + wifi.write(f'\n{args[0]} {func_name}({params})\n') + wifi.write('{\n') + wifi.write(f' return {remote_func_name}({names});\n') + wifi.write('}\n') + remote.write(f'\nWEAK {args[0]} {remote_func_name}({params})\n') + remote.write('{\n') + remote.write(f' LOG_UNSUPPORTED_AND_RETURN({ret_value});\n') + remote.write('}\n') + return [header, wifi_source, remote_source] + + +def generate_hosted_mocks(function_prototypes, component_path): + source = os.path.join(component_path, 'test', 'smoke_test', 'components', 'esp_hosted', 'esp_hosted_mock.c') + header = os.path.join(component_path, 'test', 'smoke_test', 'components', 'esp_hosted', 'include', 'esp_hosted_mock.h') + with open(source, 'w') as f, open(header, 'w') as h: + f.write(COPYRIGHT_HEADER) + h.write(COPYRIGHT_HEADER) + h.write('#pragma once\n') + f.write('#include "esp_wifi.h"\n') + f.write('#include "esp_wifi_remote.h"\n') + for func_name, args in function_prototypes.items(): + hosted_func_name = NAMESPACE.sub('esp_wifi_remote', func_name) + params, names = get_args(args[1]) + ret_type = args[0] + ret_value = '0' # default return value + if (ret_type == 'esp_err_t'): + ret_value = 'ESP_OK' + f.write(f'\n{ret_type} {hosted_func_name}({params})\n') + f.write('{\n') + f.write(f' return {ret_value};\n') + f.write('}\n') + h.write(f'{ret_type} {hosted_func_name}({params});\n') + return [source, header] + + +def generate_test_cases(function_prototypes, component_path): + wifi_cases = os.path.join(component_path, 'test', 'smoke_test', 'main', 'all_wifi_calls.c') + remote_wifi_cases = os.path.join(component_path, 'test', 'smoke_test', 'main', 'all_wifi_remote_calls.c') + with open(wifi_cases, 'w') as wifi, open(remote_wifi_cases, 'w') as remote: + wifi.write(COPYRIGHT_HEADER) + remote.write(COPYRIGHT_HEADER) + wifi.write('#include "esp_wifi.h"\n\n') + remote.write('#include "esp_wifi_remote.h"\n\n') + wifi.write('void run_all_wifi_apis(void)\n{\n') + remote.write('void run_all_wifi_remote_apis(void)\n{\n') + for func_name, args in function_prototypes.items(): + remote_func_name = NAMESPACE.sub('esp_wifi_remote', func_name) + defs, names = get_vars(args[1]) + wifi.write(' {\n') + wifi.write(f'{defs}') + wifi.write(f' {func_name}({names});\n') + wifi.write(' }\n\n') + remote.write(' {\n') + remote.write(f'{defs}') + remote.write(f' {remote_func_name}({names});\n') + remote.write(' }\n\n') + wifi.write('}\n') + remote.write('}\n') + return [wifi_cases, remote_wifi_cases] + + +def generate_wifi_native(idf_path, component_path): + wifi_native = os.path.join(component_path, 'include', 'esp_wifi_types_native.h') + native_header = os.path.join(idf_path, 'components', 'esp_wifi', 'include', 'local', 'esp_wifi_types_native.h') + orig_content = open(native_header, 'r').read() + content = orig_content.replace('CONFIG_','CONFIG_SLAVE_') + open(wifi_native, 'w').write(content) + return [wifi_native] + + +def generate_kconfig(idf_path, component_path): + remote_kconfig = os.path.join(component_path, 'Kconfig') + slave_configs = ['SOC_WIFI_', 'IDF_TARGET_'] + lines = open(os.path.join(idf_path, 'components', 'esp_wifi', 'Kconfig'), 'r').readlines() + copy = 100 # just a big number to be greater than nested_if in the first few iterations + nested_if = 0 + with open(remote_kconfig, 'w') as f: + f.write(f'# {AUTO_GENERATED}\n') + f.write('menu "Wi-Fi Remote"\n') + f.write(' config ESP_WIFI_REMOTE_ENABLED\n') + f.write(' bool\n') + f.write(' default y\n\n') + f.write(' orsource "./Kconfig.soc_wifi_caps.in"\n') + for line1 in lines: + line = line1.strip() + if re.match(r'^if\s+[A-Z_0-9]+\s*$', line): + nested_if += 1 + elif line.startswith('endif'): + nested_if -= 1 + + if nested_if >= copy: + + for config in slave_configs: + line1 = re.compile(config).sub('SLAVE_' + config, line1) + f.write(line1) + + if line.startswith('if ESP_WIFI_ENABLED'): + copy = nested_if + f.write('endmenu # Wi-Fi Remote\n') + return [remote_kconfig] + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description='Build all projects', + formatter_class=argparse.ArgumentDefaultsHelpFormatter, + epilog='''\ +TEST FAILED +----------- +Some of the component files are different from the pregenerated output. +Please check the files that marked as "FAILED" in this step, +typically you'd just need to commit the changes and create a new version. +Please be aware that the pregenerated files use the same copyright header, so after +making changes you might need to modify 'copyright_header.h' in the script directory. + ''') + parser.add_argument('-s', '--skip-check', help='Skip checking the versioned files against the re-generated', action='store_true') + args = parser.parse_args() + + component_path = os.path.normpath(os.path.join(os.path.realpath(__file__),'..', '..')) + idf_path = os.getenv('IDF_PATH') + if idf_path is None: + raise RuntimeError("Environment variable 'IDF_PATH' wasn't set.") + header = os.path.join(idf_path, 'components', 'esp_wifi', 'include', 'esp_wifi.h') + function_prototypes = extract_function_prototypes(preprocess(idf_path, header), header) + + files_to_check = [] + + files_to_check += generate_test_kconfig(component_path) + + files_to_check += generate_kconfig_wifi_caps(idf_path, component_path) + + files_to_check += generate_remote_wifi_api(function_prototypes, component_path) + + files_to_check += generate_hosted_mocks(function_prototypes, component_path) + + files_to_check += generate_test_cases(function_prototypes, component_path) + + files_to_check += generate_wifi_native(idf_path, component_path) + + files_to_check += generate_kconfig(idf_path, component_path) + + fail_test = False + failures = [] + for f in files_to_check: + print(f'checking {f}') + rc, out, err, cmd = exec_cmd(['git', 'difftool', '-y', '-x', 'diff -I Copyright', '--', f]) + if out == '' or out.isspace(): + print(' - ok') + else: + print(' - FAILED!') + failures.append((f, out)) + fail_test = True + + if fail_test: + print(parser.epilog) + print('\nDIfferent files:\n') + for i in failures: + print(f'{i[0]}\nChanges:\n{i[1]}') + exit(1) diff --git a/components/esp_wifi_remote/scripts/ignore_extensions.h b/components/esp_wifi_remote/scripts/ignore_extensions.h new file mode 100644 index 0000000000..f65b3caf42 --- /dev/null +++ b/components/esp_wifi_remote/scripts/ignore_extensions.h @@ -0,0 +1,13 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#define __attribute__(x) +#define __asm__(x) +#define __volatile__(...) +#define volatile(...) +typedef void *__builtin_va_list; +#define __inline__ inline +#define __inline inline +#define __extension__ diff --git a/components/esp_wifi_remote/test/smoke_test/CMakeLists.txt b/components/esp_wifi_remote/test/smoke_test/CMakeLists.txt new file mode 100644 index 0000000000..413711eafb --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/CMakeLists.txt @@ -0,0 +1,8 @@ +# For more information about build system see +# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html +# The following five lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.16) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(smoke_test) diff --git a/components/esp_wifi_remote/test/smoke_test/README.md b/components/esp_wifi_remote/test/smoke_test/README.md new file mode 100644 index 0000000000..900d946a15 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/README.md @@ -0,0 +1,5 @@ +# Smoke (build-only) test + +This test tries to build an application which calls all declared APIs from this component and from `esp_wifi`. +Most of the test code is autogenerated, please see [README.md](../../scripts/README.md) for more details on the generation process. +This test should be build for all combinations of host and slave targets. diff --git a/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/CMakeLists.txt b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/CMakeLists.txt new file mode 100644 index 0000000000..e49536173a --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/CMakeLists.txt @@ -0,0 +1,3 @@ +idf_component_register(SRCS "esp_hosted_mock.c" + INCLUDE_DIRS "include" + REQUIRES esp_wifi esp_wifi_remote) diff --git a/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/Kconfig b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/Kconfig new file mode 100644 index 0000000000..48b4ed62e6 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/Kconfig @@ -0,0 +1,21 @@ +# This file is auto-generated +menu "ESP Hosted Mock" + choice SLAVE_IDF_TARGET + prompt "choose slave target" + default SLAVE_IDF_TARGET_ESP32 + config SLAVE_IDF_TARGET_ESP32 + bool "esp32" + config SLAVE_IDF_TARGET_ESP32S2 + bool "esp32s2" + config SLAVE_IDF_TARGET_ESP32C3 + bool "esp32c3" + config SLAVE_IDF_TARGET_ESP32S3 + bool "esp32s3" + config SLAVE_IDF_TARGET_ESP32C2 + bool "esp32c2" + config SLAVE_IDF_TARGET_ESP32C6 + bool "esp32c6" + config SLAVE_IDF_TARGET_ESP32H2 + bool "esp32h2" + endchoice +endmenu diff --git a/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/esp_hosted_mock.c b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/esp_hosted_mock.c new file mode 100644 index 0000000000..6ae190a660 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/esp_hosted_mock.c @@ -0,0 +1,393 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +// This file is auto-generated +#include "esp_wifi.h" +#include "esp_wifi_remote.h" + +esp_err_t esp_wifi_remote_init(const wifi_init_config_t *config) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_deinit(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_mode(wifi_mode_t *mode) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_start(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_stop(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_restore(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_connect(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_disconnect(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_clear_fast_connect(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_deauth_sta(uint16_t aid) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_scan_start(const wifi_scan_config_t *config, _Bool block) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_scan_stop(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_scan_get_ap_num(uint16_t *number) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_scan_get_ap_record(wifi_ap_record_t *ap_record) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_clear_ap_list(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_sta_get_ap_info(wifi_ap_record_t *ap_info) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_ps(wifi_ps_type_t type) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_ps(wifi_ps_type_t *type) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_channel(uint8_t primary, wifi_second_chan_t second) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_channel(uint8_t *primary, wifi_second_chan_t *second) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_country(const wifi_country_t *country) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_country(wifi_country_t *country) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_mac(wifi_interface_t ifx, const uint8_t mac[6]) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_mac(wifi_interface_t ifx, uint8_t mac[6]) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_promiscuous(_Bool en) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_promiscuous(_Bool *en) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_promiscuous_filter(const wifi_promiscuous_filter_t *filter) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_promiscuous_filter(wifi_promiscuous_filter_t *filter) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *filter) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_config(wifi_interface_t interface, wifi_config_t *conf) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_config(wifi_interface_t interface, wifi_config_t *conf) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_ap_get_sta_list(wifi_sta_list_t *sta) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_vendor_ie(_Bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_max_tx_power(int8_t power) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_max_tx_power(int8_t *power) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_event_mask(uint32_t mask) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_event_mask(uint32_t *mask) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_80211_tx(wifi_interface_t ifx, const void *buffer, int len, _Bool en_sys_seq) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_csi_config(const wifi_csi_config_t *config) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_csi(_Bool en) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_ant_gpio(const wifi_ant_gpio_config_t *config) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_ant_gpio(wifi_ant_gpio_config_t *config) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_ant(const wifi_ant_config_t *config) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_ant(wifi_ant_config_t *config) +{ + return ESP_OK; +} + +int64_t esp_wifi_remote_get_tsf_time(wifi_interface_t interface) +{ + return 0; +} + +esp_err_t esp_wifi_remote_set_inactive_time(wifi_interface_t ifx, uint16_t sec) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_inactive_time(wifi_interface_t ifx, uint16_t *sec) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_statis_dump(uint32_t modules) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_rssi_threshold(int32_t rssi) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_ftm_end_session(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_ftm_resp_set_offset(int16_t offset_cm) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_ftm_get_report(wifi_ftm_report_entry_t *report, uint8_t num_entries) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_config_11b_rate(wifi_interface_t ifx, _Bool disable) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_connectionless_module_set_wake_interval(uint16_t wake_interval) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_force_wakeup_acquire(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_force_wakeup_release(void) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_country_code(const char *country, _Bool ieee80211d_enabled) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_get_country_code(char *country) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_disable_pmf_config(wifi_interface_t ifx) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_sta_get_aid(uint16_t *aid) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_set_dynamic_cs(_Bool enabled) +{ + return ESP_OK; +} + +esp_err_t esp_wifi_remote_sta_get_rssi(int *rssi) +{ + return ESP_OK; +} diff --git a/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/idf_component.yml b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/idf_component.yml new file mode 100644 index 0000000000..2ef3d523ab --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/idf_component.yml @@ -0,0 +1 @@ +version: 1.0.0 diff --git a/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_api.h b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_api.h new file mode 100644 index 0000000000..e1efa1a93b --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_api.h @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ +#pragma once +#include "esp_wifi.h" +#include "esp_hosted_mock.h" +#include "esp_wifi_remote.h" + +#define ESP_HOSTED_CHANNEL_CONFIG_DEFAULT() {} +#define ESP_SERIAL_IF 0 +#define ESP_STA_IF 1 +#define ESP_AP_IF 2 + +struct esp_remote_channel_config { + int if_type; + bool secure; +}; + +esp_remote_channel_t esp_hosted_add_channel(struct esp_remote_channel_config *config, esp_remote_channel_tx_fn_t *tx_cb, esp_remote_channel_rx_fn_t rx_cb); diff --git a/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_mock.h b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_mock.h new file mode 100644 index 0000000000..420aa5e7e9 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_mock.h @@ -0,0 +1,84 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +// This file is auto-generated +#pragma once +esp_err_t esp_wifi_remote_init(const wifi_init_config_t *config); +esp_err_t esp_wifi_remote_deinit(void); +esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode); +esp_err_t esp_wifi_remote_get_mode(wifi_mode_t *mode); +esp_err_t esp_wifi_remote_start(void); +esp_err_t esp_wifi_remote_stop(void); +esp_err_t esp_wifi_remote_restore(void); +esp_err_t esp_wifi_remote_connect(void); +esp_err_t esp_wifi_remote_disconnect(void); +esp_err_t esp_wifi_remote_clear_fast_connect(void); +esp_err_t esp_wifi_remote_deauth_sta(uint16_t aid); +esp_err_t esp_wifi_remote_scan_start(const wifi_scan_config_t *config, _Bool block); +esp_err_t esp_wifi_remote_scan_stop(void); +esp_err_t esp_wifi_remote_scan_get_ap_num(uint16_t *number); +esp_err_t esp_wifi_remote_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records); +esp_err_t esp_wifi_remote_scan_get_ap_record(wifi_ap_record_t *ap_record); +esp_err_t esp_wifi_remote_clear_ap_list(void); +esp_err_t esp_wifi_remote_sta_get_ap_info(wifi_ap_record_t *ap_info); +esp_err_t esp_wifi_remote_set_ps(wifi_ps_type_t type); +esp_err_t esp_wifi_remote_get_ps(wifi_ps_type_t *type); +esp_err_t esp_wifi_remote_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap); +esp_err_t esp_wifi_remote_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap); +esp_err_t esp_wifi_remote_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw); +esp_err_t esp_wifi_remote_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw); +esp_err_t esp_wifi_remote_set_channel(uint8_t primary, wifi_second_chan_t second); +esp_err_t esp_wifi_remote_get_channel(uint8_t *primary, wifi_second_chan_t *second); +esp_err_t esp_wifi_remote_set_country(const wifi_country_t *country); +esp_err_t esp_wifi_remote_get_country(wifi_country_t *country); +esp_err_t esp_wifi_remote_set_mac(wifi_interface_t ifx, const uint8_t mac[6]); +esp_err_t esp_wifi_remote_get_mac(wifi_interface_t ifx, uint8_t mac[6]); +esp_err_t esp_wifi_remote_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb); +esp_err_t esp_wifi_remote_set_promiscuous(_Bool en); +esp_err_t esp_wifi_remote_get_promiscuous(_Bool *en); +esp_err_t esp_wifi_remote_set_promiscuous_filter(const wifi_promiscuous_filter_t *filter); +esp_err_t esp_wifi_remote_get_promiscuous_filter(wifi_promiscuous_filter_t *filter); +esp_err_t esp_wifi_remote_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *filter); +esp_err_t esp_wifi_remote_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter); +esp_err_t esp_wifi_remote_set_config(wifi_interface_t interface, wifi_config_t *conf); +esp_err_t esp_wifi_remote_get_config(wifi_interface_t interface, wifi_config_t *conf); +esp_err_t esp_wifi_remote_ap_get_sta_list(wifi_sta_list_t *sta); +esp_err_t esp_wifi_remote_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid); +esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage); +esp_err_t esp_wifi_remote_set_vendor_ie(_Bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie); +esp_err_t esp_wifi_remote_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx); +esp_err_t esp_wifi_remote_set_max_tx_power(int8_t power); +esp_err_t esp_wifi_remote_get_max_tx_power(int8_t *power); +esp_err_t esp_wifi_remote_set_event_mask(uint32_t mask); +esp_err_t esp_wifi_remote_get_event_mask(uint32_t *mask); +esp_err_t esp_wifi_remote_80211_tx(wifi_interface_t ifx, const void *buffer, int len, _Bool en_sys_seq); +esp_err_t esp_wifi_remote_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx); +esp_err_t esp_wifi_remote_set_csi_config(const wifi_csi_config_t *config); +esp_err_t esp_wifi_remote_set_csi(_Bool en); +esp_err_t esp_wifi_remote_set_ant_gpio(const wifi_ant_gpio_config_t *config); +esp_err_t esp_wifi_remote_get_ant_gpio(wifi_ant_gpio_config_t *config); +esp_err_t esp_wifi_remote_set_ant(const wifi_ant_config_t *config); +esp_err_t esp_wifi_remote_get_ant(wifi_ant_config_t *config); +int64_t esp_wifi_remote_get_tsf_time(wifi_interface_t interface); +esp_err_t esp_wifi_remote_set_inactive_time(wifi_interface_t ifx, uint16_t sec); +esp_err_t esp_wifi_remote_get_inactive_time(wifi_interface_t ifx, uint16_t *sec); +esp_err_t esp_wifi_remote_statis_dump(uint32_t modules); +esp_err_t esp_wifi_remote_set_rssi_threshold(int32_t rssi); +esp_err_t esp_wifi_remote_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg); +esp_err_t esp_wifi_remote_ftm_end_session(void); +esp_err_t esp_wifi_remote_ftm_resp_set_offset(int16_t offset_cm); +esp_err_t esp_wifi_remote_ftm_get_report(wifi_ftm_report_entry_t *report, uint8_t num_entries); +esp_err_t esp_wifi_remote_config_11b_rate(wifi_interface_t ifx, _Bool disable); +esp_err_t esp_wifi_remote_connectionless_module_set_wake_interval(uint16_t wake_interval); +esp_err_t esp_wifi_remote_force_wakeup_acquire(void); +esp_err_t esp_wifi_remote_force_wakeup_release(void); +esp_err_t esp_wifi_remote_set_country_code(const char *country, _Bool ieee80211d_enabled); +esp_err_t esp_wifi_remote_get_country_code(char *country); +esp_err_t esp_wifi_remote_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); +esp_err_t esp_wifi_remote_disable_pmf_config(wifi_interface_t ifx); +esp_err_t esp_wifi_remote_sta_get_aid(uint16_t *aid); +esp_err_t esp_wifi_remote_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode); +esp_err_t esp_wifi_remote_set_dynamic_cs(_Bool enabled); +esp_err_t esp_wifi_remote_sta_get_rssi(int *rssi); diff --git a/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_wifi_api.h b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_wifi_api.h new file mode 100644 index 0000000000..7fd42fb0f0 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/components/esp_hosted/include/esp_hosted_wifi_api.h @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ +#pragma once +#include "esp_wifi.h" +#include "esp_hosted_api.h" diff --git a/components/esp_wifi_remote/test/smoke_test/main/CMakeLists.txt b/components/esp_wifi_remote/test/smoke_test/main/CMakeLists.txt new file mode 100644 index 0000000000..00a81f853b --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/main/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "smoke_test.c" "all_wifi_calls.c" "all_wifi_remote_calls.c" + INCLUDE_DIRS ".") diff --git a/components/esp_wifi_remote/test/smoke_test/main/all_wifi_calls.c b/components/esp_wifi_remote/test/smoke_test/main/all_wifi_calls.c new file mode 100644 index 0000000000..196c4df3e0 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/main/all_wifi_calls.c @@ -0,0 +1,411 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +// This file is auto-generated +#include "esp_wifi.h" + +void run_all_wifi_apis(void) +{ + { + const wifi_init_config_t *config = NULL; + esp_wifi_init(config); + } + + { + esp_wifi_deinit(); + } + + { + wifi_mode_t mode = 0; + esp_wifi_set_mode(mode); + } + + { + wifi_mode_t *mode = NULL; + esp_wifi_get_mode(mode); + } + + { + esp_wifi_start(); + } + + { + esp_wifi_stop(); + } + + { + esp_wifi_restore(); + } + + { + esp_wifi_connect(); + } + + { + esp_wifi_disconnect(); + } + + { + esp_wifi_clear_fast_connect(); + } + + { + uint16_t aid = 0; + esp_wifi_deauth_sta(aid); + } + + { + const wifi_scan_config_t *config = NULL; + _Bool block = 0; + esp_wifi_scan_start(config, block); + } + + { + esp_wifi_scan_stop(); + } + + { + uint16_t *number = NULL; + esp_wifi_scan_get_ap_num(number); + } + + { + uint16_t *number = NULL; + wifi_ap_record_t *ap_records = NULL; + esp_wifi_scan_get_ap_records(number, ap_records); + } + + { + wifi_ap_record_t *ap_record = NULL; + esp_wifi_scan_get_ap_record(ap_record); + } + + { + esp_wifi_clear_ap_list(); + } + + { + wifi_ap_record_t *ap_info = NULL; + esp_wifi_sta_get_ap_info(ap_info); + } + + { + wifi_ps_type_t type = 0; + esp_wifi_set_ps(type); + } + + { + wifi_ps_type_t *type = NULL; + esp_wifi_get_ps(type); + } + + { + wifi_interface_t ifx = 0; + uint8_t protocol_bitmap = 0; + esp_wifi_set_protocol(ifx, protocol_bitmap); + } + + { + wifi_interface_t ifx = 0; + uint8_t *protocol_bitmap = NULL; + esp_wifi_get_protocol(ifx, protocol_bitmap); + } + + { + wifi_interface_t ifx = 0; + wifi_bandwidth_t bw = 0; + esp_wifi_set_bandwidth(ifx, bw); + } + + { + wifi_interface_t ifx = 0; + wifi_bandwidth_t *bw = NULL; + esp_wifi_get_bandwidth(ifx, bw); + } + + { + uint8_t primary = 0; + wifi_second_chan_t second = 0; + esp_wifi_set_channel(primary, second); + } + + { + uint8_t *primary = NULL; + wifi_second_chan_t *second = NULL; + esp_wifi_get_channel(primary, second); + } + + { + const wifi_country_t *country = NULL; + esp_wifi_set_country(country); + } + + { + wifi_country_t *country = NULL; + esp_wifi_get_country(country); + } + + { + wifi_interface_t ifx = 0; + const uint8_t mac[6] = {}; + esp_wifi_set_mac(ifx, mac); + } + + { + wifi_interface_t ifx = 0; + uint8_t mac[6] = {}; + esp_wifi_get_mac(ifx, mac); + } + + { + wifi_promiscuous_cb_t cb = 0; + esp_wifi_set_promiscuous_rx_cb(cb); + } + + { + _Bool en = 0; + esp_wifi_set_promiscuous(en); + } + + { + _Bool *en = NULL; + esp_wifi_get_promiscuous(en); + } + + { + const wifi_promiscuous_filter_t *filter = NULL; + esp_wifi_set_promiscuous_filter(filter); + } + + { + wifi_promiscuous_filter_t *filter = NULL; + esp_wifi_get_promiscuous_filter(filter); + } + + { + const wifi_promiscuous_filter_t *filter = NULL; + esp_wifi_set_promiscuous_ctrl_filter(filter); + } + + { + wifi_promiscuous_filter_t *filter = NULL; + esp_wifi_get_promiscuous_ctrl_filter(filter); + } + + { + wifi_interface_t interface = 0; + wifi_config_t *conf = NULL; + esp_wifi_set_config(interface, conf); + } + + { + wifi_interface_t interface = 0; + wifi_config_t *conf = NULL; + esp_wifi_get_config(interface, conf); + } + + { + wifi_sta_list_t *sta = NULL; + esp_wifi_ap_get_sta_list(sta); + } + + { + const uint8_t mac[6] = {}; + uint16_t *aid = NULL; + esp_wifi_ap_get_sta_aid(mac, aid); + } + + { + wifi_storage_t storage = 0; + esp_wifi_set_storage(storage); + } + + { + _Bool enable = 0; + wifi_vendor_ie_type_t type = 0; + wifi_vendor_ie_id_t idx = 0; + const void *vnd_ie = NULL; + esp_wifi_set_vendor_ie(enable, type, idx, vnd_ie); + } + + { + esp_vendor_ie_cb_t cb = 0; + void *ctx = NULL; + esp_wifi_set_vendor_ie_cb(cb, ctx); + } + + { + int8_t power = 0; + esp_wifi_set_max_tx_power(power); + } + + { + int8_t *power = NULL; + esp_wifi_get_max_tx_power(power); + } + + { + uint32_t mask = 0; + esp_wifi_set_event_mask(mask); + } + + { + uint32_t *mask = NULL; + esp_wifi_get_event_mask(mask); + } + + { + wifi_interface_t ifx = 0; + const void *buffer = NULL; + int len = 0; + _Bool en_sys_seq = 0; + esp_wifi_80211_tx(ifx, buffer, len, en_sys_seq); + } + + { + wifi_csi_cb_t cb = 0; + void *ctx = NULL; + esp_wifi_set_csi_rx_cb(cb, ctx); + } + + { + const wifi_csi_config_t *config = NULL; + esp_wifi_set_csi_config(config); + } + + { + _Bool en = 0; + esp_wifi_set_csi(en); + } + + { + const wifi_ant_gpio_config_t *config = NULL; + esp_wifi_set_ant_gpio(config); + } + + { + wifi_ant_gpio_config_t *config = NULL; + esp_wifi_get_ant_gpio(config); + } + + { + const wifi_ant_config_t *config = NULL; + esp_wifi_set_ant(config); + } + + { + wifi_ant_config_t *config = NULL; + esp_wifi_get_ant(config); + } + + { + wifi_interface_t interface = 0; + esp_wifi_get_tsf_time(interface); + } + + { + wifi_interface_t ifx = 0; + uint16_t sec = 0; + esp_wifi_set_inactive_time(ifx, sec); + } + + { + wifi_interface_t ifx = 0; + uint16_t *sec = NULL; + esp_wifi_get_inactive_time(ifx, sec); + } + + { + uint32_t modules = 0; + esp_wifi_statis_dump(modules); + } + + { + int32_t rssi = 0; + esp_wifi_set_rssi_threshold(rssi); + } + + { + wifi_ftm_initiator_cfg_t *cfg = NULL; + esp_wifi_ftm_initiate_session(cfg); + } + + { + esp_wifi_ftm_end_session(); + } + + { + int16_t offset_cm = 0; + esp_wifi_ftm_resp_set_offset(offset_cm); + } + + { + wifi_ftm_report_entry_t *report = NULL; + uint8_t num_entries = 0; + esp_wifi_ftm_get_report(report, num_entries); + } + + { + wifi_interface_t ifx = 0; + _Bool disable = 0; + esp_wifi_config_11b_rate(ifx, disable); + } + + { + uint16_t wake_interval = 0; + esp_wifi_connectionless_module_set_wake_interval(wake_interval); + } + + { + esp_wifi_force_wakeup_acquire(); + } + + { + esp_wifi_force_wakeup_release(); + } + + { + const char *country = NULL; + _Bool ieee80211d_enabled = 0; + esp_wifi_set_country_code(country, ieee80211d_enabled); + } + + { + char *country = NULL; + esp_wifi_get_country_code(country); + } + + { + wifi_interface_t ifx = 0; + wifi_phy_rate_t rate = 0; + esp_wifi_config_80211_tx_rate(ifx, rate); + } + + { + wifi_interface_t ifx = 0; + esp_wifi_disable_pmf_config(ifx); + } + + { + uint16_t *aid = NULL; + esp_wifi_sta_get_aid(aid); + } + + { + wifi_phy_mode_t *phymode = NULL; + esp_wifi_sta_get_negotiated_phymode(phymode); + } + + { + _Bool enabled = 0; + esp_wifi_set_dynamic_cs(enabled); + } + + { + int *rssi = NULL; + esp_wifi_sta_get_rssi(rssi); + } + +} diff --git a/components/esp_wifi_remote/test/smoke_test/main/all_wifi_remote_calls.c b/components/esp_wifi_remote/test/smoke_test/main/all_wifi_remote_calls.c new file mode 100644 index 0000000000..9b49393dab --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/main/all_wifi_remote_calls.c @@ -0,0 +1,411 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +// This file is auto-generated +#include "esp_wifi_remote.h" + +void run_all_wifi_remote_apis(void) +{ + { + const wifi_init_config_t *config = NULL; + esp_wifi_remote_init(config); + } + + { + esp_wifi_remote_deinit(); + } + + { + wifi_mode_t mode = 0; + esp_wifi_remote_set_mode(mode); + } + + { + wifi_mode_t *mode = NULL; + esp_wifi_remote_get_mode(mode); + } + + { + esp_wifi_remote_start(); + } + + { + esp_wifi_remote_stop(); + } + + { + esp_wifi_remote_restore(); + } + + { + esp_wifi_remote_connect(); + } + + { + esp_wifi_remote_disconnect(); + } + + { + esp_wifi_remote_clear_fast_connect(); + } + + { + uint16_t aid = 0; + esp_wifi_remote_deauth_sta(aid); + } + + { + const wifi_scan_config_t *config = NULL; + _Bool block = 0; + esp_wifi_remote_scan_start(config, block); + } + + { + esp_wifi_remote_scan_stop(); + } + + { + uint16_t *number = NULL; + esp_wifi_remote_scan_get_ap_num(number); + } + + { + uint16_t *number = NULL; + wifi_ap_record_t *ap_records = NULL; + esp_wifi_remote_scan_get_ap_records(number, ap_records); + } + + { + wifi_ap_record_t *ap_record = NULL; + esp_wifi_remote_scan_get_ap_record(ap_record); + } + + { + esp_wifi_remote_clear_ap_list(); + } + + { + wifi_ap_record_t *ap_info = NULL; + esp_wifi_remote_sta_get_ap_info(ap_info); + } + + { + wifi_ps_type_t type = 0; + esp_wifi_remote_set_ps(type); + } + + { + wifi_ps_type_t *type = NULL; + esp_wifi_remote_get_ps(type); + } + + { + wifi_interface_t ifx = 0; + uint8_t protocol_bitmap = 0; + esp_wifi_remote_set_protocol(ifx, protocol_bitmap); + } + + { + wifi_interface_t ifx = 0; + uint8_t *protocol_bitmap = NULL; + esp_wifi_remote_get_protocol(ifx, protocol_bitmap); + } + + { + wifi_interface_t ifx = 0; + wifi_bandwidth_t bw = 0; + esp_wifi_remote_set_bandwidth(ifx, bw); + } + + { + wifi_interface_t ifx = 0; + wifi_bandwidth_t *bw = NULL; + esp_wifi_remote_get_bandwidth(ifx, bw); + } + + { + uint8_t primary = 0; + wifi_second_chan_t second = 0; + esp_wifi_remote_set_channel(primary, second); + } + + { + uint8_t *primary = NULL; + wifi_second_chan_t *second = NULL; + esp_wifi_remote_get_channel(primary, second); + } + + { + const wifi_country_t *country = NULL; + esp_wifi_remote_set_country(country); + } + + { + wifi_country_t *country = NULL; + esp_wifi_remote_get_country(country); + } + + { + wifi_interface_t ifx = 0; + const uint8_t mac[6] = {}; + esp_wifi_remote_set_mac(ifx, mac); + } + + { + wifi_interface_t ifx = 0; + uint8_t mac[6] = {}; + esp_wifi_remote_get_mac(ifx, mac); + } + + { + wifi_promiscuous_cb_t cb = 0; + esp_wifi_remote_set_promiscuous_rx_cb(cb); + } + + { + _Bool en = 0; + esp_wifi_remote_set_promiscuous(en); + } + + { + _Bool *en = NULL; + esp_wifi_remote_get_promiscuous(en); + } + + { + const wifi_promiscuous_filter_t *filter = NULL; + esp_wifi_remote_set_promiscuous_filter(filter); + } + + { + wifi_promiscuous_filter_t *filter = NULL; + esp_wifi_remote_get_promiscuous_filter(filter); + } + + { + const wifi_promiscuous_filter_t *filter = NULL; + esp_wifi_remote_set_promiscuous_ctrl_filter(filter); + } + + { + wifi_promiscuous_filter_t *filter = NULL; + esp_wifi_remote_get_promiscuous_ctrl_filter(filter); + } + + { + wifi_interface_t interface = 0; + wifi_config_t *conf = NULL; + esp_wifi_remote_set_config(interface, conf); + } + + { + wifi_interface_t interface = 0; + wifi_config_t *conf = NULL; + esp_wifi_remote_get_config(interface, conf); + } + + { + wifi_sta_list_t *sta = NULL; + esp_wifi_remote_ap_get_sta_list(sta); + } + + { + const uint8_t mac[6] = {}; + uint16_t *aid = NULL; + esp_wifi_remote_ap_get_sta_aid(mac, aid); + } + + { + wifi_storage_t storage = 0; + esp_wifi_remote_set_storage(storage); + } + + { + _Bool enable = 0; + wifi_vendor_ie_type_t type = 0; + wifi_vendor_ie_id_t idx = 0; + const void *vnd_ie = NULL; + esp_wifi_remote_set_vendor_ie(enable, type, idx, vnd_ie); + } + + { + esp_vendor_ie_cb_t cb = 0; + void *ctx = NULL; + esp_wifi_remote_set_vendor_ie_cb(cb, ctx); + } + + { + int8_t power = 0; + esp_wifi_remote_set_max_tx_power(power); + } + + { + int8_t *power = NULL; + esp_wifi_remote_get_max_tx_power(power); + } + + { + uint32_t mask = 0; + esp_wifi_remote_set_event_mask(mask); + } + + { + uint32_t *mask = NULL; + esp_wifi_remote_get_event_mask(mask); + } + + { + wifi_interface_t ifx = 0; + const void *buffer = NULL; + int len = 0; + _Bool en_sys_seq = 0; + esp_wifi_remote_80211_tx(ifx, buffer, len, en_sys_seq); + } + + { + wifi_csi_cb_t cb = 0; + void *ctx = NULL; + esp_wifi_remote_set_csi_rx_cb(cb, ctx); + } + + { + const wifi_csi_config_t *config = NULL; + esp_wifi_remote_set_csi_config(config); + } + + { + _Bool en = 0; + esp_wifi_remote_set_csi(en); + } + + { + const wifi_ant_gpio_config_t *config = NULL; + esp_wifi_remote_set_ant_gpio(config); + } + + { + wifi_ant_gpio_config_t *config = NULL; + esp_wifi_remote_get_ant_gpio(config); + } + + { + const wifi_ant_config_t *config = NULL; + esp_wifi_remote_set_ant(config); + } + + { + wifi_ant_config_t *config = NULL; + esp_wifi_remote_get_ant(config); + } + + { + wifi_interface_t interface = 0; + esp_wifi_remote_get_tsf_time(interface); + } + + { + wifi_interface_t ifx = 0; + uint16_t sec = 0; + esp_wifi_remote_set_inactive_time(ifx, sec); + } + + { + wifi_interface_t ifx = 0; + uint16_t *sec = NULL; + esp_wifi_remote_get_inactive_time(ifx, sec); + } + + { + uint32_t modules = 0; + esp_wifi_remote_statis_dump(modules); + } + + { + int32_t rssi = 0; + esp_wifi_remote_set_rssi_threshold(rssi); + } + + { + wifi_ftm_initiator_cfg_t *cfg = NULL; + esp_wifi_remote_ftm_initiate_session(cfg); + } + + { + esp_wifi_remote_ftm_end_session(); + } + + { + int16_t offset_cm = 0; + esp_wifi_remote_ftm_resp_set_offset(offset_cm); + } + + { + wifi_ftm_report_entry_t *report = NULL; + uint8_t num_entries = 0; + esp_wifi_remote_ftm_get_report(report, num_entries); + } + + { + wifi_interface_t ifx = 0; + _Bool disable = 0; + esp_wifi_remote_config_11b_rate(ifx, disable); + } + + { + uint16_t wake_interval = 0; + esp_wifi_remote_connectionless_module_set_wake_interval(wake_interval); + } + + { + esp_wifi_remote_force_wakeup_acquire(); + } + + { + esp_wifi_remote_force_wakeup_release(); + } + + { + const char *country = NULL; + _Bool ieee80211d_enabled = 0; + esp_wifi_remote_set_country_code(country, ieee80211d_enabled); + } + + { + char *country = NULL; + esp_wifi_remote_get_country_code(country); + } + + { + wifi_interface_t ifx = 0; + wifi_phy_rate_t rate = 0; + esp_wifi_remote_config_80211_tx_rate(ifx, rate); + } + + { + wifi_interface_t ifx = 0; + esp_wifi_remote_disable_pmf_config(ifx); + } + + { + uint16_t *aid = NULL; + esp_wifi_remote_sta_get_aid(aid); + } + + { + wifi_phy_mode_t *phymode = NULL; + esp_wifi_remote_sta_get_negotiated_phymode(phymode); + } + + { + _Bool enabled = 0; + esp_wifi_remote_set_dynamic_cs(enabled); + } + + { + int *rssi = NULL; + esp_wifi_remote_sta_get_rssi(rssi); + } + +} diff --git a/components/esp_wifi_remote/test/smoke_test/main/idf_component.yml b/components/esp_wifi_remote/test/smoke_test/main/idf_component.yml new file mode 100644 index 0000000000..ecffade569 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/main/idf_component.yml @@ -0,0 +1,8 @@ +## IDF Component Manager Manifest File +dependencies: + ## Required IDF version + idf: + version: "5.3" + espressif/esp_wifi_remote: + version: "*" + override_path: ../../.. diff --git a/components/esp_wifi_remote/test/smoke_test/main/smoke_test.c b/components/esp_wifi_remote/test/smoke_test/main/smoke_test.c new file mode 100644 index 0000000000..190348d4f0 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/main/smoke_test.c @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ +#include +#include "esp_wifi_remote.h" + +void run_all_wifi_apis(void); +void run_all_wifi_remote_apis(void); + +void app_main(void) +{ + // manual init and deinit + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + esp_wifi_init(&cfg); + esp_wifi_deinit(); + + run_all_wifi_apis(); + run_all_wifi_remote_apis(); +} diff --git a/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32 b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32 new file mode 100644 index 0000000000..80649a1d35 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32 @@ -0,0 +1 @@ +CONFIG_SLAVE_IDF_TARGET_ESP32=y diff --git a/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c2 b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c2 new file mode 100644 index 0000000000..e629b66f8c --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c2 @@ -0,0 +1 @@ +CONFIG_SLAVE_IDF_TARGET_ESP32C2=y diff --git a/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c3 b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c3 new file mode 100644 index 0000000000..1c27c1cef4 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c3 @@ -0,0 +1 @@ +CONFIG_SLAVE_IDF_TARGET_ESP32C3=y diff --git a/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c6 b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c6 new file mode 100644 index 0000000000..033f3d81b7 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32c6 @@ -0,0 +1 @@ +CONFIG_SLAVE_IDF_TARGET_ESP32C6=y diff --git a/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32s2 b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32s2 new file mode 100644 index 0000000000..04ac61547c --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32s2 @@ -0,0 +1 @@ +CONFIG_SLAVE_IDF_TARGET_ESP32S2=y diff --git a/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32s3 b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32s3 new file mode 100644 index 0000000000..83c6689650 --- /dev/null +++ b/components/esp_wifi_remote/test/smoke_test/sdkconfig.ci.slave_esp32s3 @@ -0,0 +1 @@ +CONFIG_SLAVE_IDF_TARGET_ESP32S3=y diff --git a/components/esp_wifi_remote/wifi_remote_init.c b/components/esp_wifi_remote/wifi_remote_init.c deleted file mode 100644 index 77be4069a5..0000000000 --- a/components/esp_wifi_remote/wifi_remote_init.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "esp_err.h" -#include "esp_log.h" -#include "esp_hosted_api.h" -#include "esp_wifi_remote.h" -const char *TAG = "esp_remote_wifi_init"; - -esp_err_t remote_esp_wifi_init_slave(void) -{ - ESP_LOGI(TAG, "** %s **", __func__); -#if 0 - if (esp_hosted_setup() != ESP_OK) { - return ESP_FAIL; - } -#endif - esp_remote_channel_tx_fn_t tx_cb; - esp_remote_channel_t ch; - - // Add an RPC channel with default config (i.e. secure=true) - struct esp_remote_channel_config config = ESP_HOSTED_CHANNEL_CONFIG_DEFAULT(); - config.if_type = ESP_SERIAL_IF; - //TODO: add rpc channel from here -//ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_rpc_channel_rx); -// esp_wifi_remote_rpc_channel_set(ch, tx_cb); - - // Add two other channels for the two WiFi interfaces (STA, softAP) in plain text - config.secure = false; - config.if_type = ESP_STA_IF; - ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_channel_rx); - esp_wifi_remote_channel_set(WIFI_IF_STA, ch, tx_cb); - - - config.secure = false; - config.if_type = ESP_AP_IF; - ch = esp_hosted_add_channel(&config, &tx_cb, esp_wifi_remote_channel_rx); - esp_wifi_remote_channel_set(WIFI_IF_AP, ch, tx_cb); - - return ESP_OK; -} diff --git a/components/esp_wifi_remote/wifi_remote_rpc.c b/components/esp_wifi_remote/wifi_remote_rpc.c deleted file mode 100644 index 5f2494dce7..0000000000 --- a/components/esp_wifi_remote/wifi_remote_rpc.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include -#include "esp_log.h" -#include "esp_err.h" -#include "esp_wifi.h" -#include "esp_wifi_remote.h" -#include "esp_hosted_api.h" - -static esp_remote_channel_t s_params_channel; -static esp_remote_channel_tx_fn_t s_params_tx; -static wifi_config_t s_last_wifi_conf; - -esp_err_t esp_wifi_remote_rpc_channel_rx(void *h, void *buffer, size_t len) -{ - if (h == s_params_channel && len == sizeof(s_last_wifi_conf)) { - memcpy(&s_last_wifi_conf, buffer, len); // TODO: use queue - return ESP_OK; - } - return ESP_FAIL; -} - -esp_err_t esp_wifi_remote_rpc_channel_set(void *h, esp_err_t (*tx_cb)(void *, void *, size_t)) -{ - s_params_channel = h; - s_params_tx = tx_cb; - return ESP_OK; -} - -esp_err_t remote_esp_wifi_connect(void) -{ - return esp_hosted_wifi_connect(); -} - -esp_err_t remote_esp_wifi_disconnect(void) -{ - return esp_hosted_wifi_disconnect(); -} - -esp_err_t remote_esp_wifi_init(const wifi_init_config_t *config) -{ - if (remote_esp_wifi_init_slave() != ESP_OK) { - return ESP_FAIL; - } - return esp_hosted_wifi_init(config); -} - -esp_err_t remote_esp_wifi_deinit(void) -{ - return esp_hosted_wifi_deinit(); -} - -esp_err_t remote_esp_wifi_set_mode(wifi_mode_t mode) -{ - return esp_hosted_wifi_set_mode(mode); -} - -esp_err_t remote_esp_wifi_get_mode(wifi_mode_t *mode) -{ - return esp_hosted_wifi_get_mode(mode); -} - -esp_err_t remote_esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) -{ -#if 0 - uint8_t *param = (uint8_t *)conf; - uint32_t checksum = 0; // TODO: generate a random number and add it to both - for (int i = 0; i < sizeof(wifi_config_t); ++i) { - checksum += param[i]; - } - - // transmit the sensitive parameters over a secure channel -// s_params_tx(s_params_channel, param, sizeof(wifi_config_t)); - - // add only a checksum to the RPC - return esp_hosted_wifi_set_config(interface, checksum); -#endif - return esp_hosted_wifi_set_config(interface, conf); -} - -esp_err_t remote_esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf) -{ - return esp_hosted_wifi_get_config(interface, conf); -} - -esp_err_t remote_esp_wifi_start(void) -{ - return esp_hosted_wifi_start(); -} - -esp_err_t remote_esp_wifi_stop(void) -{ - return esp_hosted_wifi_stop(); -} - -esp_err_t remote_esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]) -{ - return esp_hosted_wifi_get_mac(ifx, mac); -} - -esp_err_t remote_esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6]) -{ - return esp_hosted_wifi_set_mac(ifx, mac); -} - -esp_err_t remote_esp_wifi_scan_start(const wifi_scan_config_t *config, bool block) -{ - return esp_hosted_wifi_scan_start(config, block); -} - -esp_err_t remote_esp_wifi_scan_stop(void) -{ - return esp_hosted_wifi_scan_stop(); -} - -esp_err_t remote_esp_wifi_scan_get_ap_num(uint16_t *number) -{ - return esp_hosted_wifi_scan_get_ap_num(number); -} - -esp_err_t remote_esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records) -{ - return esp_hosted_wifi_scan_get_ap_records(number, ap_records); -} - -esp_err_t remote_esp_wifi_clear_ap_list(void) -{ - return esp_hosted_wifi_clear_ap_list(); -} - -esp_err_t remote_esp_wifi_restore(void) -{ - return esp_hosted_wifi_restore(); -} - -esp_err_t remote_esp_wifi_clear_fast_connect(void) -{ - return esp_hosted_wifi_clear_fast_connect(); -} - -esp_err_t remote_esp_wifi_deauth_sta(uint16_t aid) -{ - return esp_hosted_wifi_deauth_sta(aid); -} - -esp_err_t remote_esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info) -{ - return esp_hosted_wifi_sta_get_ap_info(ap_info); -} - -esp_err_t remote_esp_wifi_set_ps(wifi_ps_type_t type) -{ - return esp_hosted_wifi_set_ps(type); -} - -esp_err_t remote_esp_wifi_get_ps(wifi_ps_type_t *type) -{ - return esp_hosted_wifi_get_ps(type); -} - -esp_err_t remote_esp_wifi_set_storage(wifi_storage_t storage) -{ - return esp_hosted_wifi_set_storage(storage); -} - -esp_err_t remote_esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw) -{ - return esp_hosted_wifi_set_bandwidth(ifx, bw); -} - -esp_err_t remote_esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw) -{ - return esp_hosted_wifi_get_bandwidth(ifx, bw); -} - -esp_err_t remote_esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second) -{ - return esp_hosted_wifi_set_channel(primary, second); -} - -esp_err_t remote_esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second) -{ - return esp_hosted_wifi_get_channel(primary, second); -} - -esp_err_t remote_esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled) -{ - return esp_hosted_wifi_set_country_code(country, ieee80211d_enabled); -} - -esp_err_t remote_esp_wifi_get_country_code(char *country) -{ - return esp_hosted_wifi_get_country_code(country); -} - -esp_err_t remote_esp_wifi_set_country(const wifi_country_t *country) -{ - return esp_hosted_wifi_set_country(country); -} - -esp_err_t remote_esp_wifi_get_country(wifi_country_t *country) -{ - return esp_hosted_wifi_get_country(country); -} - -esp_err_t remote_esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta) -{ - return esp_hosted_wifi_ap_get_sta_list(sta); -} - -esp_err_t remote_esp_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid) -{ - return esp_hosted_wifi_ap_get_sta_aid(mac, aid); -} - -esp_err_t remote_esp_wifi_sta_get_rssi(int *rssi) -{ - return esp_hosted_wifi_sta_get_rssi(rssi); -} - -esp_err_t remote_esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap) -{ - return esp_hosted_wifi_set_protocol(ifx, protocol_bitmap); -} - -esp_err_t remote_esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap) -{ - return esp_hosted_wifi_get_protocol(ifx, protocol_bitmap); -} From 16b79d170b9df9ea6b3f5eb94f86f2abcac886eb Mon Sep 17 00:00:00 2001 From: David Cermak Date: Wed, 13 Mar 2024 08:27:55 +0100 Subject: [PATCH 5/6] ci(common): Fix changelog: only add newline for new entries --- ci/changelog.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/changelog.py b/ci/changelog.py index d3e6767ba0..7cf262898e 100644 --- a/ci/changelog.py +++ b/ci/changelog.py @@ -83,13 +83,14 @@ def main(): changelog += '\n### {}\n\n'.format(sections[section]) for it in item: changelog += '- {}\n'.format(it) - changelog += '\n' filename = os.path.join(root_path, 'components', component, 'CHANGELOG.md') # Check if the changelog file exists. if not os.path.exists(filename): # File does not exist, create it with open(filename, 'w') as file: file.write('# Changelog\n\n') + else: + changelog += '\n' # insert the actual changelog to the beginning of the file, just after the title (2nd line) with open(filename, 'r') as orig_changelog: changelog_title = orig_changelog.readline( From d053d671f4a93a51dac1611e327f524e5f5b343c Mon Sep 17 00:00:00 2001 From: David Cermak Date: Wed, 13 Mar 2024 08:28:02 +0100 Subject: [PATCH 6/6] bump(wifi_remote): Initial version 0.1.12 0.1.12 Features - Added generation step for wifi_remote based on IDF (dfb00358) - Move to esp-protocols (edc3c2d) --- components/esp_wifi_remote/CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 components/esp_wifi_remote/CHANGELOG.md diff --git a/components/esp_wifi_remote/CHANGELOG.md b/components/esp_wifi_remote/CHANGELOG.md new file mode 100644 index 0000000000..414e56c2ef --- /dev/null +++ b/components/esp_wifi_remote/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changelog + +## [0.1.12](https://github.com/espressif/esp-protocols/commits/wifi_remote-v0.1.12) + +### Features + +- Added generation step for wifi_remote based on IDF ([dfb00358](https://github.com/espressif/esp-protocols/commit/dfb00358)) +- Move to esp-protocols ([edc3c2d](https://github.com/espressif/esp-protocols/commit/edc3c2d))