├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── helper_project ├── CMakeLists.txt ├── Makefile ├── main │ ├── CMakeLists.txt │ ├── component.mk │ └── helper_project_main.c └── sdkconfig.defaults ├── include ├── esp32 │ ├── esp_bt.h │ ├── phy_init_data.h │ └── sdkconfig.h ├── esp32c3 │ ├── esp_bt.h │ ├── phy_init_data.h │ └── sdkconfig.h ├── esp_coexist.h ├── esp_coexist_adapter.h ├── esp_coexist_internal.h ├── esp_compiler.h ├── esp_err.h ├── esp_event.h ├── esp_event_base.h ├── esp_event_legacy.h ├── esp_interface.h ├── esp_phy_init.h ├── esp_private │ ├── esp_wifi_private.h │ ├── esp_wifi_types_private.h │ ├── wifi.h │ ├── wifi_os_adapter.h │ └── wifi_types.h ├── esp_smartconfig.h ├── esp_system.h ├── esp_timer.h ├── esp_wifi.h ├── esp_wifi_crypto_types.h ├── esp_wifi_default.h ├── esp_wifi_types.h ├── esp_wpa.h ├── esp_wpa2.h ├── espidf_types.h ├── espidf_wifi.h ├── nvs.h └── phy.h ├── libs ├── esp32 │ ├── libbtdm_app.a │ ├── libcoexist.a │ ├── libcore.a │ ├── libespnow.a │ ├── libmesh.a │ ├── libnet80211.a │ ├── libphy.a │ ├── libpp.a │ ├── librtc.a │ ├── libsmartconfig.a │ ├── libwapi.a │ └── libwpa_supplicant.a └── esp32c3 │ ├── libbtbb.a │ ├── libbtdm_app.a │ ├── libcoexist.a │ ├── libcore.a │ ├── libespnow.a │ ├── libmesh.a │ ├── libnet80211.a │ ├── libphy.a │ ├── libpp.a │ ├── libsmartconfig.a │ ├── libwapi.a │ └── libwpa_supplicant.a ├── patch ├── esp32 │ └── sdkconfig.h ├── esp32c3 │ └── sdkconfig.h ├── espidf_types.h └── espidf_wifi.h └── version /.gitignore: -------------------------------------------------------------------------------- 1 | .config 2 | *.o 3 | *.pyc 4 | 5 | # gtags 6 | GTAGS 7 | GRTAGS 8 | GPATH 9 | 10 | # emacs 11 | .dir-locals.el 12 | 13 | # emacs temp file suffixes 14 | *~ 15 | .#* 16 | \#*# 17 | 18 | # eclipse setting 19 | .settings 20 | 21 | # MacOS directory files 22 | .DS_Store 23 | 24 | # Example project files 25 | helper_project/sdkconfig 26 | helper_project/sdkconfig.old 27 | helper_project/build 28 | 29 | # VS Code Settings 30 | .vscode/ 31 | 32 | # VIM files 33 | *.swp 34 | *.swo 35 | 36 | # ESP-IDF default build directory name 37 | build 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2020 idf / apache 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(EXAMPLE), ) 2 | EXAMPLE := helper_project 3 | endif 4 | 5 | ifeq ($(SOC), ) 6 | SOC := esp32 7 | endif 8 | 9 | # $(1): Files list with path 10 | # $(2): Target directory 11 | define copy_files 12 | $(foreach f,$(1),cp $(f) $(2) && ) . 13 | endef 14 | 15 | # $(1): File with path 16 | # $(2): Stripped macros list in file 17 | define strip_macros 18 | $(foreach m,$(2),sed -i "/$(m)/d" $(1) &&) . 19 | endef 20 | 21 | PRJ_DIR := $(shell pwd) 22 | IDF_VER_T := $(shell cd ${IDF_PATH} && \ 23 | git describe --always --tags --dirty && \ 24 | git log -n 1 | grep "commit") 25 | 26 | # Local options 27 | 28 | VERISON_FILE := version 29 | 30 | INCS_DIR := $(PRJ_DIR)/include 31 | LIBS_DIR := $(PRJ_DIR)/libs/$(SOC) 32 | SOC_INCS_DIR := $(PRJ_DIR)/include/$(SOC) 33 | 34 | # SoC 35 | 36 | SOC_HFS := $(IDF_PATH)/components/esp_wifi/$(SOC)/include/phy_init_data.h 37 | 38 | ifeq ($(SOC), esp32) 39 | SDKCONFIG_RMS := CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ \ 40 | CONFIG_ESP32_TRACEMEM_RESERVE_DRAM \ 41 | CONFIG_PTHREAD_STACK_MIN 42 | else ifeq ($(SOC), esp32c3) 43 | SDKCONFIG_RMS := CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ \ 44 | CONFIG_PTHREAD_STACK_MIN 45 | else 46 | $(error soc=$(SOC) is not supported) 47 | endif 48 | 49 | # Libs 50 | 51 | IDF_COMPONENTS := wpa_supplicant 52 | GEN_LIBS := $(foreach c,$(IDF_COMPONENTS),$(PRJ_DIR)/$(EXAMPLE)/build/esp-idf/$(c)/lib$(c).a) 53 | WIFI_LIBS := $(IDF_PATH)/components/esp_wifi/lib/$(SOC)/* 54 | ifeq ($(SOC), esp32) 55 | BT_LIBS := $(IDF_PATH)/components/bt/controller/lib_esp32/esp32/* 56 | else ifeq ($(SOC), esp32c3) 57 | BT_LIBS := $(IDF_PATH)/components/bt/controller/lib_esp32c3_family/esp32c3/* 58 | else 59 | $(error "No BT libraries") 60 | endif 61 | IDF_LIBS := $(GEN_LIBS) $(WIFI_LIBS) $(BT_LIBS) 62 | 63 | # Types 64 | 65 | TYPES_DIR := patch 66 | TYPES_HFS := $(TYPES_DIR)/espidf_types.h \ 67 | $(TYPES_DIR)/espidf_wifi.h 68 | 69 | # Wi-Fi 70 | 71 | WIFI_DIR := $(IDF_PATH)/components/esp_wifi/include 72 | WIFI_SRC_HFS := $(WIFI_DIR)/esp_wifi.h \ 73 | $(WIFI_DIR)/esp_wifi_default.h \ 74 | $(WIFI_DIR)/esp_phy_init.h \ 75 | $(WIFI_DIR)/esp_wifi_types.h \ 76 | $(WIFI_DIR)/phy.h \ 77 | $(WIFI_DIR)/esp_wifi_crypto_types.h \ 78 | $(WIFI_DIR)/esp_smartconfig.h \ 79 | $(WIFI_DIR)/esp_coexist_adapter.h \ 80 | $(WIFI_DIR)/esp_coexist_internal.h \ 81 | $(WIFI_DIR)/esp_coexist.h 82 | 83 | # Wi-Fi Private 84 | 85 | WIFI_PRIV_DIR := $(WIFI_DIR)/esp_private 86 | WIFI_PRIV_DST_DIR := $(INCS_DIR)/esp_private 87 | WIFI_PRIV_SRC_HFS := $(WIFI_PRIV_DIR)/wifi_os_adapter.h \ 88 | $(WIFI_PRIV_DIR)/wifi.h \ 89 | $(WIFI_PRIV_DIR)/esp_wifi_types_private.h \ 90 | $(WIFI_PRIV_DIR)/esp_wifi_private.h \ 91 | $(WIFI_PRIV_DIR)/wifi_types.h 92 | 93 | WIFI_PRIV_WIFI_DST_HF := $(WIFI_PRIV_DST_DIR)/wifi.h 94 | WIFI_PRIV_WIFI_HF_RMS := freertos\/queue.h \ 95 | freertos\/FreeRTOS.h 96 | 97 | WIFI_PRIV_WIFI_PRIV_DST_HF := $(WIFI_PRIV_DST_DIR)/esp_wifi_private.h 98 | WIFI_PRIV_WIFI_PRIV_HF_RMS := freertos\/queue.h \ 99 | freertos\/FreeRTOS.h 100 | 101 | # Common 102 | COMMON_DIR := $(IDF_PATH)/components/esp_common/include 103 | COMMON_SRC_HFS := $(COMMON_DIR)/esp_err.h \ 104 | $(COMMON_DIR)/esp_compiler.h \ 105 | $(COMMON_DIR)/esp_interface.h 106 | 107 | # Event 108 | EVENT_DIR := $(IDF_PATH)/components/esp_event/include 109 | EVENT_SRC_HFS := $(EVENT_DIR)/esp_event_base.h \ 110 | $(EVENT_DIR)/esp_event.h \ 111 | $(EVENT_DIR)/esp_event_legacy.h 112 | 113 | EVENT_DST_HF := $(INCS_DIR)/esp_event.h 114 | EVENT_DST_RM := freertos\/FreeRTOS.h \ 115 | freertos\/task.h \ 116 | freertos\/queue.h \ 117 | freertos\/semphr.h 118 | 119 | EVENT_LEGACY_DST_HF := $(INCS_DIR)/esp_event_legacy.h 120 | EVENT_LEGACY_HF_RMS := esp_netif.h \ 121 | system_event_ap_staipassigned_t \ 122 | system_event_sta_got_ip_t \ 123 | system_event_got_ip6_t 124 | 125 | # NVS 126 | NVS_DIR := $(IDF_PATH)/components/nvs_flash/include 127 | NVS_SRC_HF := $(NVS_DIR)/nvs.h 128 | 129 | NVS_DST_HF := $(INCS_DIR)/nvs.h 130 | NVS_HF_RMS := esp_attr.h 131 | 132 | # WPA 133 | WPA_DIR := $(IDF_PATH)/components/wpa_supplicant/include/esp_supplicant 134 | WPA_SRC_HFS := $(WPA_DIR)/esp_wpa.h \ 135 | $(WPA_DIR)/esp_wpa2.h 136 | # ESP_Timer 137 | ESPTIMER_DIR := $(IDF_PATH)/components/esp_timer/include 138 | ESPTIMER_SRC_HF := $(ESPTIMER_DIR)/esp_timer.h 139 | 140 | # ESP_System 141 | ESPSYSTEM_DIR := $(IDF_PATH)/components/esp_system/include 142 | ESPSYSTEM_SRC_HF := $(ESPSYSTEM_DIR)/esp_system.h 143 | 144 | ESPSYSTEM_DST_HF := $(INCS_DIR)/esp_system.h 145 | ESPSYSTEM_HF_RMS := esp_attr.h \ 146 | esp_bit_defs.h \ 147 | esp_idf_version.h 148 | 149 | # SDKCONFIG 150 | SDKCONFIG_DST_HF := $(SOC_INCS_DIR)/sdkconfig.h 151 | SDKCONFIG_SRC_HF := $(PRJ_DIR)/$(EXAMPLE)/build/config/sdkconfig.h 152 | SDKCONFIG_PTH_HF := $(PRJ_DIR)/patch/$(SOC)/sdkconfig.h 153 | 154 | # BT/BLE 155 | BT_SRC_HF := $(IDF_PATH)/components/bt/include/$(SOC)/include/esp_bt.h 156 | BT_DST_HF := $(SOC_INCS_DIR)/esp_bt.h 157 | BT_HF_RMS := esp_task.h 158 | 159 | .PHONY: all clean build copy_libs copy_hfiles 160 | 161 | all: copy_libs copy_hfiles 162 | @echo $(IDF_VER_T) > $(VERISON_FILE) 163 | 164 | clean: 165 | @cd $(PRJ_DIR)/$(EXAMPLE) && rm build sdkconfig sdkconfig.old -rf 166 | @rm $(LIBS_DIR) $(INCS_DIR) $(SOC_INCS_DIR) -rf 167 | 168 | build: 169 | @cd $(PRJ_DIR)/$(EXAMPLE) && rm build sdkconfig sdkconfig.old -rf && idf.py -DIDF_TARGET=$(SOC) build 170 | 171 | copy_libs: build 172 | @mkdir -p $(LIBS_DIR) 173 | @$(call copy_files,$(IDF_LIBS),$(LIBS_DIR)) 174 | 175 | inc_dirs: build 176 | @mkdir -p $(INCS_DIR) 177 | 178 | config_files: inc_dirs 179 | @$(call copy_files,$(TYPES_HFS),$(INCS_DIR)) 180 | 181 | wifi_files: inc_dirs 182 | @mkdir -p $(INCS_DIR)/esp_private 183 | @$(call copy_files,$(WIFI_SRC_HFS),$(INCS_DIR)) 184 | @$(call copy_files,$(WIFI_PRIV_SRC_HFS),$(WIFI_PRIV_DST_DIR)) 185 | @$(call strip_macros,$(WIFI_PRIV_WIFI_DST_HF),$(WIFI_PRIV_WIFI_HF_RMS)) 186 | @$(call strip_macros,$(WIFI_PRIV_WIFI_PRIV_DST_HF),$(WIFI_PRIV_WIFI_PRIV_HF_RMS)) 187 | 188 | common_files: inc_dirs 189 | @$(call copy_files,$(COMMON_SRC_HFS),$(INCS_DIR)) 190 | 191 | event_files: 192 | @$(call copy_files,$(EVENT_SRC_HFS),$(INCS_DIR)) 193 | @$(call strip_macros,$(EVENT_DST_HF),$(EVENT_DST_RM)) 194 | @$(call strip_macros,$(EVENT_LEGACY_DST_HF),$(EVENT_LEGACY_HF_RMS)) 195 | 196 | nvs_files: 197 | @$(call copy_files,$(NVS_SRC_HF),$(INCS_DIR)) 198 | @$(call strip_macros,$(NVS_DST_HF),$(NVS_HF_RMS)) 199 | 200 | wpa_files: 201 | @$(call copy_files,$(WPA_SRC_HFS),$(INCS_DIR)) 202 | 203 | esptimer_files: 204 | @$(call copy_files,$(ESPTIMER_SRC_HF),$(INCS_DIR)) 205 | 206 | espsystem_files: 207 | @$(call copy_files,$(ESPSYSTEM_SRC_HF),$(INCS_DIR)) 208 | @$(call strip_macros,$(ESPSYSTEM_DST_HF),$(ESPSYSTEM_HF_RMS)) 209 | 210 | soc_files: 211 | @mkdir -p $(SOC_INCS_DIR) 212 | @$(call copy_files,$(SOC_HFS),$(SOC_INCS_DIR)) 213 | @cp $(SDKCONFIG_SRC_HF) $(SOC_INCS_DIR) 214 | @cat $(SDKCONFIG_PTH_HF) >> $(SDKCONFIG_DST_HF) 215 | @$(call strip_macros,$(SDKCONFIG_DST_HF),$(SDKCONFIG_RMS)) 216 | 217 | bt_files: 218 | @mkdir -p $(SOC_INCS_DIR) 219 | @$(call copy_files,$(BT_SRC_HF),$(SOC_INCS_DIR)) 220 | @$(call strip_macros,$(BT_DST_HF),$(BT_HF_RMS)) 221 | 222 | copy_hfiles: config_files wifi_files common_files event_files \ 223 | wpa_files nvs_files esptimer_files espsystem_files \ 224 | soc_files bt_files 225 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Espressif Wireless Framework 2 | 3 | ## Introduction 4 | 5 | This project is used to integrate ESP32 family SoC's wireless software drivers into other platforms, like NuttX. 6 | 7 | Wireless software drivers mainly contains of hardware drivers, wireless protocols and utils. 8 | 9 | ## Update Software of Wireless Framework 10 | 11 | 1. setup compiling environment by `. ./export.sh` in esp-idf directory 12 | 13 | 2. in the root directory of this project, input command `make` to recompile `helper_project` to generate new libraries and header files 14 | 15 | 3. file of `version` in the root directory mark the esp-idf's version 16 | -------------------------------------------------------------------------------- /helper_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(helper_project) -------------------------------------------------------------------------------- /helper_project/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := helper_project 7 | 8 | include $(IDF_PATH)/make/project.mk 9 | 10 | -------------------------------------------------------------------------------- /helper_project/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "helper_project_main.c" 2 | INCLUDE_DIRS "") -------------------------------------------------------------------------------- /helper_project/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # "main" pseudo-component makefile. 3 | # 4 | # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) 5 | 6 | -------------------------------------------------------------------------------- /helper_project/main/helper_project_main.c: -------------------------------------------------------------------------------- 1 | /* Base Example 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #include 11 | #include "sdkconfig.h" 12 | 13 | void app_main(void) 14 | { 15 | printf("Helper project!\n"); 16 | } 17 | -------------------------------------------------------------------------------- /helper_project/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_BT_ENABLED=y 2 | -------------------------------------------------------------------------------- /include/esp32/esp_bt.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef __ESP_BT_H__ 16 | #define __ESP_BT_H__ 17 | 18 | #include 19 | #include 20 | #include "esp_err.h" 21 | #include "sdkconfig.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20200622 28 | 29 | /** 30 | * @brief Bluetooth mode for controller enable/disable 31 | */ 32 | typedef enum { 33 | ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */ 34 | ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */ 35 | ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */ 36 | ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */ 37 | } esp_bt_mode_t; 38 | 39 | /** 40 | * @brief BLE sleep clock accuracy(SCA), values for ble_sca field in esp_bt_controller_config_t, 41 | * currently only ESP_BLE_SCA_500PPM and ESP_BLE_SCA_250PPM are supported 42 | */ 43 | enum { 44 | ESP_BLE_SCA_500PPM = 0, /*!< BLE SCA at 500ppm */ 45 | ESP_BLE_SCA_250PPM, /*!< BLE SCA at 250ppm */ 46 | ESP_BLE_SCA_150PPM, /*!< BLE SCA at 150ppm */ 47 | ESP_BLE_SCA_100PPM, /*!< BLE SCA at 100ppm */ 48 | ESP_BLE_SCA_75PPM, /*!< BLE SCA at 75ppm */ 49 | ESP_BLE_SCA_50PPM, /*!< BLE SCA at 50ppm */ 50 | ESP_BLE_SCA_30PPM, /*!< BLE SCA at 30ppm */ 51 | ESP_BLE_SCA_20PPM, /*!< BLE SCA at 20ppm */ 52 | }; 53 | 54 | #ifdef CONFIG_BT_ENABLED 55 | /* While scanning, if the free memory value in controller is less than SCAN_SEND_ADV_RESERVED_SIZE, 56 | the adv packet will be discarded until the memory is restored. */ 57 | #define SCAN_SEND_ADV_RESERVED_SIZE 1000 58 | /* enable controller log debug when adv lost */ 59 | #define CONTROLLER_ADV_LOST_DEBUG_BIT (0<<0) 60 | 61 | #ifdef CONFIG_BTDM_CTRL_HCI_UART_NO 62 | #define BT_HCI_UART_NO_DEFAULT CONFIG_BTDM_CTRL_HCI_UART_NO 63 | #else 64 | #define BT_HCI_UART_NO_DEFAULT 1 65 | #endif /* BT_HCI_UART_NO_DEFAULT */ 66 | 67 | #ifdef CONFIG_BTDM_CTRL_HCI_UART_BAUDRATE 68 | #define BT_HCI_UART_BAUDRATE_DEFAULT CONFIG_BTDM_CTRL_HCI_UART_BAUDRATE 69 | #else 70 | #define BT_HCI_UART_BAUDRATE_DEFAULT 921600 71 | #endif /* BT_HCI_UART_BAUDRATE_DEFAULT */ 72 | 73 | #ifdef CONFIG_BTDM_SCAN_DUPL_TYPE 74 | #define SCAN_DUPLICATE_TYPE_VALUE CONFIG_BTDM_SCAN_DUPL_TYPE 75 | #else 76 | #define SCAN_DUPLICATE_TYPE_VALUE 0 77 | #endif 78 | 79 | /* normal adv cache size */ 80 | #ifdef CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE 81 | #define NORMAL_SCAN_DUPLICATE_CACHE_SIZE CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE 82 | #else 83 | #define NORMAL_SCAN_DUPLICATE_CACHE_SIZE 20 84 | #endif 85 | 86 | #ifndef CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN 87 | #define CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN FALSE 88 | #endif 89 | 90 | #define SCAN_DUPLICATE_MODE_NORMAL_ADV_ONLY 0 91 | #define SCAN_DUPLICATE_MODE_NORMAL_ADV_MESH_ADV 1 92 | 93 | #if CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN 94 | #define SCAN_DUPLICATE_MODE SCAN_DUPLICATE_MODE_NORMAL_ADV_MESH_ADV 95 | #ifdef CONFIG_BTDM_MESH_DUPL_SCAN_CACHE_SIZE 96 | #define MESH_DUPLICATE_SCAN_CACHE_SIZE CONFIG_BTDM_MESH_DUPL_SCAN_CACHE_SIZE 97 | #else 98 | #define MESH_DUPLICATE_SCAN_CACHE_SIZE 50 99 | #endif 100 | #else 101 | #define SCAN_DUPLICATE_MODE SCAN_DUPLICATE_MODE_NORMAL_ADV_ONLY 102 | #define MESH_DUPLICATE_SCAN_CACHE_SIZE 0 103 | #endif 104 | 105 | #if defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY) 106 | #define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BLE 107 | #elif defined(CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY) 108 | #define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_CLASSIC_BT 109 | #else 110 | #define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BTDM 111 | #endif 112 | 113 | #ifdef CONFIG_BTDM_CTRL_AUTO_LATENCY_EFF 114 | #define BTDM_CTRL_AUTO_LATENCY_EFF CONFIG_BTDM_CTRL_AUTO_LATENCY_EFF 115 | #else 116 | #define BTDM_CTRL_AUTO_LATENCY_EFF false 117 | #endif 118 | 119 | #ifdef CONFIG_BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF 120 | #define BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF CONFIG_BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF 121 | #else 122 | #define BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF false 123 | #endif 124 | 125 | #define BTDM_CONTROLLER_BLE_MAX_CONN_LIMIT 9 //Maximum BLE connection limitation 126 | #define BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_LIMIT 7 //Maximum ACL connection limitation 127 | #define BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_LIMIT 3 //Maximum SCO/eSCO connection limitation 128 | 129 | #define BTDM_CONTROLLER_SCO_DATA_PATH_HCI 0 // SCO data is routed to HCI 130 | #define BTDM_CONTROLLER_SCO_DATA_PATH_PCM 1 // SCO data path is PCM 131 | 132 | #define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \ 133 | .controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \ 134 | .controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \ 135 | .hci_uart_no = BT_HCI_UART_NO_DEFAULT, \ 136 | .hci_uart_baudrate = BT_HCI_UART_BAUDRATE_DEFAULT, \ 137 | .scan_duplicate_mode = SCAN_DUPLICATE_MODE, \ 138 | .scan_duplicate_type = SCAN_DUPLICATE_TYPE_VALUE, \ 139 | .normal_adv_size = NORMAL_SCAN_DUPLICATE_CACHE_SIZE, \ 140 | .mesh_adv_size = MESH_DUPLICATE_SCAN_CACHE_SIZE, \ 141 | .send_adv_reserved_size = SCAN_SEND_ADV_RESERVED_SIZE, \ 142 | .controller_debug_flag = CONTROLLER_ADV_LOST_DEBUG_BIT, \ 143 | .mode = BTDM_CONTROLLER_MODE_EFF, \ 144 | .ble_max_conn = CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF, \ 145 | .bt_max_acl_conn = CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF, \ 146 | .bt_sco_datapath = CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF, \ 147 | .auto_latency = BTDM_CTRL_AUTO_LATENCY_EFF, \ 148 | .bt_legacy_auth_vs_evt = BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF, \ 149 | .bt_max_sync_conn = CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF, \ 150 | .ble_sca = CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF, \ 151 | .pcm_role = CONFIG_BTDM_CTRL_PCM_ROLE_EFF, \ 152 | .pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \ 153 | .magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \ 154 | }; 155 | 156 | #else 157 | #define BT_CONTROLLER_INIT_CONFIG_DEFAULT() {0}; _Static_assert(0, "please enable bluetooth in menuconfig to use bt.h"); 158 | #endif 159 | 160 | /** 161 | * @brief Controller config options, depend on config mask. 162 | * Config mask indicate which functions enabled, this means 163 | * some options or parameters of some functions enabled by config mask. 164 | */ 165 | typedef struct { 166 | /* 167 | * Following parameters can be configured runtime, when call esp_bt_controller_init() 168 | */ 169 | uint16_t controller_task_stack_size; /*!< Bluetooth controller task stack size */ 170 | uint8_t controller_task_prio; /*!< Bluetooth controller task priority */ 171 | uint8_t hci_uart_no; /*!< If use UART1/2 as HCI IO interface, indicate UART number */ 172 | uint32_t hci_uart_baudrate; /*!< If use UART1/2 as HCI IO interface, indicate UART baudrate */ 173 | uint8_t scan_duplicate_mode; /*!< scan duplicate mode */ 174 | uint8_t scan_duplicate_type; /*!< scan duplicate type */ 175 | uint16_t normal_adv_size; /*!< Normal adv size for scan duplicate */ 176 | uint16_t mesh_adv_size; /*!< Mesh adv size for scan duplicate */ 177 | uint16_t send_adv_reserved_size; /*!< Controller minimum memory value */ 178 | uint32_t controller_debug_flag; /*!< Controller debug log flag */ 179 | uint8_t mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */ 180 | uint8_t ble_max_conn; /*!< BLE maximum connection numbers */ 181 | uint8_t bt_max_acl_conn; /*!< BR/EDR maximum ACL connection numbers */ 182 | uint8_t bt_sco_datapath; /*!< SCO data path, i.e. HCI or PCM module */ 183 | bool auto_latency; /*!< BLE auto latency, used to enhance classic BT performance */ 184 | bool bt_legacy_auth_vs_evt; /*!< BR/EDR Legacy auth complete event required to protect from BIAS attack */ 185 | /* 186 | * Following parameters can not be configured runtime when call esp_bt_controller_init() 187 | * It will be overwrite with a constant value which in menuconfig or from a macro. 188 | * So, do not modify the value when esp_bt_controller_init() 189 | */ 190 | uint8_t bt_max_sync_conn; /*!< BR/EDR maximum ACL connection numbers. Effective in menuconfig */ 191 | uint8_t ble_sca; /*!< BLE low power crystal accuracy index */ 192 | uint8_t pcm_role; /*!< PCM role (master & slave)*/ 193 | uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge) */ 194 | uint32_t magic; /*!< Magic number */ 195 | } esp_bt_controller_config_t; 196 | 197 | /** 198 | * @brief Bluetooth controller enable/disable/initialised/de-initialised status 199 | */ 200 | typedef enum { 201 | ESP_BT_CONTROLLER_STATUS_IDLE = 0, 202 | ESP_BT_CONTROLLER_STATUS_INITED, 203 | ESP_BT_CONTROLLER_STATUS_ENABLED, 204 | ESP_BT_CONTROLLER_STATUS_NUM, 205 | } esp_bt_controller_status_t; 206 | 207 | /** 208 | * @brief BLE tx power type 209 | * ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connection completed. 210 | * when disconnect, the correspond TX power is not effected. 211 | * ESP_BLE_PWR_TYPE_ADV : for advertising/scan response. 212 | * ESP_BLE_PWR_TYPE_SCAN : for scan. 213 | * ESP_BLE_PWR_TYPE_DEFAULT : if each connection's TX power is not set, it will use this default value. 214 | * if neither in scan mode nor in adv mode, it will use this default value. 215 | * If none of power type is set, system will use ESP_PWR_LVL_P3 as default for ADV/SCAN/CONN0-9. 216 | */ 217 | typedef enum { 218 | ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */ 219 | ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */ 220 | ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */ 221 | ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< For connection handle 3 */ 222 | ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< For connection handle 4 */ 223 | ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< For connection handle 5 */ 224 | ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */ 225 | ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */ 226 | ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */ 227 | ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */ 228 | ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */ 229 | ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */ 230 | ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */ 231 | } esp_ble_power_type_t; 232 | 233 | /** 234 | * @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm). 235 | */ 236 | typedef enum { 237 | ESP_PWR_LVL_N12 = 0, /*!< Corresponding to -12dbm */ 238 | ESP_PWR_LVL_N9 = 1, /*!< Corresponding to -9dbm */ 239 | ESP_PWR_LVL_N6 = 2, /*!< Corresponding to -6dbm */ 240 | ESP_PWR_LVL_N3 = 3, /*!< Corresponding to -3dbm */ 241 | ESP_PWR_LVL_N0 = 4, /*!< Corresponding to 0dbm */ 242 | ESP_PWR_LVL_P3 = 5, /*!< Corresponding to +3dbm */ 243 | ESP_PWR_LVL_P6 = 6, /*!< Corresponding to +6dbm */ 244 | ESP_PWR_LVL_P9 = 7, /*!< Corresponding to +9dbm */ 245 | ESP_PWR_LVL_N14 = ESP_PWR_LVL_N12, /*!< Backward compatibility! Setting to -14dbm will actually result to -12dbm */ 246 | ESP_PWR_LVL_N11 = ESP_PWR_LVL_N9, /*!< Backward compatibility! Setting to -11dbm will actually result to -9dbm */ 247 | ESP_PWR_LVL_N8 = ESP_PWR_LVL_N6, /*!< Backward compatibility! Setting to -8dbm will actually result to -6dbm */ 248 | ESP_PWR_LVL_N5 = ESP_PWR_LVL_N3, /*!< Backward compatibility! Setting to -5dbm will actually result to -3dbm */ 249 | ESP_PWR_LVL_N2 = ESP_PWR_LVL_N0, /*!< Backward compatibility! Setting to -2dbm will actually result to 0dbm */ 250 | ESP_PWR_LVL_P1 = ESP_PWR_LVL_P3, /*!< Backward compatibility! Setting to +1dbm will actually result to +3dbm */ 251 | ESP_PWR_LVL_P4 = ESP_PWR_LVL_P6, /*!< Backward compatibility! Setting to +4dbm will actually result to +6dbm */ 252 | ESP_PWR_LVL_P7 = ESP_PWR_LVL_P9, /*!< Backward compatibility! Setting to +7dbm will actually result to +9dbm */ 253 | } esp_power_level_t; 254 | 255 | /** 256 | * @brief Bluetooth audio data transport path 257 | */ 258 | typedef enum { 259 | ESP_SCO_DATA_PATH_HCI = 0, /*!< data over HCI transport */ 260 | ESP_SCO_DATA_PATH_PCM = 1, /*!< data over PCM interface */ 261 | } esp_sco_data_path_t; 262 | 263 | /** 264 | * @brief Set BLE TX power 265 | * Connection Tx power should only be set after connection created. 266 | * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc 267 | * @param power_level: Power level(index) corresponding to absolute value(dbm) 268 | * @return ESP_OK - success, other - failed 269 | */ 270 | esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level); 271 | 272 | /** 273 | * @brief Get BLE TX power 274 | * Connection Tx power should only be get after connection created. 275 | * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc 276 | * @return >= 0 - Power level, < 0 - Invalid 277 | */ 278 | esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type); 279 | 280 | /** 281 | * @brief Set BR/EDR TX power 282 | * BR/EDR power control will use the power in range of minimum value and maximum value. 283 | * The power level will effect the global BR/EDR TX power, such inquire, page, connection and so on. 284 | * Please call the function after esp_bt_controller_enable and before any function which cause RF do TX. 285 | * So you can call the function before doing discovery, profile init and so on. 286 | * For example, if you want BR/EDR use the new TX power to do inquire, you should call 287 | * this function before inquire. Another word, If call this function when BR/EDR is in inquire(ING), 288 | * please do inquire again after call this function. 289 | * Default minimum power level is ESP_PWR_LVL_N0, and maximum power level is ESP_PWR_LVL_P3. 290 | * @param min_power_level: The minimum power level 291 | * @param max_power_level: The maximum power level 292 | * @return ESP_OK - success, other - failed 293 | */ 294 | esp_err_t esp_bredr_tx_power_set(esp_power_level_t min_power_level, esp_power_level_t max_power_level); 295 | 296 | /** 297 | * @brief Get BR/EDR TX power 298 | * If the argument is not NULL, then store the corresponding value. 299 | * @param min_power_level: The minimum power level 300 | * @param max_power_level: The maximum power level 301 | * @return ESP_OK - success, other - failed 302 | */ 303 | esp_err_t esp_bredr_tx_power_get(esp_power_level_t *min_power_level, esp_power_level_t *max_power_level); 304 | 305 | /** 306 | * @brief Set default SCO data path 307 | * Should be called after controller is enabled, and before (e)SCO link is established 308 | * @param data_path: SCO data path 309 | * @return ESP_OK - success, other - failed 310 | */ 311 | esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path); 312 | 313 | /** 314 | * @brief Initialize BT controller to allocate task and other resource. 315 | * This function should be called only once, before any other BT functions are called. 316 | * @param cfg: Initial configuration of BT controller. Different from previous version, there's a mode and some 317 | * connection configuration in "cfg" to configure controller work mode and allocate the resource which is needed. 318 | * @return ESP_OK - success, other - failed 319 | */ 320 | esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg); 321 | 322 | /** 323 | * @brief De-initialize BT controller to free resource and delete task. 324 | * 325 | * This function should be called only once, after any other BT functions are called. 326 | * @return ESP_OK - success, other - failed 327 | */ 328 | esp_err_t esp_bt_controller_deinit(void); 329 | 330 | /** 331 | * @brief Enable BT controller. 332 | * Due to a known issue, you cannot call esp_bt_controller_enable() a second time 333 | * to change the controller mode dynamically. To change controller mode, call 334 | * esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode. 335 | * @param mode : the mode(BLE/BT/BTDM) to enable. For compatible of API, retain this argument. This mode must be 336 | * equal as the mode in "cfg" of esp_bt_controller_init(). 337 | * @return ESP_OK - success, other - failed 338 | */ 339 | esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode); 340 | 341 | /** 342 | * @brief Disable BT controller 343 | * @return ESP_OK - success, other - failed 344 | */ 345 | esp_err_t esp_bt_controller_disable(void); 346 | 347 | /** 348 | * @brief Get BT controller is initialised/de-initialised/enabled/disabled 349 | * @return status value 350 | */ 351 | esp_bt_controller_status_t esp_bt_controller_get_status(void); 352 | 353 | /** 354 | * @brief Get BT MAC address. 355 | * @return Array pointer of length 6 storing MAC address value. 356 | */ 357 | uint8_t* esp_bt_get_mac(void); 358 | 359 | /** @brief esp_vhci_host_callback 360 | * used for vhci call host function to notify what host need to do 361 | */ 362 | typedef struct esp_vhci_host_callback { 363 | void (*notify_host_send_available)(void); /*!< callback used to notify that the host can send packet to controller */ 364 | int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the controller has a packet to send to the host*/ 365 | } esp_vhci_host_callback_t; 366 | 367 | /** @brief esp_vhci_host_check_send_available 368 | * used for check actively if the host can send packet to controller or not. 369 | * @return true for ready to send, false means cannot send packet 370 | */ 371 | bool esp_vhci_host_check_send_available(void); 372 | 373 | /** @brief esp_vhci_host_send_packet 374 | * host send packet to controller 375 | * 376 | * Should not call this function from within a critical section 377 | * or when the scheduler is suspended. 378 | * 379 | * @param data the packet point 380 | * @param len the packet length 381 | */ 382 | void esp_vhci_host_send_packet(uint8_t *data, uint16_t len); 383 | 384 | /** @brief esp_vhci_host_register_callback 385 | * register the vhci reference callback 386 | * struct defined by vhci_host_callback structure. 387 | * @param callback esp_vhci_host_callback type variable 388 | * @return ESP_OK - success, ESP_FAIL - failed 389 | */ 390 | esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback); 391 | 392 | /** @brief esp_bt_controller_mem_release 393 | * release the controller memory as per the mode 394 | * 395 | * This function releases the BSS, data and other sections of the controller to heap. The total size is about 70k bytes. 396 | * 397 | * esp_bt_controller_mem_release(mode) should be called only before esp_bt_controller_init() 398 | * or after esp_bt_controller_deinit(). 399 | * 400 | * Note that once BT controller memory is released, the process cannot be reversed. It means you cannot use the bluetooth 401 | * mode which you have released by this function. 402 | * 403 | * If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled) 404 | * then do not call this function. 405 | * 406 | * If the app calls esp_bt_controller_enable(ESP_BT_MODE_BLE) to use BLE only then it is safe to call 407 | * esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) at initialization time to free unused BT Classic memory. 408 | * 409 | * If the mode is ESP_BT_MODE_BTDM, then it may be useful to call API esp_bt_mem_release(ESP_BT_MODE_BTDM) instead, 410 | * which internally calls esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) and additionally releases the BSS and data 411 | * consumed by the BT/BLE host stack to heap. For more details about usage please refer to the documentation of 412 | * esp_bt_mem_release() function 413 | * 414 | * @param mode : the mode want to release memory 415 | * @return ESP_OK - success, other - failed 416 | */ 417 | esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode); 418 | 419 | /** @brief esp_bt_mem_release 420 | * release controller memory and BSS and data section of the BT/BLE host stack as per the mode 421 | * 422 | * This function first releases controller memory by internally calling esp_bt_controller_mem_release(). 423 | * Additionally, if the mode is set to ESP_BT_MODE_BTDM, it also releases the BSS and data consumed by the BT/BLE host stack to heap 424 | * 425 | * Note that once BT memory is released, the process cannot be reversed. It means you cannot use the bluetooth 426 | * mode which you have released by this function. 427 | * 428 | * If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled) 429 | * then do not call this function. 430 | * 431 | * If you never intend to use bluetooth in a current boot-up cycle, you can call esp_bt_mem_release(ESP_BT_MODE_BTDM) 432 | * before esp_bt_controller_init or after esp_bt_controller_deinit. 433 | * 434 | * For example, if a user only uses bluetooth for setting the WiFi configuration, and does not use bluetooth in the rest of the product operation". 435 | * In such cases, after receiving the WiFi configuration, you can disable/deinit bluetooth and release its memory. 436 | * Below is the sequence of APIs to be called for such scenarios: 437 | * 438 | * esp_bluedroid_disable(); 439 | * esp_bluedroid_deinit(); 440 | * esp_bt_controller_disable(); 441 | * esp_bt_controller_deinit(); 442 | * esp_bt_mem_release(ESP_BT_MODE_BTDM); 443 | * 444 | * @note In case of NimBLE host, to release BSS and data memory to heap, the mode needs to be 445 | * set to ESP_BT_MODE_BTDM as controller is dual mode. 446 | * @param mode : the mode whose memory is to be released 447 | * @return ESP_OK - success, other - failed 448 | */ 449 | esp_err_t esp_bt_mem_release(esp_bt_mode_t mode); 450 | 451 | /** 452 | * @brief enable bluetooth to enter modem sleep 453 | * 454 | * Note that this function shall not be invoked before esp_bt_controller_enable() 455 | * 456 | * There are currently two options for bluetooth modem sleep, one is ORIG mode, and another is EVED Mode. EVED Mode is intended for BLE only. 457 | * 458 | * For ORIG mode: 459 | * Bluetooth modem sleep is enabled in controller start up by default if CONFIG_CTRL_BTDM_MODEM_SLEEP is set and "ORIG mode" is selected. In ORIG modem sleep mode, bluetooth controller will switch off some components and pause to work every now and then, if there is no event to process; and wakeup according to the scheduled interval and resume the work. It can also wakeup earlier upon external request using function "esp_bt_controller_wakeup_request". 460 | * 461 | * @return 462 | * - ESP_OK : success 463 | * - other : failed 464 | */ 465 | esp_err_t esp_bt_sleep_enable(void); 466 | 467 | 468 | /** 469 | * @brief disable bluetooth modem sleep 470 | * 471 | * Note that this function shall not be invoked before esp_bt_controller_enable() 472 | * 473 | * If esp_bt_sleep_disable() is called, bluetooth controller will not be allowed to enter modem sleep; 474 | * 475 | * If ORIG modem sleep mode is in use, if this function is called, bluetooth controller may not immediately wake up if it is dormant then. 476 | * In this case, esp_bt_controller_wakeup_request() can be used to shorten the time for wakeup. 477 | * 478 | * @return 479 | * - ESP_OK : success 480 | * - other : failed 481 | */ 482 | esp_err_t esp_bt_sleep_disable(void); 483 | 484 | /** 485 | * @brief Manually clear scan duplicate list 486 | * 487 | * Note that scan duplicate list will be automatically cleared when the maximum amount of device in the filter is reached 488 | * the amount of device in the filter can be configured in menuconfig. 489 | * 490 | * @note This function name is incorrectly spelled, it will be fixed in release 5.x version. 491 | * 492 | * @return 493 | * - ESP_OK : success 494 | * - other : failed 495 | */ 496 | esp_err_t esp_ble_scan_dupilcate_list_flush(void); 497 | 498 | #ifdef __cplusplus 499 | } 500 | #endif 501 | 502 | #endif /* __ESP_BT_H__ */ 503 | -------------------------------------------------------------------------------- /include/esp32/phy_init_data.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef PHY_INIT_DATA_H 16 | #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ 17 | #include "esp_phy_init.h" 18 | #include "sdkconfig.h" 19 | 20 | // constrain a value between 'low' and 'high', inclusive 21 | #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val) 22 | 23 | #define PHY_INIT_MAGIC "PHYINIT" 24 | 25 | // define the lowest tx power as LOWEST_PHY_TX_POWER 26 | #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 52) 27 | #define PHY_TX_POWER_OFFSET 44 28 | #define PHY_TX_POWER_NUM 5 29 | 30 | #if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN 31 | #define PHY_CRC_ALGORITHM 1 32 | #define PHY_COUNTRY_CODE_LEN 2 33 | #define PHY_INIT_DATA_TYPE_OFFSET 126 34 | #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125 35 | #endif 36 | static const char phy_init_magic_pre[] = PHY_INIT_MAGIC; 37 | 38 | /** 39 | * @brief Structure containing default recommended PHY initialization parameters. 40 | */ 41 | static const esp_phy_init_data_t phy_init_data= { { 42 | 3, 43 | 3, 44 | 0x05, 45 | 0x09, 46 | 0x06, 47 | 0x05, 48 | 0x03, 49 | 0x06, 50 | 0x05, 51 | 0x04, 52 | 0x06, 53 | 0x04, 54 | 0x05, 55 | 0x00, 56 | 0x00, 57 | 0x00, 58 | 0x00, 59 | 0x05, 60 | 0x09, 61 | 0x06, 62 | 0x05, 63 | 0x03, 64 | 0x06, 65 | 0x05, 66 | 0x00, 67 | 0x00, 68 | 0x00, 69 | 0x00, 70 | 0x00, 71 | 0x00, 72 | 0x00, 73 | 0x00, 74 | 0xfc, 75 | 0xfc, 76 | 0xfe, 77 | 0xf0, 78 | 0xf0, 79 | 0xf0, 80 | 0xe0, 81 | 0xe0, 82 | 0xe0, 83 | 0x18, 84 | 0x18, 85 | 0x18, 86 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 84), 87 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 72), 88 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 66), 89 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 60), 90 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 56), 91 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 52), 92 | 0, 93 | 1, 94 | 1, 95 | 2, 96 | 2, 97 | 3, 98 | 4, 99 | 5, 100 | 0, 101 | 0, 102 | 0, 103 | 0, 104 | 0, 105 | 0, 106 | 0, 107 | 0, 108 | 0, 109 | 0, 110 | 0, 111 | 0, 112 | 0, 113 | 0, 114 | 0, 115 | 0, 116 | 0, 117 | 0, 118 | 0, 119 | 0, 120 | 0, 121 | 0, 122 | 0, 123 | 0, 124 | 0, 125 | 0, 126 | 0, 127 | 0, 128 | 0, 129 | 0, 130 | 0, 131 | 0, 132 | 0, 133 | 0, 134 | 0, 135 | 0, 136 | 0, 137 | 0, 138 | 0, 139 | 0, 140 | 0, 141 | 0, 142 | 0, 143 | 0, 144 | 0, 145 | 0, 146 | 0, 147 | 0, 148 | 0, 149 | } }; 150 | 151 | static const char phy_init_magic_post[] = PHY_INIT_MAGIC; 152 | 153 | #if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN 154 | /** 155 | * @brief PHY init data control infomation structure 156 | */ 157 | typedef struct { 158 | uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */ 159 | uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */ 160 | uint8_t check_algorithm; /*!< check algorithm */ 161 | uint8_t version; /*!< PHY init data bin version */ 162 | uint8_t number; /*!< PHY init data bin number */ 163 | uint8_t length[2]; /*!< Length of each PHY init data bin */ 164 | uint8_t reserved[19]; /*!< 19-byte reserved */ 165 | } __attribute__ ((packed)) phy_control_info_data_t; 166 | 167 | /** 168 | * @brief Country corresponds to PHY init data type structure 169 | */ 170 | typedef struct { 171 | char cc[PHY_COUNTRY_CODE_LEN]; 172 | uint8_t type; 173 | } phy_country_to_bin_type_t; 174 | #endif 175 | #endif /* PHY_INIT_DATA_H */ 176 | -------------------------------------------------------------------------------- /include/esp32c3/phy_init_data.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef PHY_INIT_DATA_H 16 | #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ 17 | #include "esp_phy_init.h" 18 | #include "sdkconfig.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | // constrain a value between 'low' and 'high', inclusive 25 | #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val) 26 | 27 | #define PHY_INIT_MAGIC "PHYINIT" 28 | 29 | // define the lowest tx power as LOWEST_PHY_TX_POWER 30 | #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 52) 31 | #define PHY_TX_POWER_OFFSET 44 32 | #define PHY_TX_POWER_NUM 5 33 | 34 | #if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN 35 | #define PHY_CRC_ALGORITHM 1 36 | #define PHY_COUNTRY_CODE_LEN 2 37 | #define PHY_INIT_DATA_TYPE_OFFSET 126 38 | #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125 39 | #endif 40 | 41 | static const char __attribute__((section(".rodata"))) phy_init_magic_pre[] = PHY_INIT_MAGIC; 42 | 43 | /** 44 | * @brief Structure containing default recommended PHY initialization parameters. 45 | */ 46 | static const esp_phy_init_data_t phy_init_data= { { 47 | 0x00, 48 | 0x00, 49 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x50), 50 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x50), 51 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x50), 52 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x4c), 53 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x4c), 54 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x48), 55 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x4c), 56 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x48), 57 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x48), 58 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x44), 59 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x4a), 60 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x46), 61 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x46), 62 | LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x42), 63 | 0x00, 64 | 0x00, 65 | 0x00, 66 | 0xff, 67 | 0xff, 68 | 0xff, 69 | 0xff, 70 | 0xff, 71 | 0xff, 72 | 0xff, 73 | 0xff, 74 | 0xff, 75 | 0xff, 76 | 0xff, 77 | 0xff, 78 | 0xff, 79 | 0xff, 80 | 0xff, 81 | 0xff, 82 | 0xff, 83 | 0xff, 84 | 0xff, 85 | 0xff, 86 | 0xff, 87 | 0xff, 88 | 0xff, 89 | 0xff, 90 | 0xff, 91 | 0xff, 92 | 0xff, 93 | 0xff, 94 | 0xff, 95 | 0xff, 96 | 0xff, 97 | 0xff, 98 | 0xff, 99 | 0xff, 100 | 0xff, 101 | 0xff, 102 | 0xff, 103 | 0xff, 104 | 0xff, 105 | 0xff, 106 | 0xff, 107 | 0xff, 108 | 0xff, 109 | 0xff, 110 | 0xff, 111 | 0xff, 112 | 0xff, 113 | 0xff, 114 | 0xff, 115 | 0xff, 116 | 0xff, 117 | 0, 118 | 0, 119 | 0, 120 | 0, 121 | 0, 122 | 0, 123 | 0, 124 | 0, 125 | 0, 126 | 0, 127 | 0, 128 | 0, 129 | 0, 130 | 0, 131 | 0, 132 | 0, 133 | 0, 134 | 0, 135 | 0, 136 | 0, 137 | 0, 138 | 0, 139 | 0, 140 | 0, 141 | 0, 142 | 0, 143 | 0, 144 | 0, 145 | 0, 146 | 0, 147 | 0, 148 | 0, 149 | 0, 150 | 0, 151 | 0, 152 | 0, 153 | 0, 154 | 0, 155 | 0, 156 | 0, 157 | 0, 158 | 0x74 159 | } }; 160 | 161 | static const char __attribute__((section(".rodata"))) phy_init_magic_post[] = PHY_INIT_MAGIC; 162 | 163 | #if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN 164 | /** 165 | * @brief PHY init data control infomation structure 166 | */ 167 | typedef struct { 168 | uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */ 169 | uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */ 170 | uint8_t check_algorithm; /*!< check algorithm */ 171 | uint8_t version; /*!< PHY init data bin version */ 172 | uint8_t number; /*!< PHY init data bin number */ 173 | uint8_t length[2]; /*!< Length of each PHY init data bin */ 174 | uint8_t reserved[19]; /*!< 19-byte reserved */ 175 | } __attribute__ ((packed)) phy_control_info_data_t; 176 | 177 | /** 178 | * @brief Country corresponds to PHY init data type structure 179 | */ 180 | typedef struct { 181 | char cc[PHY_COUNTRY_CODE_LEN]; 182 | uint8_t type; 183 | } phy_country_to_bin_type_t; 184 | #endif 185 | 186 | #ifdef __cplusplus 187 | } 188 | #endif 189 | 190 | #endif /* PHY_INIT_DATA_H */ 191 | -------------------------------------------------------------------------------- /include/esp_coexist.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef __ESP_COEXIST_H__ 16 | #define __ESP_COEXIST_H__ 17 | 18 | #include 19 | #include "esp_err.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * @brief coex prefer value 27 | */ 28 | typedef enum { 29 | ESP_COEX_PREFER_WIFI = 0, /*!< Prefer to WiFi, WiFi will have more opportunity to use RF */ 30 | ESP_COEX_PREFER_BT, /*!< Prefer to bluetooth, bluetooth will have more opportunity to use RF */ 31 | ESP_COEX_PREFER_BALANCE, /*!< Do balance of WiFi and bluetooth */ 32 | ESP_COEX_PREFER_NUM, /*!< Prefer value numbers */ 33 | } esp_coex_prefer_t; 34 | 35 | /** 36 | * @brief coex status type 37 | */ 38 | typedef enum { 39 | ESP_COEX_ST_TYPE_WIFI = 0, 40 | ESP_COEX_ST_TYPE_BLE, 41 | ESP_COEX_ST_TYPE_BT, 42 | } esp_coex_status_type_t; 43 | 44 | /** 45 | * @brief coex configuration structure 46 | */ 47 | typedef struct 48 | { 49 | uint8_t wifi_st; 50 | uint8_t ble_st; 51 | uint8_t bt_st; 52 | /* Members above shall vary from coexistence status macro: ESP_COEX_[MODULE]_ST_[STATUS] */ 53 | uint8_t wifi_prop; 54 | uint8_t ble_prop; 55 | uint8_t bt_prop; 56 | /* proportion shall vary from 0-100 and the summary of them shall equal to 100 */ 57 | } esp_coex_proportion_t; 58 | 59 | /* coexistence status macro */ 60 | #define ESP_COEX_WIIF_ST_SCAN 0x01 61 | #define ESP_COEX_WIFI_ST_CONNECTING 0x02 62 | #define ESP_COEX_WIFI_ST_CONNECTED 0x04 63 | 64 | #define ESP_COEX_BLE_ST_IDLE 0x00 65 | #define ESP_COEX_BLE_ST_ADV 0x01 66 | #define ESP_COEX_BLE_ST_SCAN 0x02 67 | #define ESP_COEX_BLE_ST_CONNECTED 0x04 68 | #define ESP_COEX_BLE_ST_MESH_CONFIG 0x08 69 | #define ESP_COEX_BLE_ST_MESH_TRAFFIC 0x10 70 | #define ESP_COEX_BLE_ST_MESH_STANDBY 0x20 71 | 72 | #define ESP_COEX_BT_ST_IDLE 0x00 73 | #define ESP_COEX_BT_ST_ISCAN 0x01 74 | #define ESP_COEX_BT_ST_CONNECTED 0x04 75 | #define ESP_COEX_BT_ST_SNIFF 0x08 76 | #define ESP_COEX_BT_ST_A2DP_STREAMING 0x10 77 | #define ESP_COEX_BT_ST_A2DP_PAUSED 0x20 78 | 79 | /** 80 | * @brief Get software coexist version string 81 | * 82 | * @return : version string 83 | */ 84 | const char *esp_coex_version_get(void); 85 | 86 | /** 87 | * @deprecated Use esp_coex_status_bit_set() and esp_coex_status_bit_clear() instead. 88 | * Set coexist preference of performance 89 | * For example, if prefer to bluetooth, then it will make A2DP(play audio via classic bt) 90 | * more smooth while wifi is runnning something. 91 | * If prefer to wifi, it will do similar things as prefer to bluetooth. 92 | * Default, it prefer to balance. 93 | * 94 | * @param prefer : the prefer enumeration value 95 | * @return : ESP_OK - success, other - failed 96 | */ 97 | esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer); 98 | 99 | /** 100 | * @brief Set coex schm status 101 | * @param type : WIFI/BLE/BT 102 | * @param status : WIFI/BLE/BT STATUS 103 | * @return : ESP_OK - success, other - failed 104 | */ 105 | esp_err_t esp_coex_status_bit_set(esp_coex_status_type_t type, uint32_t status); 106 | 107 | /** 108 | * @brief Clear coex schm status 109 | * @param type : WIFI/BLE/BT 110 | * @param status : WIFI/BLE/BT STATUS 111 | * @return : ESP_OK - success, other - failed 112 | */ 113 | esp_err_t esp_coex_status_bit_clear(esp_coex_status_type_t type, uint32_t status); 114 | 115 | /** 116 | * @brief Set specifical coexistence proportion for different coexistence combination 117 | * The following combinations are not supported to set proportion 118 | * 1. WiFi module is at IDLE status 119 | * 2. BLE module is at IDLE status and BT module is at IDLE / InquiryScan / Sniff / Inquiry status 120 | * 3. BLE module is at MESH_CONFIG / MESH_STANDBY status 121 | * 4. BLE module is at MESH TRAFFIC / SCAN with no mesh status and BT module is at Inquiry status 122 | * @param prop : pointer for configuration structure 123 | * @return : ESP_OK - success, other - failed 124 | */ 125 | esp_err_t esp_coex_proportion_set(esp_coex_proportion_t *prop); 126 | 127 | /** 128 | * @brief Get specifical coexistence proportion at different coexistence combination 129 | * The following combinations are not supported to get proportion 130 | * 1. WiFi module is at IDLE status 131 | * 2. BLE module is at IDLE status and BT module is at IDLE / InquiryScan / Sniff / Inquiry status 132 | * 3. BLE module is at MESH_CONFIG / MESH_STANDBY status 133 | * 4. BLE module is at MESH TRAFFIC / SCAN with no mesh status and BT module is at Inquiry status 134 | * @param prop : pointer for configuration structure 135 | * @return : ESP_OK - success, other - failed 136 | */ 137 | esp_err_t esp_coex_proportion_get(esp_coex_proportion_t *prop); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | 144 | #endif /* __ESP_COEXIST_H__ */ 145 | -------------------------------------------------------------------------------- /include/esp_coexist_adapter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef __ESP_COEXIST_ADAPTER_H__ 16 | #define __ESP_COEXIST_ADAPTER_H__ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define COEX_ADAPTER_VERSION 0x00000002 25 | #define COEX_ADAPTER_MAGIC 0xDEADBEAF 26 | 27 | #define COEX_ADAPTER_FUNCS_TIME_BLOCKING 0xffffffff 28 | 29 | typedef struct { 30 | int32_t _version; 31 | #if CONFIG_IDF_TARGET_ESP32 32 | void *(* _spin_lock_create)(void); 33 | void (* _spin_lock_delete)(void *lock); 34 | uint32_t (*_int_disable)(void *mux); 35 | void (*_int_enable)(void *mux, uint32_t tmp); 36 | #endif 37 | void (*_task_yield_from_isr)(void); 38 | void *(*_semphr_create)(uint32_t max, uint32_t init); 39 | void (*_semphr_delete)(void *semphr); 40 | int32_t (*_semphr_take_from_isr)(void *semphr, void *hptw); 41 | int32_t (*_semphr_give_from_isr)(void *semphr, void *hptw); 42 | int32_t (*_semphr_take)(void *semphr, uint32_t block_time_tick); 43 | int32_t (*_semphr_give)(void *semphr); 44 | int (* _is_in_isr)(void); 45 | void * (* _malloc_internal)(size_t size); 46 | void (* _free)(void *p); 47 | #if CONFIG_IDF_TARGET_ESP32 48 | void (* _timer_disarm)(void *timer); 49 | void (* _timer_done)(void *ptimer); 50 | void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg); 51 | void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat); 52 | #endif 53 | int64_t (* _esp_timer_get_time)(void); 54 | int32_t _magic; 55 | } coex_adapter_funcs_t; 56 | 57 | extern coex_adapter_funcs_t g_coex_adapter_funcs; 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* __ESP_COEXIST_ADAPTER_H__ */ 64 | -------------------------------------------------------------------------------- /include/esp_coexist_internal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef __ESP_COEXIST_INTERNAL_H__ 16 | #define __ESP_COEXIST_INTERNAL_H__ 17 | 18 | #include 19 | #include "esp_coexist_adapter.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef enum { 26 | COEX_PREFER_WIFI = 0, 27 | COEX_PREFER_BT, 28 | COEX_PREFER_BALANCE, 29 | COEX_PREFER_NUM, 30 | } coex_prefer_t; 31 | 32 | typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt); 33 | 34 | /** 35 | * @brief Pre-Init software coexist 36 | * extern function for internal use. 37 | * 38 | * @return Init ok or failed. 39 | */ 40 | esp_err_t coex_pre_init(void); 41 | 42 | /** 43 | * @brief Init software coexist 44 | * extern function for internal use. 45 | * 46 | * @return Init ok or failed. 47 | */ 48 | esp_err_t coex_init(void); 49 | 50 | /** 51 | * @brief De-init software coexist 52 | * extern function for internal use. 53 | */ 54 | void coex_deinit(void); 55 | 56 | /** 57 | * @brief Enable software coexist 58 | * extern function for internal use. 59 | * 60 | * @return Enable ok or failed. 61 | */ 62 | esp_err_t coex_enable(void); 63 | 64 | /** 65 | * @brief Disable software coexist 66 | * extern function for internal use. 67 | */ 68 | void coex_disable(void); 69 | 70 | /** 71 | * @brief Get software coexist version string 72 | * extern function for internal use. 73 | * @return : version string 74 | */ 75 | const char *coex_version_get(void); 76 | 77 | /** 78 | * @brief Coexist performance preference set from libbt.a 79 | * extern function for internal use. 80 | * 81 | * @param prefer : the prefer enumeration value 82 | * @return : ESP_OK - success, other - failed 83 | */ 84 | esp_err_t coex_preference_set(coex_prefer_t prefer); 85 | 86 | /** 87 | * @brief Get software coexist status. 88 | * @return : software coexist status 89 | */ 90 | uint32_t coex_status_get(void); 91 | 92 | /** 93 | * @brief Set software coexist condition. 94 | * @return : software coexist condition 95 | */ 96 | void coex_condition_set(uint32_t type, bool dissatisfy); 97 | 98 | /** 99 | * @brief WiFi requests coexistence. 100 | * 101 | * @param event : WiFi event 102 | * @param latency : WiFi will request coexistence after latency 103 | * @param duration : duration for WiFi to request coexistence 104 | * @return : 0 - success, other - failed 105 | */ 106 | int coex_wifi_request(uint32_t event, uint32_t latency, uint32_t duration); 107 | 108 | /** 109 | * @brief WiFi release coexistence. 110 | * 111 | * @param event : WiFi event 112 | * @return : 0 - success, other - failed 113 | */ 114 | int coex_wifi_release(uint32_t event); 115 | 116 | /** 117 | * @brief Set WiFi channel to coexistence module. 118 | * 119 | * @param primary : WiFi primary channel 120 | * @param secondary : WiFi secondary channel 121 | * @return : 0 - success, other - failed 122 | */ 123 | int coex_wifi_channel_set(uint8_t primary, uint8_t secondary); 124 | 125 | /** 126 | * @brief Get coexistence event duration. 127 | * 128 | * @param event : Coexistence event 129 | * @param duration: Coexistence event duration 130 | * @return : 0 - success, other - failed 131 | */ 132 | int coex_event_duration_get(uint32_t event, uint32_t *duration); 133 | 134 | #if SOC_COEX_HW_PTI 135 | /** 136 | * @brief Get coexistence event priority. 137 | * 138 | * @param event : Coexistence event 139 | * @param pti: Coexistence event priority 140 | * @return : 0 - success, other - failed 141 | */ 142 | int coex_pti_get(uint32_t event, uint8_t *pti); 143 | #endif 144 | 145 | /** 146 | * @brief Clear coexistence status. 147 | * 148 | * @param type : Coexistence status type 149 | * @param status: Coexistence status 150 | */ 151 | void coex_schm_status_bit_clear(uint32_t type, uint32_t status); 152 | 153 | /** 154 | * @brief Set coexistence status. 155 | * 156 | * @param type : Coexistence status type 157 | * @param status: Coexistence status 158 | */ 159 | void coex_schm_status_bit_set(uint32_t type, uint32_t status); 160 | 161 | /** 162 | * @brief Set coexistence scheme interval. 163 | * 164 | * @param interval : Coexistence scheme interval 165 | * @return : 0 - success, other - failed 166 | */ 167 | int coex_schm_interval_set(uint32_t interval); 168 | 169 | /** 170 | * @brief Get coexistence scheme interval. 171 | * 172 | * @return : Coexistence scheme interval 173 | */ 174 | uint32_t coex_schm_interval_get(void); 175 | 176 | /** 177 | * @brief Get current coexistence scheme period. 178 | * 179 | * @return : Coexistence scheme period 180 | */ 181 | uint8_t coex_schm_curr_period_get(void); 182 | 183 | /** 184 | * @brief Get current coexistence scheme phase. 185 | * 186 | * @return : Coexistence scheme phase 187 | */ 188 | void * coex_schm_curr_phase_get(void); 189 | 190 | /** 191 | * @brief Set current coexistence scheme phase index. 192 | * 193 | * @param interval : Coexistence scheme phase index 194 | * @return : 0 - success, other - failed 195 | */ 196 | int coex_schm_curr_phase_idx_set(int idx); 197 | 198 | /** 199 | * @brief Get current coexistence scheme phase index. 200 | * 201 | * @return : Coexistence scheme phase index 202 | */ 203 | int coex_schm_curr_phase_idx_get(void); 204 | 205 | /** 206 | * @brief Register coexistence adapter functions. 207 | * 208 | * @param funcs : coexistence adapter functions 209 | * @return : ESP_OK - success, other - failed 210 | */ 211 | esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs); 212 | 213 | /** 214 | * @brief Check the MD5 values of the coexistence adapter header files in IDF and WiFi library 215 | * 216 | * @attention 1. It is used for internal CI version check 217 | * 218 | * @return 219 | * - ESP_OK : succeed 220 | * - ESP_WIFI_INVALID_ARG : MD5 check fail 221 | */ 222 | esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5); 223 | 224 | #ifdef __cplusplus 225 | } 226 | #endif 227 | 228 | #endif /* __ESP_COEXIST_INTERNAL_H__ */ 229 | -------------------------------------------------------------------------------- /include/esp_compiler.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef __ESP_COMPILER_H 15 | #define __ESP_COMPILER_H 16 | 17 | /* 18 | * The likely and unlikely macro pairs: 19 | * These macros are useful to place when application 20 | * knows the majority ocurrence of a decision paths, 21 | * placing one of these macros can hint the compiler 22 | * to reorder instructions producing more optimized 23 | * code. 24 | */ 25 | #if (CONFIG_COMPILER_OPTIMIZATION_PERF) 26 | #define likely(x) __builtin_expect(!!(x), 1) 27 | #define unlikely(x) __builtin_expect(!!(x), 0) 28 | #else 29 | #define likely(x) (x) 30 | #define unlikely(x) (x) 31 | #endif 32 | 33 | /* 34 | * Utility macros used for designated initializers, which work differently 35 | * in C99 and C++ standards mainly for aggregate types. 36 | * The member separator, comma, is already part of the macro, please omit the trailing comma. 37 | * Usage example: 38 | * struct config_t { char* pchr; char arr[SIZE]; } config = { 39 | * ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(pchr) 40 | * ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(arr, "Value") 41 | * }; 42 | */ 43 | #ifdef __cplusplus 44 | #define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) { .member = value }, 45 | #define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member) .member = { }, 46 | #else 47 | #define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) .member = value, 48 | #define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member) 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/esp_err.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #pragma once 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef int esp_err_t; 25 | 26 | /* Definitions for error constants. */ 27 | #define ESP_OK 0 /*!< esp_err_t value indicating success (no error) */ 28 | #define ESP_FAIL -1 /*!< Generic esp_err_t code indicating failure */ 29 | 30 | #define ESP_ERR_NO_MEM 0x101 /*!< Out of memory */ 31 | #define ESP_ERR_INVALID_ARG 0x102 /*!< Invalid argument */ 32 | #define ESP_ERR_INVALID_STATE 0x103 /*!< Invalid state */ 33 | #define ESP_ERR_INVALID_SIZE 0x104 /*!< Invalid size */ 34 | #define ESP_ERR_NOT_FOUND 0x105 /*!< Requested resource not found */ 35 | #define ESP_ERR_NOT_SUPPORTED 0x106 /*!< Operation or feature not supported */ 36 | #define ESP_ERR_TIMEOUT 0x107 /*!< Operation timed out */ 37 | #define ESP_ERR_INVALID_RESPONSE 0x108 /*!< Received response was invalid */ 38 | #define ESP_ERR_INVALID_CRC 0x109 /*!< CRC or checksum was invalid */ 39 | #define ESP_ERR_INVALID_VERSION 0x10A /*!< Version was invalid */ 40 | #define ESP_ERR_INVALID_MAC 0x10B /*!< MAC address was invalid */ 41 | 42 | #define ESP_ERR_WIFI_BASE 0x3000 /*!< Starting number of WiFi error codes */ 43 | #define ESP_ERR_MESH_BASE 0x4000 /*!< Starting number of MESH error codes */ 44 | #define ESP_ERR_FLASH_BASE 0x6000 /*!< Starting number of flash error codes */ 45 | #define ESP_ERR_HW_CRYPTO_BASE 0xc000 /*!< Starting number of HW cryptography module error codes */ 46 | 47 | /** 48 | * @brief Returns string for esp_err_t error codes 49 | * 50 | * This function finds the error code in a pre-generated lookup-table and 51 | * returns its string representation. 52 | * 53 | * The function is generated by the Python script 54 | * tools/gen_esp_err_to_name.py which should be run each time an esp_err_t 55 | * error is modified, created or removed from the IDF project. 56 | * 57 | * @param code esp_err_t error code 58 | * @return string error message 59 | */ 60 | const char *esp_err_to_name(esp_err_t code); 61 | 62 | /** 63 | * @brief Returns string for esp_err_t and system error codes 64 | * 65 | * This function finds the error code in a pre-generated lookup-table of 66 | * esp_err_t errors and returns its string representation. If the error code 67 | * is not found then it is attempted to be found among system errors. 68 | * 69 | * The function is generated by the Python script 70 | * tools/gen_esp_err_to_name.py which should be run each time an esp_err_t 71 | * error is modified, created or removed from the IDF project. 72 | * 73 | * @param code esp_err_t error code 74 | * @param[out] buf buffer where the error message should be written 75 | * @param buflen Size of buffer buf. At most buflen bytes are written into the buf buffer (including the terminating null byte). 76 | * @return buf containing the string error message 77 | */ 78 | const char *esp_err_to_name_r(esp_err_t code, char *buf, size_t buflen); 79 | 80 | /** @cond */ 81 | void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) __attribute__((noreturn)); 82 | 83 | /** @cond */ 84 | void _esp_error_check_failed_without_abort(esp_err_t rc, const char *file, int line, const char *function, const char *expression); 85 | 86 | #ifndef __ASSERT_FUNC 87 | /* This won't happen on IDF, which defines __ASSERT_FUNC in assert.h, but it does happen when building on the host which 88 | uses /usr/include/assert.h or equivalent. 89 | */ 90 | #ifdef __ASSERT_FUNCTION 91 | #define __ASSERT_FUNC __ASSERT_FUNCTION /* used in glibc assert.h */ 92 | #else 93 | #define __ASSERT_FUNC "??" 94 | #endif 95 | #endif 96 | /** @endcond */ 97 | 98 | /** 99 | * Macro which can be used to check the error code, 100 | * and terminate the program in case the code is not ESP_OK. 101 | * Prints the error code, error location, and the failed statement to serial output. 102 | * 103 | * Disabled if assertions are disabled. 104 | */ 105 | #ifdef NDEBUG 106 | #define ESP_ERROR_CHECK(x) do { \ 107 | esp_err_t __err_rc = (x); \ 108 | (void) sizeof(__err_rc); \ 109 | } while(0) 110 | #elif defined(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT) 111 | #define ESP_ERROR_CHECK(x) do { \ 112 | esp_err_t __err_rc = (x); \ 113 | if (__err_rc != ESP_OK) { \ 114 | abort(); \ 115 | } \ 116 | } while(0) 117 | #else 118 | #define ESP_ERROR_CHECK(x) do { \ 119 | esp_err_t __err_rc = (x); \ 120 | if (__err_rc != ESP_OK) { \ 121 | _esp_error_check_failed(__err_rc, __FILE__, __LINE__, \ 122 | __ASSERT_FUNC, #x); \ 123 | } \ 124 | } while(0) 125 | #endif 126 | 127 | /** 128 | * Macro which can be used to check the error code. Prints the error code, error location, and the failed statement to 129 | * serial output. 130 | * In comparison with ESP_ERROR_CHECK(), this prints the same error message but isn't terminating the program. 131 | */ 132 | #ifdef NDEBUG 133 | #define ESP_ERROR_CHECK_WITHOUT_ABORT(x) ({ \ 134 | esp_err_t __err_rc = (x); \ 135 | __err_rc; \ 136 | }) 137 | #else 138 | #define ESP_ERROR_CHECK_WITHOUT_ABORT(x) ({ \ 139 | esp_err_t __err_rc = (x); \ 140 | if (__err_rc != ESP_OK) { \ 141 | _esp_error_check_failed_without_abort(__err_rc, __FILE__, __LINE__, \ 142 | __ASSERT_FUNC, #x); \ 143 | } \ 144 | __err_rc; \ 145 | }) 146 | #endif //NDEBUG 147 | 148 | #ifdef __cplusplus 149 | } 150 | #endif 151 | -------------------------------------------------------------------------------- /include/esp_event_base.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef ESP_EVENT_BASE_H_ 16 | #define ESP_EVENT_BASE_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | // Defines for declaring and defining event base 23 | #define ESP_EVENT_DECLARE_BASE(id) extern esp_event_base_t id 24 | #define ESP_EVENT_DEFINE_BASE(id) esp_event_base_t id = #id 25 | 26 | // Event loop library types 27 | typedef const char* esp_event_base_t; /**< unique pointer to a subsystem that exposes events */ 28 | typedef void* esp_event_loop_handle_t; /**< a number that identifies an event with respect to a base */ 29 | typedef void (*esp_event_handler_t)(void* event_handler_arg, 30 | esp_event_base_t event_base, 31 | int32_t event_id, 32 | void* event_data); /**< function called when an event is posted to the queue */ 33 | typedef void* esp_event_handler_instance_t; /**< context identifying an instance of a registered event handler */ 34 | 35 | // Defines for registering/unregistering event handlers 36 | #define ESP_EVENT_ANY_BASE NULL /**< register handler for any event base */ 37 | #define ESP_EVENT_ANY_ID -1 /**< register handler for any event id */ 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif // #ifndef ESP_EVENT_BASE_H_ 44 | -------------------------------------------------------------------------------- /include/esp_event_legacy.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | #include "esp_err.h" 21 | #include "esp_wifi_types.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** System event types enumeration */ 28 | typedef enum { 29 | SYSTEM_EVENT_WIFI_READY = 0, /*!< ESP32 WiFi ready */ 30 | SYSTEM_EVENT_SCAN_DONE, /*!< ESP32 finish scanning AP */ 31 | SYSTEM_EVENT_STA_START, /*!< ESP32 station start */ 32 | SYSTEM_EVENT_STA_STOP, /*!< ESP32 station stop */ 33 | SYSTEM_EVENT_STA_CONNECTED, /*!< ESP32 station connected to AP */ 34 | SYSTEM_EVENT_STA_DISCONNECTED, /*!< ESP32 station disconnected from AP */ 35 | SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /*!< the auth mode of AP connected by ESP32 station changed */ 36 | SYSTEM_EVENT_STA_GOT_IP, /*!< ESP32 station got IP from connected AP */ 37 | SYSTEM_EVENT_STA_LOST_IP, /*!< ESP32 station lost IP and the IP is reset to 0 */ 38 | SYSTEM_EVENT_STA_BSS_RSSI_LOW, /*!< ESP32 station connected BSS rssi goes below threshold */ 39 | SYSTEM_EVENT_STA_WPS_ER_SUCCESS, /*!< ESP32 station wps succeeds in enrollee mode */ 40 | SYSTEM_EVENT_STA_WPS_ER_FAILED, /*!< ESP32 station wps fails in enrollee mode */ 41 | SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, /*!< ESP32 station wps timeout in enrollee mode */ 42 | SYSTEM_EVENT_STA_WPS_ER_PIN, /*!< ESP32 station wps pin code in enrollee mode */ 43 | SYSTEM_EVENT_STA_WPS_ER_PBC_OVERLAP, /*!< ESP32 station wps overlap in enrollee mode */ 44 | SYSTEM_EVENT_AP_START, /*!< ESP32 soft-AP start */ 45 | SYSTEM_EVENT_AP_STOP, /*!< ESP32 soft-AP stop */ 46 | SYSTEM_EVENT_AP_STACONNECTED, /*!< a station connected to ESP32 soft-AP */ 47 | SYSTEM_EVENT_AP_STADISCONNECTED, /*!< a station disconnected from ESP32 soft-AP */ 48 | SYSTEM_EVENT_AP_STAIPASSIGNED, /*!< ESP32 soft-AP assign an IP to a connected station */ 49 | SYSTEM_EVENT_AP_PROBEREQRECVED, /*!< Receive probe request packet in soft-AP interface */ 50 | SYSTEM_EVENT_ACTION_TX_STATUS, /*!< Receive status of Action frame transmitted */ 51 | SYSTEM_EVENT_ROC_DONE, /*!< Indicates the completion of Remain-on-Channel operation status */ 52 | SYSTEM_EVENT_STA_BEACON_TIMEOUT, /*!< ESP32 station beacon timeout */ 53 | SYSTEM_EVENT_FTM_REPORT, /*!< Receive report of FTM procedure */ 54 | SYSTEM_EVENT_GOT_IP6, /*!< ESP32 station or ap or ethernet interface v6IP addr is preferred */ 55 | SYSTEM_EVENT_ETH_START, /*!< ESP32 ethernet start */ 56 | SYSTEM_EVENT_ETH_STOP, /*!< ESP32 ethernet stop */ 57 | SYSTEM_EVENT_ETH_CONNECTED, /*!< ESP32 ethernet phy link up */ 58 | SYSTEM_EVENT_ETH_DISCONNECTED, /*!< ESP32 ethernet phy link down */ 59 | SYSTEM_EVENT_ETH_GOT_IP, /*!< ESP32 ethernet got IP from connected AP */ 60 | SYSTEM_EVENT_MAX /*!< Number of members in this enum */ 61 | } system_event_id_t; 62 | 63 | /* add this macro define for compatible with old IDF version */ 64 | #ifndef SYSTEM_EVENT_AP_STA_GOT_IP6 65 | #define SYSTEM_EVENT_AP_STA_GOT_IP6 SYSTEM_EVENT_GOT_IP6 66 | #endif 67 | 68 | 69 | /** Argument structure of SYSTEM_EVENT_STA_WPS_ER_FAILED event */ 70 | typedef wifi_event_sta_wps_fail_reason_t system_event_sta_wps_fail_reason_t; 71 | 72 | /** Argument structure of SYSTEM_EVENT_SCAN_DONE event */ 73 | typedef wifi_event_sta_scan_done_t system_event_sta_scan_done_t; 74 | 75 | /** Argument structure of SYSTEM_EVENT_STA_CONNECTED event */ 76 | typedef wifi_event_sta_connected_t system_event_sta_connected_t; 77 | 78 | /** Argument structure of SYSTEM_EVENT_STA_DISCONNECTED event */ 79 | typedef wifi_event_sta_disconnected_t system_event_sta_disconnected_t; 80 | 81 | /** Argument structure of SYSTEM_EVENT_STA_AUTHMODE_CHANGE event */ 82 | typedef wifi_event_sta_authmode_change_t system_event_sta_authmode_change_t; 83 | 84 | /** Argument structure of SYSTEM_EVENT_STA_WPS_ER_PIN event */ 85 | typedef wifi_event_sta_wps_er_pin_t system_event_sta_wps_er_pin_t; 86 | 87 | /** Argument structure of SYSTEM_EVENT_STA_WPS_ER_PIN event */ 88 | typedef wifi_event_sta_wps_er_success_t system_event_sta_wps_er_success_t; 89 | 90 | /** Argument structure of event */ 91 | typedef wifi_event_ap_staconnected_t system_event_ap_staconnected_t; 92 | 93 | /** Argument structure of event */ 94 | typedef wifi_event_ap_stadisconnected_t system_event_ap_stadisconnected_t; 95 | 96 | /** Argument structure of event */ 97 | typedef wifi_event_ap_probe_req_rx_t system_event_ap_probe_req_rx_t; 98 | 99 | /** Argument structure of SYSTEM_EVENT_FTM_REPORT event */ 100 | typedef wifi_event_ftm_report_t system_event_ftm_report_t; 101 | 102 | /** Argument structure of event */ 103 | 104 | /** Argument structure of event */ 105 | 106 | /** Argument structure of event */ 107 | 108 | /** Union of all possible system_event argument structures */ 109 | typedef union { 110 | system_event_sta_connected_t connected; /*!< ESP32 station connected to AP */ 111 | system_event_sta_disconnected_t disconnected; /*!< ESP32 station disconnected to AP */ 112 | system_event_sta_scan_done_t scan_done; /*!< ESP32 station scan (APs) done */ 113 | system_event_sta_authmode_change_t auth_change; /*!< the auth mode of AP ESP32 station connected to changed */ 114 | system_event_sta_wps_er_pin_t sta_er_pin; /*!< ESP32 station WPS enrollee mode PIN code received */ 115 | system_event_sta_wps_fail_reason_t sta_er_fail_reason; /*!< ESP32 station WPS enrollee mode failed reason code received */ 116 | system_event_sta_wps_er_success_t sta_er_success; /*!< ESP32 station WPS enrollee success */ 117 | system_event_ap_staconnected_t sta_connected; /*!< a station connected to ESP32 soft-AP */ 118 | system_event_ap_stadisconnected_t sta_disconnected; /*!< a station disconnected to ESP32 soft-AP */ 119 | system_event_ap_probe_req_rx_t ap_probereqrecved; /*!< ESP32 soft-AP receive probe request packet */ 120 | system_event_ftm_report_t ftm_report; /*!< Report of FTM procedure */ 121 | } system_event_info_t; 122 | 123 | /** Event, as a tagged enum */ 124 | typedef struct { 125 | system_event_id_t event_id; /*!< event ID */ 126 | system_event_info_t event_info; /*!< event information */ 127 | } system_event_t; 128 | 129 | /** Event handler function type */ 130 | typedef esp_err_t (*system_event_handler_t)(esp_event_base_t event_base, 131 | int32_t event_id, 132 | void* event_data, 133 | size_t event_data_size, 134 | TickType_t ticks_to_wait); 135 | 136 | /** 137 | * @brief Send a event to event task 138 | * 139 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 140 | * 141 | * Other task/modules, such as the tcpip_adapter, can call this API to send an event to event task 142 | * 143 | * @param event Event to send 144 | * 145 | * @return ESP_OK : succeed 146 | * @return others : fail 147 | */ 148 | esp_err_t esp_event_send(system_event_t *event) __attribute__ ((deprecated)); 149 | 150 | /** 151 | * @brief Send a event to event task 152 | * 153 | * @note This API is used by WiFi Driver only. 154 | * 155 | * Other task/modules, such as the tcpip_adapter, can call this API to send an event to event task 156 | * 157 | * @param[in] event_base the event base that identifies the event 158 | * @param[in] event_id the event id that identifies the event 159 | * @param[in] event_data the data, specific to the event occurence, that gets passed to the handler 160 | * @param[in] event_data_size the size of the event data 161 | * @param[in] ticks_to_wait number of ticks to block on a full event queue 162 | * 163 | * @return ESP_OK : succeed 164 | * @return others : fail 165 | */ 166 | esp_err_t esp_event_send_internal(esp_event_base_t event_base, 167 | int32_t event_id, 168 | void* event_data, 169 | size_t event_data_size, 170 | TickType_t ticks_to_wait); 171 | 172 | /** 173 | * @brief Default event handler for system events 174 | * 175 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 176 | * 177 | * This function performs default handling of system events. 178 | * When using esp_event_loop APIs, it is called automatically before invoking the user-provided 179 | * callback function. 180 | * 181 | * Applications which implement a custom event loop must call this function 182 | * as part of event processing. 183 | * 184 | * @param event pointer to event to be handled 185 | * @return ESP_OK if an event was handled successfully 186 | */ 187 | esp_err_t esp_event_process_default(system_event_t *event) __attribute__ ((deprecated)); 188 | 189 | /** 190 | * @brief Install default event handlers for Ethernet interface 191 | * 192 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 193 | * 194 | */ 195 | void esp_event_set_default_eth_handlers(void); 196 | 197 | /** 198 | * @brief Install default event handlers for Wi-Fi interfaces (station and AP) 199 | * 200 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 201 | */ 202 | void esp_event_set_default_wifi_handlers(void) __attribute__ ((deprecated)); 203 | 204 | /** 205 | * @brief Application specified event callback function 206 | * 207 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 208 | * 209 | * 210 | * @param ctx reserved for user 211 | * @param event event type defined in this file 212 | * 213 | * @return 214 | * - ESP_OK: succeed 215 | * - others: fail 216 | */ 217 | typedef esp_err_t (*system_event_cb_t)(void *ctx, system_event_t *event); 218 | 219 | /** 220 | * @brief Initialize event loop 221 | * 222 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 223 | * 224 | * Create the event handler and task 225 | * 226 | * @param cb application specified event callback, it can be modified by call esp_event_set_cb 227 | * @param ctx reserved for user 228 | * 229 | * @return 230 | * - ESP_OK: succeed 231 | * - others: fail 232 | */ 233 | esp_err_t esp_event_loop_init(system_event_cb_t cb, void *ctx) __attribute__ ((deprecated)); 234 | 235 | /** 236 | * @brief Set application specified event callback function 237 | * 238 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 239 | * 240 | * @attention 1. If cb is NULL, means application don't need to handle 241 | * If cb is not NULL, it will be call when an event is received, after the default event callback is completed 242 | * 243 | * @param cb application callback function 244 | * @param ctx argument to be passed to callback 245 | * 246 | * 247 | * @return old callback 248 | */ 249 | system_event_cb_t esp_event_loop_set_cb(system_event_cb_t cb, void *ctx) __attribute__ ((deprecated)); 250 | 251 | #ifdef __cplusplus 252 | } 253 | #endif 254 | -------------------------------------------------------------------------------- /include/esp_interface.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef __ESP_INTERFACE_H__ 17 | #define __ESP_INTERFACE_H__ 18 | 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef enum { 26 | ESP_IF_WIFI_STA = 0, /**< ESP32 station interface */ 27 | ESP_IF_WIFI_AP, /**< ESP32 soft-AP interface */ 28 | ESP_IF_ETH, /**< ESP32 ethernet interface */ 29 | ESP_IF_MAX 30 | } esp_interface_t; 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | 37 | #endif /* __ESP_INTERFACE_TYPES_H__ */ 38 | -------------------------------------------------------------------------------- /include/esp_phy_init.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | #include 17 | #include 18 | #include "esp_err.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * @file PHY init parameters and API 26 | */ 27 | 28 | 29 | /** 30 | * @brief Structure holding PHY init parameters 31 | */ 32 | typedef struct { 33 | uint8_t params[128]; /*!< opaque PHY initialization parameters */ 34 | } esp_phy_init_data_t; 35 | 36 | /** 37 | * @brief Opaque PHY calibration data 38 | */ 39 | typedef struct { 40 | uint8_t version[4]; /*!< PHY version */ 41 | uint8_t mac[6]; /*!< The MAC address of the station */ 42 | uint8_t opaque[1894]; /*!< calibration data */ 43 | } esp_phy_calibration_data_t; 44 | 45 | typedef enum { 46 | PHY_RF_CAL_PARTIAL = 0x00000000, /*!< Do part of RF calibration. This should be used after power-on reset. */ 47 | PHY_RF_CAL_NONE = 0x00000001, /*!< Don't do any RF calibration. This mode is only suggested to be used after deep sleep reset. */ 48 | PHY_RF_CAL_FULL = 0x00000002 /*!< Do full RF calibration. Produces best results, but also consumes a lot of time and current. Suggested to be used once. */ 49 | } esp_phy_calibration_mode_t; 50 | 51 | #if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN 52 | /** 53 | * @brief PHY init data type 54 | */ 55 | typedef enum { 56 | ESP_PHY_INIT_DATA_TYPE_DEFAULT = 0, 57 | ESP_PHY_INIT_DATA_TYPE_SRRC, 58 | ESP_PHY_INIT_DATA_TYPE_FCC, 59 | ESP_PHY_INIT_DATA_TYPE_CE, 60 | ESP_PHY_INIT_DATA_TYPE_NCC, 61 | ESP_PHY_INIT_DATA_TYPE_KCC, 62 | ESP_PHY_INIT_DATA_TYPE_MIC, 63 | ESP_PHY_INIT_DATA_TYPE_IC, 64 | ESP_PHY_INIT_DATA_TYPE_ACMA, 65 | ESP_PHY_INIT_DATA_TYPE_ANATEL, 66 | ESP_PHY_INIT_DATA_TYPE_ISED, 67 | ESP_PHY_INIT_DATA_TYPE_WPC, 68 | ESP_PHY_INIT_DATA_TYPE_OFCA, 69 | ESP_PHY_INIT_DATA_TYPE_IFETEL, 70 | ESP_PHY_INIT_DATA_TYPE_RCM, 71 | ESP_PHY_INIT_DATA_TYPE_NUMBER, 72 | } phy_init_data_type_t; 73 | #endif 74 | 75 | /** 76 | * @brief Get PHY init data 77 | * 78 | * If "Use a partition to store PHY init data" option is set in menuconfig, 79 | * This function will load PHY init data from a partition. Otherwise, 80 | * PHY init data will be compiled into the application itself, and this function 81 | * will return a pointer to PHY init data located in read-only memory (DROM). 82 | * 83 | * If "Use a partition to store PHY init data" option is enabled, this function 84 | * may return NULL if the data loaded from flash is not valid. 85 | * 86 | * @note Call esp_phy_release_init_data to release the pointer obtained using 87 | * this function after the call to esp_wifi_init. 88 | * 89 | * @return pointer to PHY init data structure 90 | */ 91 | const esp_phy_init_data_t* esp_phy_get_init_data(void); 92 | 93 | /** 94 | * @brief Release PHY init data 95 | * @param data pointer to PHY init data structure obtained from 96 | * esp_phy_get_init_data function 97 | */ 98 | void esp_phy_release_init_data(const esp_phy_init_data_t* data); 99 | 100 | /** 101 | * @brief Function called by esp_phy_init to load PHY calibration data 102 | * 103 | * This is a convenience function which can be used to load PHY calibration 104 | * data from NVS. Data can be stored to NVS using esp_phy_store_cal_data_to_nvs 105 | * function. 106 | * 107 | * If calibration data is not present in the NVS, or 108 | * data is not valid (was obtained for a chip with a different MAC address, 109 | * or obtained for a different version of software), this function will 110 | * return an error. 111 | * 112 | * If "Initialize PHY in startup code" option is set in menuconfig, this 113 | * function will be used to load calibration data. To provide a different 114 | * mechanism for loading calibration data, disable 115 | * "Initialize PHY in startup code" option in menuconfig and call esp_phy_init 116 | * function from the application. For an example usage of esp_phy_init and 117 | * this function, see esp_phy_store_cal_data_to_nvs function in cpu_start.c 118 | * 119 | * @param out_cal_data pointer to calibration data structure to be filled with 120 | * loaded data. 121 | * @return ESP_OK on success 122 | */ 123 | esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_data); 124 | 125 | /** 126 | * @brief Function called by esp_phy_init to store PHY calibration data 127 | * 128 | * This is a convenience function which can be used to store PHY calibration 129 | * data to the NVS. Calibration data is returned by esp_phy_init function. 130 | * Data saved using this function to the NVS can later be loaded using 131 | * esp_phy_store_cal_data_to_nvs function. 132 | * 133 | * If "Initialize PHY in startup code" option is set in menuconfig, this 134 | * function will be used to store calibration data. To provide a different 135 | * mechanism for storing calibration data, disable 136 | * "Initialize PHY in startup code" option in menuconfig and call esp_phy_init 137 | * function from the application. 138 | * 139 | * @param cal_data pointer to calibration data which has to be saved. 140 | * @return ESP_OK on success 141 | */ 142 | esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_data); 143 | 144 | /** 145 | * @brief Erase PHY calibration data which is stored in the NVS 146 | * 147 | * This is a function which can be used to trigger full calibration as a last-resort remedy 148 | * if partial calibration is used. It can be called in the application based on some conditions 149 | * (e.g. an option provided in some diagnostic mode). 150 | * 151 | * @return ESP_OK on success 152 | * @return others on fail. Please refer to NVS API return value error number. 153 | */ 154 | esp_err_t esp_phy_erase_cal_data_in_nvs(void); 155 | 156 | /** 157 | * @brief Enable PHY and RF module 158 | * 159 | * PHY and RF module should be enabled in order to use WiFi or BT. 160 | * Now PHY and RF enabling job is done automatically when start WiFi or BT. Users should not 161 | * call this API in their application. 162 | * 163 | */ 164 | void esp_phy_enable(void); 165 | 166 | /** 167 | * @brief Disable PHY and RF module 168 | * 169 | * PHY module should be disabled in order to shutdown WiFi or BT. 170 | * Now PHY and RF disabling job is done automatically when stop WiFi or BT. Users should not 171 | * call this API in their application. 172 | * 173 | */ 174 | void esp_phy_disable(void); 175 | 176 | /** 177 | * @brief Load calibration data from NVS and initialize PHY and RF module 178 | */ 179 | void esp_phy_load_cal_and_init(void); 180 | 181 | #if CONFIG_MAC_BB_PD 182 | /** 183 | * @brief Initialize backup memory for MAC and Baseband power up/down 184 | */ 185 | void esp_mac_bb_pd_mem_init(void); 186 | 187 | /** 188 | * @brief Power up MAC and Baseband 189 | */ 190 | void esp_mac_bb_power_up(void); 191 | 192 | /** 193 | * @brief Power down MAC and Baseband 194 | */ 195 | void esp_mac_bb_power_down(void); 196 | #endif 197 | 198 | /** 199 | * @brief Enable WiFi/BT common clock 200 | * 201 | */ 202 | void esp_phy_common_clock_enable(void); 203 | 204 | /** 205 | * @brief Disable WiFi/BT common clock 206 | * 207 | */ 208 | void esp_phy_common_clock_disable(void); 209 | 210 | /** 211 | * @brief Get the time stamp when PHY/RF was switched on 212 | * @return return 0 if PHY/RF is never switched on. Otherwise return time in 213 | * microsecond since boot when phy/rf was last switched on 214 | */ 215 | int64_t esp_phy_rf_get_on_ts(void); 216 | 217 | /** 218 | * @brief Update the corresponding PHY init type according to the country code of Wi-Fi. 219 | */ 220 | esp_err_t esp_phy_update_country_info(const char *country); 221 | 222 | 223 | #if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN 224 | /** 225 | * @brief Apply PHY init bin to PHY 226 | * @return ESP_OK on success. 227 | * @return ESP_FAIL on fail. 228 | */ 229 | esp_err_t esp_phy_apply_phy_init_data(uint8_t *init_data); 230 | #endif 231 | 232 | /** 233 | * @brief Get PHY lib version 234 | * @return PHY lib version. 235 | */ 236 | char * get_phy_version_str(void); 237 | 238 | #ifdef __cplusplus 239 | } 240 | #endif 241 | -------------------------------------------------------------------------------- /include/esp_private/esp_wifi_private.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | #ifndef _ESP_WIFI_PRIVATE_H 15 | #define _ESP_WIFI_PRIVATE_H 16 | 17 | #include "sys/queue.h" 18 | #include "sdkconfig.h" 19 | #include "esp_wifi_crypto_types.h" 20 | #include "esp_private/wifi_os_adapter.h" 21 | 22 | 23 | #endif /* _ESP_WIFI_PRIVATE_H */ 24 | -------------------------------------------------------------------------------- /include/esp_private/esp_wifi_types_private.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _ESP_WIFI_TYPES_PRIVATE_H 16 | #define _ESP_WIFI_TYPES_PRIVATE_H 17 | 18 | #include 19 | #include 20 | #include "sys/queue.h" 21 | #include "esp_err.h" 22 | #include "esp_interface.h" 23 | #include "esp_event_base.h" 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/esp_private/wifi.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /* 16 | * All the APIs declared here are internal only APIs, it can only be used by 17 | * espressif internal modules, such as SSC, LWIP, TCPIP adapter etc, espressif 18 | * customers are not recommended to use them. 19 | * 20 | * If someone really want to use specified APIs declared in here, please contact 21 | * espressif AE/developer to make sure you know the limitations or risk of 22 | * the API, otherwise you may get unexpected behavior!!! 23 | * 24 | */ 25 | 26 | 27 | #ifndef __ESP_WIFI_INTERNAL_H__ 28 | #define __ESP_WIFI_INTERNAL_H__ 29 | 30 | #include 31 | #include 32 | #include "sys/queue.h" 33 | #include "esp_err.h" 34 | #include "esp_wifi_types.h" 35 | #include "esp_event.h" 36 | #include "esp_wifi.h" 37 | #include "esp_smartconfig.h" 38 | #include "wifi_types.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef struct { 45 | QueueHandle_t handle; /**< FreeRTOS queue handler */ 46 | void *storage; /**< storage for FreeRTOS queue */ 47 | } wifi_static_queue_t; 48 | 49 | /** 50 | * @brief WiFi log level 51 | * 52 | */ 53 | typedef enum { 54 | WIFI_LOG_NONE = 0, 55 | WIFI_LOG_ERROR , /*enabled by default*/ 56 | WIFI_LOG_WARNING, /*enabled by default*/ 57 | WIFI_LOG_INFO, /*enabled by default*/ 58 | WIFI_LOG_DEBUG, /*can be set in menuconfig*/ 59 | WIFI_LOG_VERBOSE, /*can be set in menuconfig*/ 60 | } wifi_log_level_t; 61 | 62 | /** 63 | * @brief WiFi log module definition 64 | * 65 | */ 66 | typedef enum { 67 | WIFI_LOG_MODULE_ALL = 0, /*all log modules */ 68 | WIFI_LOG_MODULE_WIFI, /*logs related to WiFi*/ 69 | WIFI_LOG_MODULE_COEX, /*logs related to WiFi and BT(or BLE) coexist*/ 70 | WIFI_LOG_MODULE_MESH, /*logs related to Mesh*/ 71 | } wifi_log_module_t; 72 | 73 | /** 74 | * @brief WiFi log submodule definition 75 | * 76 | */ 77 | #define WIFI_LOG_SUBMODULE_ALL (0) /*all log submodules*/ 78 | #define WIFI_LOG_SUBMODULE_INIT (1) /*logs related to initialization*/ 79 | #define WIFI_LOG_SUBMODULE_IOCTL (1<<1) /*logs related to API calling*/ 80 | #define WIFI_LOG_SUBMODULE_CONN (1<<2) /*logs related to connecting*/ 81 | #define WIFI_LOG_SUBMODULE_SCAN (1<<3) /*logs related to scaning*/ 82 | 83 | 84 | /** 85 | * @brief Initialize Wi-Fi Driver 86 | * Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer, 87 | * WiFi NVS structure among others. 88 | * 89 | * For the most part, you need not call this function directly. It gets called 90 | * from esp_wifi_init(). 91 | * 92 | * This function may be called, if you only need to initialize the Wi-Fi driver 93 | * without having to use the network stack on top. 94 | * 95 | * @param config provide WiFi init configuration 96 | * 97 | * @return 98 | * - ESP_OK: succeed 99 | * - ESP_ERR_NO_MEM: out of memory 100 | * - others: refer to error code esp_err.h 101 | */ 102 | esp_err_t esp_wifi_init_internal(const wifi_init_config_t *config); 103 | 104 | /** 105 | * @brief Deinitialize Wi-Fi Driver 106 | * Free resource for WiFi driver, such as WiFi control structure, RX/TX buffer, 107 | * WiFi NVS structure among others. 108 | * 109 | * For the most part, you need not call this function directly. It gets called 110 | * from esp_wifi_deinit(). 111 | * 112 | * This function may be called, if you call esp_wifi_init_internal to initialize 113 | * WiFi driver. 114 | * 115 | * @return 116 | * - ESP_OK: succeed 117 | * - others: refer to error code esp_err.h 118 | */ 119 | esp_err_t esp_wifi_deinit_internal(void); 120 | 121 | /** 122 | * @brief free the rx buffer which allocated by wifi driver 123 | * 124 | * @param void* buffer: rx buffer pointer 125 | */ 126 | void esp_wifi_internal_free_rx_buffer(void* buffer); 127 | 128 | /** 129 | * @brief transmit the buffer via wifi driver 130 | * 131 | * This API makes a copy of the input buffer and then forwards the buffer 132 | * copy to WiFi driver. 133 | * 134 | * @param wifi_interface_t wifi_if : wifi interface id 135 | * @param void *buffer : the buffer to be tansmit 136 | * @param uint16_t len : the length of buffer 137 | * 138 | * @return 139 | * - ESP_OK : Successfully transmit the buffer to wifi driver 140 | * - ESP_ERR_NO_MEM: out of memory 141 | * - ESP_ERR_WIFI_ARG: invalid argument 142 | * - ESP_ERR_WIFI_IF : WiFi interface is invalid 143 | * - ESP_ERR_WIFI_CONN : WiFi interface is not created, e.g. send the data to STA while WiFi mode is AP mode 144 | * - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started 145 | * - ESP_ERR_WIFI_STATE : WiFi internal state is not ready, e.g. WiFi is not started 146 | * - ESP_ERR_WIFI_NOT_ASSOC : WiFi is not associated 147 | * - ESP_ERR_WIFI_TX_DISALLOW : WiFi TX is disallowed, e.g. WiFi hasn't pass the authentication 148 | * - ESP_ERR_WIFI_POST : caller fails to post event to WiFi task 149 | */ 150 | int esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, uint16_t len); 151 | 152 | /** 153 | * @brief The net stack buffer reference counter callback function 154 | * 155 | */ 156 | typedef void (*wifi_netstack_buf_ref_cb_t)(void *netstack_buf); 157 | 158 | /** 159 | * @brief The net stack buffer free callback function 160 | * 161 | */ 162 | typedef void (*wifi_netstack_buf_free_cb_t)(void *netstack_buf); 163 | 164 | /** 165 | * @brief transmit the buffer by reference via wifi driver 166 | * 167 | * This API firstly increases the reference counter of the input buffer and 168 | * then forwards the buffer to WiFi driver. The WiFi driver will free the buffer 169 | * after processing it. Use esp_wifi_internal_tx() if the uplayer buffer doesn't 170 | * supports reference counter. 171 | * 172 | * @param wifi_if : wifi interface id 173 | * @param buffer : the buffer to be tansmit 174 | * @param len : the length of buffer 175 | * @param netstack_buf : the netstack buffer related to bufffer 176 | * 177 | * @return 178 | * - ESP_OK : Successfully transmit the buffer to wifi driver 179 | * - ESP_ERR_NO_MEM: out of memory 180 | * - ESP_ERR_WIFI_ARG: invalid argument 181 | * - ESP_ERR_WIFI_IF : WiFi interface is invalid 182 | * - ESP_ERR_WIFI_CONN : WiFi interface is not created, e.g. send the data to STA while WiFi mode is AP mode 183 | * - ESP_ERR_WIFI_NOT_STARTED : WiFi is not started 184 | * - ESP_ERR_WIFI_STATE : WiFi internal state is not ready, e.g. WiFi is not started 185 | * - ESP_ERR_WIFI_NOT_ASSOC : WiFi is not associated 186 | * - ESP_ERR_WIFI_TX_DISALLOW : WiFi TX is disallowed, e.g. WiFi hasn't pass the authentication 187 | * - ESP_ERR_WIFI_POST : caller fails to post event to WiFi task 188 | */ 189 | esp_err_t esp_wifi_internal_tx_by_ref(wifi_interface_t ifx, void *buffer, size_t len, void *netstack_buf); 190 | 191 | /** 192 | * @brief Initialize WAPI function when wpa_supplicant initialize. 193 | * 194 | * This API is privately used, be careful not open to external applicantion. 195 | * 196 | * @return 197 | * - ESP_OK : succeed 198 | * - ESP_ERR_WAPI_INTERNAL : Internal error 199 | */ 200 | esp_err_t esp_wifi_internal_wapi_init(void); 201 | 202 | /** 203 | * @brief De-initialize WAPI function when wpa_supplicant de-initialize. 204 | * 205 | * This API is privately used, be careful not open to external applicantion. 206 | * 207 | * @return 208 | * - ESP_OK : succeed 209 | */ 210 | esp_err_t esp_wifi_internal_wapi_deinit(void); 211 | 212 | /** 213 | * @brief register the net stack buffer reference increasing and free callback 214 | * 215 | * @param ref : net stack buffer reference callback 216 | * @param free: net stack buffer free callback 217 | * 218 | * @return 219 | * - ESP_OK : Successfully transmit the buffer to wifi driver 220 | * - others : failed to register the callback 221 | */ 222 | esp_err_t esp_wifi_internal_reg_netstack_buf_cb(wifi_netstack_buf_ref_cb_t ref, wifi_netstack_buf_free_cb_t free); 223 | 224 | 225 | /** 226 | * @brief The WiFi RX callback function 227 | * 228 | * Each time the WiFi need to forward the packets to high layer, the callback function will be called 229 | */ 230 | typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void *eb); 231 | 232 | /** 233 | * @brief Set the WiFi RX callback 234 | * 235 | * @attention 1. Currently we support only one RX callback for each interface 236 | * 237 | * @param wifi_interface_t ifx : interface 238 | * @param wifi_rxcb_t fn : WiFi RX callback 239 | * 240 | * @return 241 | * - ESP_OK : succeed 242 | * - others : fail 243 | */ 244 | esp_err_t esp_wifi_internal_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn); 245 | 246 | /** 247 | * @brief Notify WIFI driver that the station got ip successfully 248 | * 249 | * @return 250 | * - ESP_OK : succeed 251 | * - others : fail 252 | */ 253 | esp_err_t esp_wifi_internal_set_sta_ip(void); 254 | 255 | /** 256 | * @brief enable or disable transmitting WiFi MAC frame with fixed rate 257 | * 258 | * @attention 1. If fixed rate is enabled, both management and data frame are transmitted with fixed rate 259 | * @attention 2. Make sure that the receiver is able to receive the frame with the fixed rate if you want the frame to be received 260 | * 261 | * @param ifx : wifi interface 262 | * @param en : false - disable, true - enable 263 | * @param rate : PHY rate 264 | * 265 | * @return 266 | * - ERR_OK : succeed 267 | * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 268 | * - ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start 269 | * - ESP_ERR_WIFI_IF : invalid WiFi interface 270 | * - ESP_ERR_INVALID_ARG : invalid rate 271 | * - ESP_ERR_NOT_SUPPORTED : do not support to set fixed rate if TX AMPDU is enabled 272 | */ 273 | esp_err_t esp_wifi_internal_set_fix_rate(wifi_interface_t ifx, bool en, wifi_phy_rate_t rate); 274 | 275 | /** 276 | * @brief Start SmartConfig, config ESP device to connect AP. You need to broadcast information by phone APP. 277 | * Device sniffer special packets from the air that containing SSID and password of target AP. 278 | * 279 | * @attention 1. This API can be called in station or softAP-station mode. 280 | * @attention 2. Can not call esp_smartconfig_start twice before it finish, please call 281 | * esp_smartconfig_stop first. 282 | * 283 | * @param config pointer to smartconfig start configure structure 284 | * 285 | * @return 286 | * - ESP_OK: succeed 287 | * - others: fail 288 | */ 289 | esp_err_t esp_smartconfig_internal_start(const smartconfig_start_config_t *config); 290 | 291 | /** 292 | * @brief Stop SmartConfig, free the buffer taken by esp_smartconfig_start. 293 | * 294 | * @attention Whether connect to AP succeed or not, this API should be called to free 295 | * memory taken by smartconfig_start. 296 | * 297 | * @return 298 | * - ESP_OK: succeed 299 | * - others: fail 300 | */ 301 | esp_err_t esp_smartconfig_internal_stop(void); 302 | 303 | /** 304 | * @brief Check the MD5 values of the OS adapter header files in IDF and WiFi library 305 | * 306 | * @attention 1. It is used for internal CI version check 307 | * 308 | * @return 309 | * - ESP_OK : succeed 310 | * - ESP_WIFI_INVALID_ARG : MD5 check fail 311 | */ 312 | esp_err_t esp_wifi_internal_osi_funcs_md5_check(const char *md5); 313 | 314 | /** 315 | * @brief Check the MD5 values of the crypto types header files in IDF and WiFi library 316 | * 317 | * @attention 1. It is used for internal CI version check 318 | * 319 | * @return 320 | * - ESP_OK : succeed 321 | * - ESP_WIFI_INVALID_ARG : MD5 check fail 322 | */ 323 | esp_err_t esp_wifi_internal_crypto_funcs_md5_check(const char *md5); 324 | 325 | /** 326 | * @brief Check the MD5 values of the esp_wifi_types.h in IDF and WiFi library 327 | * 328 | * @attention 1. It is used for internal CI version check 329 | * 330 | * @return 331 | * - ESP_OK : succeed 332 | * - ESP_WIFI_INVALID_ARG : MD5 check fail 333 | */ 334 | esp_err_t esp_wifi_internal_wifi_type_md5_check(const char *md5); 335 | 336 | /** 337 | * @brief Check the MD5 values of the esp_wifi.h in IDF and WiFi library 338 | * 339 | * @attention 1. It is used for internal CI version check 340 | * 341 | * @return 342 | * - ESP_OK : succeed 343 | * - ESP_WIFI_INVALID_ARG : MD5 check fail 344 | */ 345 | esp_err_t esp_wifi_internal_esp_wifi_md5_check(const char *md5); 346 | 347 | /** 348 | * @brief Allocate a chunk of memory for WiFi driver 349 | * 350 | * @attention This API is not used for DMA memory allocation. 351 | * 352 | * @param size_t size : Size, in bytes, of the amount of memory to allocate 353 | * 354 | * @return A pointer to the memory allocated on success, NULL on failure 355 | */ 356 | void *wifi_malloc( size_t size ); 357 | 358 | /** 359 | * @brief Reallocate a chunk of memory for WiFi driver 360 | * 361 | * @attention This API is not used for DMA memory allocation. 362 | * 363 | * @param void * ptr : Pointer to previously allocated memory, or NULL for a new allocation. 364 | * @param size_t size : Size, in bytes, of the amount of memory to allocate 365 | * 366 | * @return A pointer to the memory allocated on success, NULL on failure 367 | */ 368 | void *wifi_realloc( void *ptr, size_t size ); 369 | 370 | /** 371 | * @brief Callocate memory for WiFi driver 372 | * 373 | * @attention This API is not used for DMA memory allocation. 374 | * 375 | * @param size_t n : Number of continuing chunks of memory to allocate 376 | * @param size_t size : Size, in bytes, of the amount of memory to allocate 377 | * 378 | * @return A pointer to the memory allocated on success, NULL on failure 379 | */ 380 | void *wifi_calloc( size_t n, size_t size ); 381 | 382 | /** 383 | * @brief Update WiFi MAC time 384 | * 385 | * @param uint32_t time_delta : time duration since the WiFi/BT common clock is disabled 386 | * 387 | * @return Always returns ESP_OK 388 | */ 389 | typedef esp_err_t (* wifi_mac_time_update_cb_t)( uint32_t time_delta ); 390 | 391 | /** 392 | * @brief Update WiFi MAC time 393 | * 394 | * @param uint32_t time_delta : time duration since the WiFi/BT common clock is disabled 395 | * 396 | * @return Always returns ESP_OK 397 | */ 398 | esp_err_t esp_wifi_internal_update_mac_time( uint32_t time_delta ); 399 | 400 | /** 401 | * @brief Set current WiFi log level 402 | * 403 | * @param level Log level. 404 | * 405 | * @return 406 | * - ESP_OK: succeed 407 | * - ESP_FAIL: level is invalid 408 | */ 409 | esp_err_t esp_wifi_internal_set_log_level(wifi_log_level_t level); 410 | 411 | /** 412 | * @brief Set current log module and submodule 413 | * 414 | * @param module Log module 415 | * @param submodule Log submodule 416 | * @param enable enable or disable 417 | * If module == 0 && enable == 0, all log modules are disabled. 418 | * If module == 0 && enable == 1, all log modules are enabled. 419 | * If submodule == 0 && enable == 0, all log submodules are disabled. 420 | * If submodule == 0 && enable == 1, all log submodules are enabled. 421 | * 422 | * @return 423 | * - ESP_OK: succeed 424 | * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 425 | * - ESP_ERR_WIFI_ARG: invalid argument 426 | */ 427 | esp_err_t esp_wifi_internal_set_log_mod(wifi_log_module_t module, uint32_t submodule, bool enable); 428 | 429 | /** 430 | * @brief Get current WiFi log info 431 | * 432 | * @param log_level the return log level. 433 | * @param log_mod the return log module and submodule 434 | * 435 | * @return 436 | * - ESP_OK: succeed 437 | */ 438 | esp_err_t esp_wifi_internal_get_log(wifi_log_level_t *log_level, uint32_t *log_mod); 439 | 440 | /** 441 | * @brief A general API to set/get WiFi internal configuration, it's for debug only 442 | * 443 | * @param cmd : ioctl command type 444 | * @param cfg : configuration for the command 445 | * 446 | * @return 447 | * - ESP_OK: succeed 448 | * - others: failed 449 | */ 450 | esp_err_t esp_wifi_internal_ioctl(int cmd, wifi_ioctl_config_t *cfg); 451 | 452 | /** 453 | * @brief Get the user-configured channel info 454 | * 455 | * @param ifx : WiFi interface 456 | * @param primary : store the configured primary channel 457 | * @param second : store the configured second channel 458 | * 459 | * @return 460 | * - ESP_OK: succeed 461 | */ 462 | esp_err_t esp_wifi_internal_get_config_channel(wifi_interface_t ifx, uint8_t *primary, uint8_t *second); 463 | 464 | /** 465 | * @brief Get the negotiated channel info after WiFi connection established 466 | * 467 | * @param ifx : WiFi interface 468 | * @param aid : the connection number when a STA connects to the softAP 469 | * @param primary : store the negotiated primary channel 470 | * @param second : store the negotiated second channel 471 | * @attention the aid param is only works when the ESP32 in softAP/softAP+STA mode 472 | * 473 | * @return 474 | * - ESP_OK: succeed 475 | */ 476 | esp_err_t esp_wifi_internal_get_negotiated_channel(wifi_interface_t ifx, uint8_t aid, uint8_t *primary, uint8_t *second); 477 | 478 | /** 479 | * @brief Get the negotiated bandwidth info after WiFi connection established 480 | * 481 | * @param ifx : WiFi interface 482 | * @param bw : store the negotiated bandwidth 483 | * 484 | * @return 485 | * - ESP_OK: succeed 486 | */ 487 | esp_err_t esp_wifi_internal_get_negotiated_bandwidth(wifi_interface_t ifx, uint8_t aid, uint8_t *bw); 488 | 489 | #if SOC_WIFI_HW_TSF 490 | /** 491 | * @brief Check if WiFi TSF is active 492 | * 493 | * @return 494 | * - true: Active 495 | * - false: Not active 496 | */ 497 | bool esp_wifi_internal_is_tsf_active(void); 498 | 499 | /** 500 | * @brief Update WIFI light sleep wake ahead time 501 | * 502 | */ 503 | void esp_wifi_internal_update_light_sleep_wake_ahead_time(uint32_t); 504 | #endif 505 | 506 | #if CONFIG_MAC_BB_PD 507 | /** 508 | * @brief Enable or disable powering down MAC and baseband when Wi-Fi is sleeping. 509 | * 510 | * @param enable : enable or disable 511 | * 512 | * @return 513 | * - ESP_OK: succeed 514 | */ 515 | esp_err_t esp_wifi_internal_set_mac_sleep(bool enable); 516 | 517 | /** 518 | * @brief mac bb sleep. 519 | */ 520 | void pm_mac_sleep(void); 521 | 522 | /** 523 | * @brief mac bb wakeup. 524 | */ 525 | void pm_mac_wakeup(void); 526 | #endif 527 | 528 | /** 529 | * @breif TxDone callback function type. Should be registered using esp_wifi_set_tx_done_cb() 530 | * 531 | * @param ifidx The interface id that the tx callback has been triggered from 532 | * @param data Pointer to the data transmitted 533 | * @param data_len Length of the data transmitted 534 | * @param txStatus True:if the data was transmitted sucessfully False: if data transmission failed 535 | */ 536 | typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data, uint16_t *data_len, bool txStatus); 537 | 538 | /** 539 | * @brief Register the txDone callback function of type wifi_tx_done_cb_t 540 | * 541 | * @param cb The callback function 542 | * 543 | * @return 544 | * - ESP_OK: succeed 545 | * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 546 | * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start 547 | */ 548 | esp_err_t esp_wifi_set_tx_done_cb(wifi_tx_done_cb_t cb); 549 | 550 | /** 551 | * @brief Set device spp amsdu attributes 552 | * 553 | * @param ifx: WiFi interface 554 | * @param spp_cap: spp amsdu capable 555 | * @param spp_req: spp amsdu require 556 | * 557 | * @return 558 | * - ESP_OK: succeed 559 | * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 560 | * - ESP_ERR_WIFI_IF : invalid WiFi interface 561 | */ 562 | esp_err_t esp_wifi_internal_set_spp_amsdu(wifi_interface_t ifidx, bool spp_cap, bool spp_req); 563 | 564 | /** 565 | * @brief Update WIFI light sleep default parameters 566 | * 567 | * @param min_freq_mhz: minimum frequency of DFS 568 | * @param max_freq_mhz: maximum frequency of DFS 569 | */ 570 | void esp_wifi_internal_update_light_sleep_default_params(int min_freq_mhz, int max_freq_mhz); 571 | 572 | /** 573 | * @brief Set the delay time for wifi to enter the sleep state when light sleep 574 | * 575 | * @param return_to_sleep_delay: minimum timeout time for waiting to receive 576 | * data, when no data is received during the timeout period, 577 | * the wifi enters the sleep process. 578 | */ 579 | void esp_wifi_set_sleep_delay_time(uint32_t return_to_sleep_delay); 580 | 581 | /** 582 | * @brief Set wifi keep alive time 583 | * 584 | * @param keep_alive_time: keep alive time 585 | */ 586 | void esp_wifi_set_keep_alive_time(uint32_t keep_alive_time); 587 | 588 | #ifdef __cplusplus 589 | } 590 | #endif 591 | 592 | #endif /* __ESP_WIFI_H__ */ 593 | -------------------------------------------------------------------------------- /include/esp_private/wifi_os_adapter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef ESP_WIFI_OS_ADAPTER_H_ 16 | #define ESP_WIFI_OS_ADAPTER_H_ 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define ESP_WIFI_OS_ADAPTER_VERSION 0x00000008 25 | #define ESP_WIFI_OS_ADAPTER_MAGIC 0xDEADBEAF 26 | 27 | #define OSI_FUNCS_TIME_BLOCKING 0xffffffff 28 | 29 | #define OSI_QUEUE_SEND_FRONT 0 30 | #define OSI_QUEUE_SEND_BACK 1 31 | #define OSI_QUEUE_SEND_OVERWRITE 2 32 | 33 | typedef struct { 34 | int32_t _version; 35 | bool (* _env_is_chip)(void); 36 | void (*_set_intr)(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio); 37 | void (*_clear_intr)(uint32_t intr_source, uint32_t intr_num); 38 | void (*_set_isr)(int32_t n, void *f, void *arg); 39 | void (*_ints_on)(uint32_t mask); 40 | void (*_ints_off)(uint32_t mask); 41 | bool (* _is_from_isr)(void); 42 | void *(* _spin_lock_create)(void); 43 | void (* _spin_lock_delete)(void *lock); 44 | uint32_t (*_wifi_int_disable)(void *wifi_int_mux); 45 | void (*_wifi_int_restore)(void *wifi_int_mux, uint32_t tmp); 46 | void (*_task_yield_from_isr)(void); 47 | void *(*_semphr_create)(uint32_t max, uint32_t init); 48 | void (*_semphr_delete)(void *semphr); 49 | int32_t (*_semphr_take)(void *semphr, uint32_t block_time_tick); 50 | int32_t (*_semphr_give)(void *semphr); 51 | void *(*_wifi_thread_semphr_get)(void); 52 | void *(*_mutex_create)(void); 53 | void *(*_recursive_mutex_create)(void); 54 | void (*_mutex_delete)(void *mutex); 55 | int32_t (*_mutex_lock)(void *mutex); 56 | int32_t (*_mutex_unlock)(void *mutex); 57 | void *(* _queue_create)(uint32_t queue_len, uint32_t item_size); 58 | void (* _queue_delete)(void *queue); 59 | int32_t (* _queue_send)(void *queue, void *item, uint32_t block_time_tick); 60 | int32_t (* _queue_send_from_isr)(void *queue, void *item, void *hptw); 61 | int32_t (* _queue_send_to_back)(void *queue, void *item, uint32_t block_time_tick); 62 | int32_t (* _queue_send_to_front)(void *queue, void *item, uint32_t block_time_tick); 63 | int32_t (* _queue_recv)(void *queue, void *item, uint32_t block_time_tick); 64 | uint32_t (* _queue_msg_waiting)(void *queue); 65 | void *(* _event_group_create)(void); 66 | void (* _event_group_delete)(void *event); 67 | uint32_t (* _event_group_set_bits)(void *event, uint32_t bits); 68 | uint32_t (* _event_group_clear_bits)(void *event, uint32_t bits); 69 | uint32_t (* _event_group_wait_bits)(void *event, uint32_t bits_to_wait_for, int clear_on_exit, int wait_for_all_bits, uint32_t block_time_tick); 70 | int32_t (* _task_create_pinned_to_core)(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id); 71 | int32_t (* _task_create)(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle); 72 | void (* _task_delete)(void *task_handle); 73 | void (* _task_delay)(uint32_t tick); 74 | int32_t (* _task_ms_to_tick)(uint32_t ms); 75 | void *(* _task_get_current_task)(void); 76 | int32_t (* _task_get_max_priority)(void); 77 | void *(* _malloc)(unsigned int size); 78 | void (* _free)(void *p); 79 | int32_t (* _event_post)(const char* event_base, int32_t event_id, void* event_data, size_t event_data_size, uint32_t ticks_to_wait); 80 | uint32_t (* _get_free_heap_size)(void); 81 | uint32_t (* _rand)(void); 82 | void (* _dport_access_stall_other_cpu_start_wrap)(void); 83 | void (* _dport_access_stall_other_cpu_end_wrap)(void); 84 | void (* _wifi_apb80m_request)(void); 85 | void (* _wifi_apb80m_release)(void); 86 | void (* _phy_disable)(void); 87 | void (* _phy_enable)(void); 88 | #if CONFIG_IDF_TARGET_ESP32 89 | void (* _phy_common_clock_enable)(void); 90 | void (* _phy_common_clock_disable)(void); 91 | #endif 92 | int (* _phy_update_country_info)(const char* country); 93 | int (* _read_mac)(uint8_t* mac, uint32_t type); 94 | void (* _timer_arm)(void *timer, uint32_t tmout, bool repeat); 95 | void (* _timer_disarm)(void *timer); 96 | void (* _timer_done)(void *ptimer); 97 | void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg); 98 | void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat); 99 | void (* _wifi_reset_mac)(void); 100 | void (* _wifi_clock_enable)(void); 101 | void (* _wifi_clock_disable)(void); 102 | void (* _wifi_rtc_enable_iso)(void); 103 | void (* _wifi_rtc_disable_iso)(void); 104 | int64_t (* _esp_timer_get_time)(void); 105 | int (* _nvs_set_i8)(uint32_t handle, const char* key, int8_t value); 106 | int (* _nvs_get_i8)(uint32_t handle, const char* key, int8_t* out_value); 107 | int (* _nvs_set_u8)(uint32_t handle, const char* key, uint8_t value); 108 | int (* _nvs_get_u8)(uint32_t handle, const char* key, uint8_t* out_value); 109 | int (* _nvs_set_u16)(uint32_t handle, const char* key, uint16_t value); 110 | int (* _nvs_get_u16)(uint32_t handle, const char* key, uint16_t* out_value); 111 | int (* _nvs_open)(const char* name, uint32_t open_mode, uint32_t *out_handle); 112 | void (* _nvs_close)(uint32_t handle); 113 | int (* _nvs_commit)(uint32_t handle); 114 | int (* _nvs_set_blob)(uint32_t handle, const char* key, const void* value, size_t length); 115 | int (* _nvs_get_blob)(uint32_t handle, const char* key, void* out_value, size_t* length); 116 | int (* _nvs_erase_key)(uint32_t handle, const char* key); 117 | int (* _get_random)(uint8_t *buf, size_t len); 118 | int (* _get_time)(void *t); 119 | unsigned long (* _random)(void); 120 | #if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 121 | uint32_t (* _slowclk_cal_get)(void); 122 | #endif 123 | void (* _log_write)(uint32_t level, const char* tag, const char* format, ...); 124 | void (* _log_writev)(uint32_t level, const char* tag, const char* format, va_list args); 125 | uint32_t (* _log_timestamp)(void); 126 | void * (* _malloc_internal)(size_t size); 127 | void * (* _realloc_internal)(void *ptr, size_t size); 128 | void * (* _calloc_internal)(size_t n, size_t size); 129 | void * (* _zalloc_internal)(size_t size); 130 | void * (* _wifi_malloc)(size_t size); 131 | void * (* _wifi_realloc)(void *ptr, size_t size); 132 | void * (* _wifi_calloc)(size_t n, size_t size); 133 | void * (* _wifi_zalloc)(size_t size); 134 | void * (* _wifi_create_queue)(int queue_len, int item_size); 135 | void (* _wifi_delete_queue)(void * queue); 136 | int (* _coex_init)(void); 137 | void (* _coex_deinit)(void); 138 | int (* _coex_enable)(void); 139 | void (* _coex_disable)(void); 140 | uint32_t (* _coex_status_get)(void); 141 | void (* _coex_condition_set)(uint32_t type, bool dissatisfy); 142 | int (* _coex_wifi_request)(uint32_t event, uint32_t latency, uint32_t duration); 143 | int (* _coex_wifi_release)(uint32_t event); 144 | int (* _coex_wifi_channel_set)(uint8_t primary, uint8_t secondary); 145 | int (* _coex_event_duration_get)(uint32_t event, uint32_t *duration); 146 | int (* _coex_pti_get)(uint32_t event, uint8_t *pti); 147 | void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status); 148 | void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status); 149 | int (* _coex_schm_interval_set)(uint32_t interval); 150 | uint32_t (* _coex_schm_interval_get)(void); 151 | uint8_t (* _coex_schm_curr_period_get)(void); 152 | void * (* _coex_schm_curr_phase_get)(void); 153 | int (* _coex_schm_curr_phase_idx_set)(int idx); 154 | int (* _coex_schm_curr_phase_idx_get)(void); 155 | int32_t _magic; 156 | } wifi_osi_funcs_t; 157 | 158 | extern wifi_osi_funcs_t g_wifi_osi_funcs; 159 | 160 | #ifdef __cplusplus 161 | } 162 | #endif 163 | 164 | #endif /* ESP_WIFI_OS_ADAPTER_H_ */ 165 | -------------------------------------------------------------------------------- /include/esp_private/wifi_types.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _WIFI_TYPES_H 16 | #define _WIFI_TYPES_H 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /** 23 | * @brief WiFi ioctl command type 24 | * 25 | */ 26 | typedef enum { 27 | WIFI_IOCTL_SET_STA_HT2040_COEX = 1, /**< Set the configuration of STA's HT2040 coexist management */ 28 | WIFI_IOCTL_GET_STA_HT2040_COEX, /**< Get the configuration of STA's HT2040 coexist management */ 29 | WIFI_IOCTL_MAX, 30 | } wifi_ioctl_cmd_t; 31 | 32 | /** 33 | * @brief Configuration for STA's HT2040 coexist management 34 | * 35 | */ 36 | typedef struct { 37 | int enable; /**< Indicate whether STA's HT2040 coexist management is enabled or not */ 38 | } wifi_ht2040_coex_t; 39 | 40 | /** 41 | * @brief Configuration for WiFi ioctl 42 | * 43 | */ 44 | typedef struct { 45 | union { 46 | wifi_ht2040_coex_t ht2040_coex; /**< Configuration of STA's HT2040 coexist management */ 47 | } data; /**< Configuration of ioctl command */ 48 | } wifi_ioctl_config_t; 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/esp_smartconfig.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef __ESP_SMARTCONFIG_H__ 16 | #define __ESP_SMARTCONFIG_H__ 17 | 18 | #include 19 | #include 20 | #include "esp_err.h" 21 | #include "esp_event_base.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef enum { 28 | SC_TYPE_ESPTOUCH = 0, /**< protocol: ESPTouch */ 29 | SC_TYPE_AIRKISS, /**< protocol: AirKiss */ 30 | SC_TYPE_ESPTOUCH_AIRKISS, /**< protocol: ESPTouch and AirKiss */ 31 | SC_TYPE_ESPTOUCH_V2, /**< protocol: ESPTouch v2*/ 32 | } smartconfig_type_t; 33 | 34 | /** Smartconfig event declarations */ 35 | typedef enum { 36 | SC_EVENT_SCAN_DONE, /*!< ESP32 station smartconfig has finished to scan for APs */ 37 | SC_EVENT_FOUND_CHANNEL, /*!< ESP32 station smartconfig has found the channel of the target AP */ 38 | SC_EVENT_GOT_SSID_PSWD, /*!< ESP32 station smartconfig got the SSID and password */ 39 | SC_EVENT_SEND_ACK_DONE, /*!< ESP32 station smartconfig has sent ACK to cellphone */ 40 | } smartconfig_event_t; 41 | 42 | /** @brief smartconfig event base declaration */ 43 | ESP_EVENT_DECLARE_BASE(SC_EVENT); 44 | 45 | /** Argument structure for SC_EVENT_GOT_SSID_PSWD event */ 46 | typedef struct { 47 | uint8_t ssid[32]; /**< SSID of the AP. Null terminated string. */ 48 | uint8_t password[64]; /**< Password of the AP. Null terminated string. */ 49 | bool bssid_set; /**< whether set MAC address of target AP or not. */ 50 | uint8_t bssid[6]; /**< MAC address of target AP. */ 51 | smartconfig_type_t type; /**< Type of smartconfig(ESPTouch or AirKiss). */ 52 | uint8_t token; /**< Token from cellphone which is used to send ACK to cellphone. */ 53 | uint8_t cellphone_ip[4]; /**< IP address of cellphone. */ 54 | } smartconfig_event_got_ssid_pswd_t; 55 | 56 | /** Configure structure for esp_smartconfig_start */ 57 | typedef struct { 58 | bool enable_log; /**< Enable smartconfig logs. */ 59 | bool esp_touch_v2_enable_crypt; /**< Enable ESPTouch v2 crypt. */ 60 | char *esp_touch_v2_key; /**< ESPTouch v2 crypt key, len should be 16. */ 61 | } smartconfig_start_config_t; 62 | 63 | #define SMARTCONFIG_START_CONFIG_DEFAULT() { \ 64 | .enable_log = false, \ 65 | .esp_touch_v2_enable_crypt = false,\ 66 | .esp_touch_v2_key = NULL \ 67 | }; 68 | 69 | /** 70 | * @brief Get the version of SmartConfig. 71 | * 72 | * @return 73 | * - SmartConfig version const char. 74 | */ 75 | const char *esp_smartconfig_get_version(void); 76 | 77 | /** 78 | * @brief Start SmartConfig, config ESP device to connect AP. You need to broadcast information by phone APP. 79 | * Device sniffer special packets from the air that containing SSID and password of target AP. 80 | * 81 | * @attention 1. This API can be called in station or softAP-station mode. 82 | * @attention 2. Can not call esp_smartconfig_start twice before it finish, please call 83 | * esp_smartconfig_stop first. 84 | * 85 | * @param config pointer to smartconfig start configure structure 86 | * 87 | * @return 88 | * - ESP_OK: succeed 89 | * - others: fail 90 | */ 91 | esp_err_t esp_smartconfig_start(const smartconfig_start_config_t *config); 92 | 93 | /** 94 | * @brief Stop SmartConfig, free the buffer taken by esp_smartconfig_start. 95 | * 96 | * @attention Whether connect to AP succeed or not, this API should be called to free 97 | * memory taken by smartconfig_start. 98 | * 99 | * @return 100 | * - ESP_OK: succeed 101 | * - others: fail 102 | */ 103 | esp_err_t esp_smartconfig_stop(void); 104 | 105 | /** 106 | * @brief Set timeout of SmartConfig process. 107 | * 108 | * @attention Timing starts from SC_STATUS_FIND_CHANNEL status. SmartConfig will restart if timeout. 109 | * 110 | * @param time_s range 15s~255s, offset:45s. 111 | * 112 | * @return 113 | * - ESP_OK: succeed 114 | * - others: fail 115 | */ 116 | esp_err_t esp_esptouch_set_timeout(uint8_t time_s); 117 | 118 | /** 119 | * @brief Set protocol type of SmartConfig. 120 | * 121 | * @attention If users need to set the SmartConfig type, please set it before calling 122 | * esp_smartconfig_start. 123 | * 124 | * @param type Choose from the smartconfig_type_t. 125 | * 126 | * @return 127 | * - ESP_OK: succeed 128 | * - others: fail 129 | */ 130 | esp_err_t esp_smartconfig_set_type(smartconfig_type_t type); 131 | 132 | /** 133 | * @brief Set mode of SmartConfig. default normal mode. 134 | * 135 | * @attention 1. Please call it before API esp_smartconfig_start. 136 | * @attention 2. Fast mode have corresponding APP(phone). 137 | * @attention 3. Two mode is compatible. 138 | * 139 | * @param enable false-disable(default); true-enable; 140 | * 141 | * @return 142 | * - ESP_OK: succeed 143 | * - others: fail 144 | */ 145 | esp_err_t esp_smartconfig_fast_mode(bool enable); 146 | 147 | /** 148 | * @brief Get reserved data of ESPTouch v2. 149 | * 150 | * @param rvd_data reserved data 151 | * @param len length of reserved data 152 | * 153 | * @return 154 | * - ESP_OK: succeed 155 | * - others: fail 156 | */ 157 | esp_err_t esp_smartconfig_get_rvd_data(uint8_t *rvd_data, uint8_t len); 158 | 159 | #ifdef __cplusplus 160 | } 161 | #endif 162 | 163 | #endif 164 | -------------------------------------------------------------------------------- /include/esp_system.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef __ESP_SYSTEM_H__ 16 | #define __ESP_SYSTEM_H__ 17 | 18 | #include 19 | #include 20 | #include "esp_err.h" 21 | 22 | #include "sdkconfig.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef enum { 29 | ESP_MAC_WIFI_STA, 30 | ESP_MAC_WIFI_SOFTAP, 31 | ESP_MAC_BT, 32 | ESP_MAC_ETH, 33 | } esp_mac_type_t; 34 | 35 | /** @cond */ 36 | #define TWO_UNIVERSAL_MAC_ADDR 2 37 | #define FOUR_UNIVERSAL_MAC_ADDR 4 38 | #if CONFIG_IDF_TARGET_ESP32 39 | #define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES 40 | #elif CONFIG_IDF_TARGET_ESP32S2 41 | #define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES 42 | #elif CONFIG_IDF_TARGET_ESP32C3 43 | #define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES 44 | #endif 45 | /** @endcond */ 46 | 47 | /** 48 | * @brief Reset reasons 49 | */ 50 | typedef enum { 51 | ESP_RST_UNKNOWN, //!< Reset reason can not be determined 52 | ESP_RST_POWERON, //!< Reset due to power-on event 53 | ESP_RST_EXT, //!< Reset by external pin (not applicable for ESP32) 54 | ESP_RST_SW, //!< Software reset via esp_restart 55 | ESP_RST_PANIC, //!< Software reset due to exception/panic 56 | ESP_RST_INT_WDT, //!< Reset (software or hardware) due to interrupt watchdog 57 | ESP_RST_TASK_WDT, //!< Reset due to task watchdog 58 | ESP_RST_WDT, //!< Reset due to other watchdogs 59 | ESP_RST_DEEPSLEEP, //!< Reset after exiting deep sleep mode 60 | ESP_RST_BROWNOUT, //!< Brownout reset (software or hardware) 61 | ESP_RST_SDIO, //!< Reset over SDIO 62 | } esp_reset_reason_t; 63 | 64 | /** 65 | * Shutdown handler type 66 | */ 67 | typedef void (*shutdown_handler_t)(void); 68 | 69 | /** 70 | * @brief Register shutdown handler 71 | * 72 | * This function allows you to register a handler that gets invoked before 73 | * the application is restarted using esp_restart function. 74 | * @param handle function to execute on restart 75 | * @return 76 | * - ESP_OK on success 77 | * - ESP_ERR_INVALID_STATE if the handler has already been registered 78 | * - ESP_ERR_NO_MEM if no more shutdown handler slots are available 79 | */ 80 | esp_err_t esp_register_shutdown_handler(shutdown_handler_t handle); 81 | 82 | /** 83 | * @brief Unregister shutdown handler 84 | * 85 | * This function allows you to unregister a handler which was previously 86 | * registered using esp_register_shutdown_handler function. 87 | * - ESP_OK on success 88 | * - ESP_ERR_INVALID_STATE if the given handler hasn't been registered before 89 | */ 90 | esp_err_t esp_unregister_shutdown_handler(shutdown_handler_t handle); 91 | 92 | 93 | /** 94 | * @brief Restart PRO and APP CPUs. 95 | * 96 | * This function can be called both from PRO and APP CPUs. 97 | * After successful restart, CPU reset reason will be SW_CPU_RESET. 98 | * Peripherals (except for WiFi, BT, UART0, SPI1, and legacy timers) are not reset. 99 | * This function does not return. 100 | */ 101 | void esp_restart(void) __attribute__ ((noreturn)); 102 | 103 | /** 104 | * @brief Get reason of last reset 105 | * @return See description of esp_reset_reason_t for explanation of each value. 106 | */ 107 | esp_reset_reason_t esp_reset_reason(void); 108 | 109 | /** 110 | * @brief Get the size of available heap. 111 | * 112 | * Note that the returned value may be larger than the maximum contiguous block 113 | * which can be allocated. 114 | * 115 | * @return Available heap size, in bytes. 116 | */ 117 | uint32_t esp_get_free_heap_size(void); 118 | 119 | /** 120 | * @brief Get the size of available internal heap. 121 | * 122 | * Note that the returned value may be larger than the maximum contiguous block 123 | * which can be allocated. 124 | * 125 | * @return Available internal heap size, in bytes. 126 | */ 127 | uint32_t esp_get_free_internal_heap_size(void); 128 | 129 | /** 130 | * @brief Get the minimum heap that has ever been available 131 | * 132 | * @return Minimum free heap ever available 133 | */ 134 | uint32_t esp_get_minimum_free_heap_size( void ); 135 | 136 | /** 137 | * @brief Get one random 32-bit word from hardware RNG 138 | * 139 | * The hardware RNG is fully functional whenever an RF subsystem is running (ie Bluetooth or WiFi is enabled). For 140 | * random values, call this function after WiFi or Bluetooth are started. 141 | * 142 | * If the RF subsystem is not used by the program, the function bootloader_random_enable() can be called to enable an 143 | * entropy source. bootloader_random_disable() must be called before RF subsystem or I2S peripheral are used. See these functions' 144 | * documentation for more details. 145 | * 146 | * Any time the app is running without an RF subsystem (or bootloader_random) enabled, RNG hardware should be 147 | * considered a PRNG. A very small amount of entropy is available due to pre-seeding while the IDF 148 | * bootloader is running, but this should not be relied upon for any use. 149 | * 150 | * @return Random value between 0 and UINT32_MAX 151 | */ 152 | uint32_t esp_random(void); 153 | 154 | /** 155 | * @brief Fill a buffer with random bytes from hardware RNG 156 | * 157 | * @note This function has the same restrictions regarding available entropy as esp_random() 158 | * 159 | * @param buf Pointer to buffer to fill with random numbers. 160 | * @param len Length of buffer in bytes 161 | */ 162 | void esp_fill_random(void *buf, size_t len); 163 | 164 | /** 165 | * @brief Set base MAC address with the MAC address which is stored in BLK3 of EFUSE or 166 | * external storage e.g. flash and EEPROM. 167 | * 168 | * Base MAC address is used to generate the MAC addresses used by the networking interfaces. 169 | * If using base MAC address stored in BLK3 of EFUSE or external storage, call this API to set base MAC 170 | * address with the MAC address which is stored in BLK3 of EFUSE or external storage before initializing 171 | * WiFi/BT/Ethernet. 172 | * 173 | * @note Base MAC must be a unicast MAC (least significant bit of first byte must be zero). 174 | * 175 | * @note If not using a valid OUI, set the "locally administered" bit 176 | * (bit value 0x02 in the first byte) to avoid collisions. 177 | * 178 | * @param mac base MAC address, length: 6 bytes. 179 | * 180 | * @return ESP_OK on success 181 | * ESP_ERR_INVALID_ARG If mac is NULL or is not a unicast MAC 182 | */ 183 | esp_err_t esp_base_mac_addr_set(const uint8_t *mac); 184 | 185 | /** 186 | * @brief Return base MAC address which is set using esp_base_mac_addr_set. 187 | * 188 | * @param mac base MAC address, length: 6 bytes. 189 | * 190 | * @return ESP_OK on success 191 | * ESP_ERR_INVALID_MAC base MAC address has not been set 192 | */ 193 | esp_err_t esp_base_mac_addr_get(uint8_t *mac); 194 | 195 | /** 196 | * @brief Return base MAC address which was previously written to BLK3 of EFUSE. 197 | * 198 | * Base MAC address is used to generate the MAC addresses used by the networking interfaces. 199 | * This API returns the custom base MAC address which was previously written to BLK3 of EFUSE. 200 | * Writing this EFUSE allows setting of a different (non-Espressif) base MAC address. It is also 201 | * possible to store a custom base MAC address elsewhere, see esp_base_mac_addr_set() for details. 202 | * 203 | * @param mac base MAC address, length: 6 bytes. 204 | * 205 | * @return ESP_OK on success 206 | * ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE 207 | * ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE 208 | */ 209 | esp_err_t esp_efuse_mac_get_custom(uint8_t *mac); 210 | 211 | /** 212 | * @brief Return base MAC address which is factory-programmed by Espressif in BLK0 of EFUSE. 213 | * 214 | * @param mac base MAC address, length: 6 bytes. 215 | * 216 | * @return ESP_OK on success 217 | */ 218 | esp_err_t esp_efuse_mac_get_default(uint8_t *mac); 219 | 220 | /** 221 | * @brief Read base MAC address and set MAC address of the interface. 222 | * 223 | * This function first get base MAC address using esp_base_mac_addr_get or reads base MAC address 224 | * from BLK0 of EFUSE. Then set the MAC address of the interface including wifi station, wifi softap, 225 | * bluetooth and ethernet. 226 | * 227 | * @param mac MAC address of the interface, length: 6 bytes. 228 | * @param type type of MAC address, 0:wifi station, 1:wifi softap, 2:bluetooth, 3:ethernet. 229 | * 230 | * @return ESP_OK on success 231 | */ 232 | esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type); 233 | 234 | /** 235 | * @brief Derive local MAC address from universal MAC address. 236 | * 237 | * This function derives a local MAC address from an universal MAC address. 238 | * A `definition of local vs universal MAC address can be found on Wikipedia 239 | * `. 240 | * In ESP32, universal MAC address is generated from base MAC address in EFUSE or other external storage. 241 | * Local MAC address is derived from the universal MAC address. 242 | * 243 | * @param local_mac Derived local MAC address, length: 6 bytes. 244 | * @param universal_mac Source universal MAC address, length: 6 bytes. 245 | * 246 | * @return ESP_OK on success 247 | */ 248 | esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac); 249 | 250 | /** 251 | * @brief Trigger a software abort 252 | * 253 | * @param details Details that will be displayed during panic handling. 254 | */ 255 | void __attribute__((noreturn)) esp_system_abort(const char* details); 256 | 257 | /** 258 | * @brief Chip models 259 | */ 260 | typedef enum { 261 | CHIP_ESP32 = 1, //!< ESP32 262 | CHIP_ESP32S2 = 2, //!< ESP32-S2 263 | CHIP_ESP32S3 = 4, //!< ESP32-S3 264 | CHIP_ESP32C3 = 5, //!< ESP32-C3 265 | } esp_chip_model_t; 266 | 267 | /* Chip feature flags, used in esp_chip_info_t */ 268 | #define CHIP_FEATURE_EMB_FLASH BIT(0) //!< Chip has embedded flash memory 269 | #define CHIP_FEATURE_WIFI_BGN BIT(1) //!< Chip has 2.4GHz WiFi 270 | #define CHIP_FEATURE_BLE BIT(4) //!< Chip has Bluetooth LE 271 | #define CHIP_FEATURE_BT BIT(5) //!< Chip has Bluetooth Classic 272 | 273 | /** 274 | * @brief The structure represents information about the chip 275 | */ 276 | typedef struct { 277 | esp_chip_model_t model; //!< chip model, one of esp_chip_model_t 278 | uint32_t features; //!< bit mask of CHIP_FEATURE_x feature flags 279 | uint8_t cores; //!< number of CPU cores 280 | uint8_t revision; //!< chip revision number 281 | } esp_chip_info_t; 282 | 283 | /** 284 | * @brief Fill an esp_chip_info_t structure with information about the chip 285 | * @param[out] out_info structure to be filled 286 | */ 287 | void esp_chip_info(esp_chip_info_t* out_info); 288 | 289 | 290 | #if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX 291 | /** 292 | * @brief Cache lock bug exists or not 293 | * 294 | * @return 295 | * - ture : bug exists 296 | * - false : bug not exists 297 | */ 298 | bool soc_has_cache_lock_bug(void); 299 | #endif 300 | 301 | #ifdef __cplusplus 302 | } 303 | #endif 304 | 305 | #endif /* __ESP_SYSTEM_H__ */ 306 | -------------------------------------------------------------------------------- /include/esp_timer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | /** 18 | * @file esp_timer.h 19 | * @brief microsecond-precision 64-bit timer API, replacement for ets_timer 20 | * 21 | * esp_timer APIs allow components to receive callbacks when a hardware timer 22 | * reaches certain value. The timer provides microsecond accuracy and 23 | * up to 64 bit range. Note that while the timer itself provides microsecond 24 | * accuracy, callbacks are dispatched from an auxiliary task. Some time is 25 | * needed to notify this task from timer ISR, and then to invoke the callback. 26 | * If more than one callback needs to be dispatched at any particular time, 27 | * each subsequent callback will be dispatched only when the previous callback 28 | * returns. Therefore, callbacks should not do much work; instead, they should 29 | * use RTOS notification mechanisms (queues, semaphores, event groups, etc.) to 30 | * pass information to other tasks. 31 | * 32 | * To be implemented: it should be possible to request the callback to be called 33 | * directly from the ISR. This reduces the latency, but has potential impact on 34 | * all other callbacks which need to be dispatched. This option should only be 35 | * used for simple callback functions, which do not take longer than a few 36 | * microseconds to run. 37 | * 38 | * Implementation note: on the ESP32, esp_timer APIs use the "legacy" FRC2 39 | * timer. Timer callbacks are called from a task running on the PRO CPU. 40 | */ 41 | 42 | #include 43 | #include 44 | #include 45 | #include "esp_err.h" 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /** 52 | * @brief Opaque type representing a single esp_timer 53 | */ 54 | typedef struct esp_timer* esp_timer_handle_t; 55 | 56 | /** 57 | * @brief Timer callback function type 58 | * @param arg pointer to opaque user-specific data 59 | */ 60 | typedef void (*esp_timer_cb_t)(void* arg); 61 | 62 | 63 | /** 64 | * @brief Method for dispatching timer callback 65 | */ 66 | typedef enum { 67 | ESP_TIMER_TASK, //!< Callback is called from timer task 68 | 69 | /* Not supported for now, provision to allow callbacks to run directly 70 | * from an ISR: 71 | 72 | ESP_TIMER_ISR, //!< Callback is called from timer ISR 73 | 74 | */ 75 | } esp_timer_dispatch_t; 76 | 77 | /** 78 | * @brief Timer configuration passed to esp_timer_create 79 | */ 80 | typedef struct { 81 | esp_timer_cb_t callback; //!< Function to call when timer expires 82 | void* arg; //!< Argument to pass to the callback 83 | esp_timer_dispatch_t dispatch_method; //!< Call the callback from task or from ISR 84 | const char* name; //!< Timer name, used in esp_timer_dump function 85 | bool skip_unhandled_events; //!< Skip unhandled events for periodic timers 86 | } esp_timer_create_args_t; 87 | 88 | /** 89 | * @brief Initialize esp_timer library 90 | * 91 | * @note This function is called from startup code. Applications do not need 92 | * to call this function before using other esp_timer APIs. 93 | * 94 | * @return 95 | * - ESP_OK on success 96 | * - ESP_ERR_NO_MEM if allocation has failed 97 | * - ESP_ERR_INVALID_STATE if already initialized 98 | * - other errors from interrupt allocator 99 | */ 100 | esp_err_t esp_timer_init(void); 101 | 102 | /** 103 | * @brief De-initialize esp_timer library 104 | * 105 | * @note Normally this function should not be called from applications 106 | * 107 | * @return 108 | * - ESP_OK on success 109 | * - ESP_ERR_INVALID_STATE if not yet initialized 110 | */ 111 | esp_err_t esp_timer_deinit(void); 112 | 113 | /** 114 | * @brief Create an esp_timer instance 115 | * 116 | * @note When done using the timer, delete it with esp_timer_delete function. 117 | * 118 | * @param create_args Pointer to a structure with timer creation arguments. 119 | * Not saved by the library, can be allocated on the stack. 120 | * @param[out] out_handle Output, pointer to esp_timer_handle_t variable which 121 | * will hold the created timer handle. 122 | * 123 | * @return 124 | * - ESP_OK on success 125 | * - ESP_ERR_INVALID_ARG if some of the create_args are not valid 126 | * - ESP_ERR_INVALID_STATE if esp_timer library is not initialized yet 127 | * - ESP_ERR_NO_MEM if memory allocation fails 128 | */ 129 | esp_err_t esp_timer_create(const esp_timer_create_args_t* create_args, 130 | esp_timer_handle_t* out_handle); 131 | 132 | /** 133 | * @brief Start one-shot timer 134 | * 135 | * Timer should not be running when this function is called. 136 | * 137 | * @param timer timer handle created using esp_timer_create 138 | * @param timeout_us timer timeout, in microseconds relative to the current moment 139 | * @return 140 | * - ESP_OK on success 141 | * - ESP_ERR_INVALID_ARG if the handle is invalid 142 | * - ESP_ERR_INVALID_STATE if the timer is already running 143 | */ 144 | esp_err_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us); 145 | 146 | /** 147 | * @brief Start a periodic timer 148 | * 149 | * Timer should not be running when this function is called. This function will 150 | * start the timer which will trigger every 'period' microseconds. 151 | * 152 | * @param timer timer handle created using esp_timer_create 153 | * @param period timer period, in microseconds 154 | * @return 155 | * - ESP_OK on success 156 | * - ESP_ERR_INVALID_ARG if the handle is invalid 157 | * - ESP_ERR_INVALID_STATE if the timer is already running 158 | */ 159 | esp_err_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period); 160 | 161 | /** 162 | * @brief Stop the timer 163 | * 164 | * This function stops the timer previously started using esp_timer_start_once 165 | * or esp_timer_start_periodic. 166 | * 167 | * @param timer timer handle created using esp_timer_create 168 | * @return 169 | * - ESP_OK on success 170 | * - ESP_ERR_INVALID_STATE if the timer is not running 171 | */ 172 | esp_err_t esp_timer_stop(esp_timer_handle_t timer); 173 | 174 | /** 175 | * @brief Delete an esp_timer instance 176 | * 177 | * The timer must be stopped before deleting. A one-shot timer which has expired 178 | * does not need to be stopped. 179 | * 180 | * @param timer timer handle allocated using esp_timer_create 181 | * @return 182 | * - ESP_OK on success 183 | * - ESP_ERR_INVALID_STATE if the timer is running 184 | */ 185 | esp_err_t esp_timer_delete(esp_timer_handle_t timer); 186 | 187 | /** 188 | * @brief Get time in microseconds since boot 189 | * @return number of microseconds since esp_timer_init was called (this normally 190 | * happens early during application startup). 191 | */ 192 | int64_t esp_timer_get_time(void); 193 | 194 | /** 195 | * @brief Get the timestamp when the next timeout is expected to occur 196 | * @return Timestamp of the nearest timer event, in microseconds. 197 | * The timebase is the same as for the values returned by esp_timer_get_time. 198 | */ 199 | int64_t esp_timer_get_next_alarm(void); 200 | 201 | /** 202 | * @brief Dump the list of timers to a stream 203 | * 204 | * If CONFIG_ESP_TIMER_PROFILING option is enabled, this prints the list of all 205 | * the existing timers. Otherwise, only the list active timers is printed. 206 | * 207 | * The format is: 208 | * 209 | * name period alarm times_armed times_triggered total_callback_run_time 210 | * 211 | * where: 212 | * 213 | * name — timer name (if CONFIG_ESP_TIMER_PROFILING is defined), or timer pointer 214 | * period — period of timer, in microseconds, or 0 for one-shot timer 215 | * alarm - time of the next alarm, in microseconds since boot, or 0 if the timer 216 | * is not started 217 | * 218 | * The following fields are printed if CONFIG_ESP_TIMER_PROFILING is defined: 219 | * 220 | * times_armed — number of times the timer was armed via esp_timer_start_X 221 | * times_triggered - number of times the callback was called 222 | * total_callback_run_time - total time taken by callback to execute, across all calls 223 | * 224 | * @param stream stream (such as stdout) to dump the information to 225 | * @return 226 | * - ESP_OK on success 227 | * - ESP_ERR_NO_MEM if can not allocate temporary buffer for the output 228 | */ 229 | esp_err_t esp_timer_dump(FILE* stream); 230 | 231 | #ifdef __cplusplus 232 | } 233 | #endif 234 | -------------------------------------------------------------------------------- /include/esp_wifi_crypto_types.h: -------------------------------------------------------------------------------- 1 | // Hardware crypto support Copyright 2017 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef __ESP_WIFI_CRYPTO_TYPES_H__ 17 | #define __ESP_WIFI_CRYPTO_TYPES_H__ 18 | 19 | /* This is an internal API header for configuring the implementation used for WiFi cryptographic 20 | operations. 21 | 22 | During normal operation, you don't need to use any of these types or functions in this header. 23 | See esp_wifi.h & esp_wifi_types.h instead. 24 | */ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #define ESP_WIFI_CRYPTO_VERSION 0x00000001 31 | 32 | /* 33 | * Enumeration for hash operations. 34 | * When WPA2 is connecting, this enum is used to 35 | * request a hash algorithm via crypto_hash_xxx functions. 36 | */ 37 | typedef enum { 38 | ESP_CRYPTO_HASH_ALG_MD5, ESP_CRYPTO_HASH_ALG_SHA1, 39 | ESP_CRYPTO_HASH_ALG_HMAC_MD5, ESP_CRYPTO_HASH_ALG_HMAC_SHA1, 40 | ESP_CRYPTO_HASH_ALG_SHA256, ESP_CRYPTO_HASH_ALG_HMAC_SHA256 41 | }esp_crypto_hash_alg_t; 42 | 43 | /* 44 | * Enumeration for block cipher operations. 45 | * When WPA2 is connecting, this enum is used to request a block 46 | * cipher algorithm via crypto_cipher_xxx functions. 47 | */ 48 | typedef enum { 49 | ESP_CRYPTO_CIPHER_NULL, ESP_CRYPTO_CIPHER_ALG_AES, ESP_CRYPTO_CIPHER_ALG_3DES, 50 | ESP_CRYPTO_CIPHER_ALG_DES, ESP_CRYPTO_CIPHER_ALG_RC2, ESP_CRYPTO_CIPHER_ALG_RC4 51 | } esp_crypto_cipher_alg_t; 52 | 53 | /* 54 | * This structure is about the algorithm when do crypto_hash operation, for detail, 55 | * please reference to the structure crypto_hash. 56 | */ 57 | typedef struct crypto_hash esp_crypto_hash_t; 58 | 59 | /* 60 | * This structure is about the algorithm when do crypto_cipher operation, for detail, 61 | * please reference to the structure crypto_cipher. 62 | */ 63 | typedef struct crypto_cipher esp_crypto_cipher_t; 64 | 65 | /** 66 | * @brief The AES callback function when do WPS connect. 67 | * 68 | * @param key Encryption key. 69 | * @param iv Encryption IV for CBC mode (16 bytes). 70 | * @param data Data to encrypt in-place. 71 | * @param data_len Length of data in bytes (must be divisible by 16) 72 | */ 73 | typedef int (*esp_aes_128_encrypt_t)(const unsigned char *key, const unsigned char *iv, unsigned char *data, int data_len); 74 | 75 | /** 76 | * @brief The AES callback function when do WPS connect. 77 | * 78 | * @param key Decryption key. 79 | * @param iv Decryption IV for CBC mode (16 bytes). 80 | * @param data Data to decrypt in-place. 81 | * @param data_len Length of data in bytes (must be divisible by 16) 82 | * 83 | */ 84 | typedef int (*esp_aes_128_decrypt_t)(const unsigned char *key, const unsigned char *iv, unsigned char *data, int data_len); 85 | 86 | /** 87 | * @brief The AES callback function when do STA connect. 88 | * 89 | * @param kek 16-octet Key encryption key (KEK). 90 | * @param n Length of the plaintext key in 64-bit units; 91 | * @param plain Plaintext key to be wrapped, n * 64 bits 92 | * @param cipher Wrapped key, (n + 1) * 64 bits 93 | * 94 | */ 95 | typedef int (*esp_aes_wrap_t)(const unsigned char *kek, int n, const unsigned char *plain, unsigned char *cipher); 96 | 97 | /** 98 | * @brief The AES callback function when do STA connect. 99 | * 100 | * @param kek 16-octet Key decryption key (KEK). 101 | * @param n Length of the plaintext key in 64-bit units; 102 | * @param cipher Wrapped key to be unwrapped, (n + 1) * 64 bits 103 | * @param plain Plaintext key, n * 64 bits 104 | * 105 | */ 106 | typedef int (*esp_aes_unwrap_t)(const unsigned char *kek, int n, const unsigned char *cipher, unsigned char *plain); 107 | 108 | /** 109 | * @brief The SHA256 callback function when do WPS connect. 110 | * 111 | * @param key Key for HMAC operations. 112 | * @param key_len Length of the key in bytes. 113 | * @param num_elem Number of elements in the data vector. 114 | * @param addr Pointers to the data areas. 115 | * @param len Lengths of the data blocks. 116 | * @param mac Buffer for the hash (32 bytes). 117 | * 118 | */ 119 | typedef int (*esp_hmac_sha256_vector_t)(const unsigned char *key, int key_len, int num_elem, 120 | const unsigned char *addr[], const int *len, unsigned char *mac); 121 | 122 | /** 123 | * @brief The AES callback function when do STA connect. 124 | * 125 | * @param key Key for PRF. 126 | * @param key_len Length of the key in bytes. 127 | * @param label A unique label for each purpose of the PRF. 128 | * @param data Extra data to bind into the key. 129 | * @param data_len Length of the data. 130 | * @param buf Buffer for the generated pseudo-random key. 131 | * @param buf_len Number of bytes of key to generate. 132 | * 133 | */ 134 | typedef int (*esp_sha256_prf_t)(const unsigned char *key, int key_len, const char *label, 135 | const unsigned char *data, int data_len, unsigned char *buf, int buf_len); 136 | 137 | /** 138 | * @brief HMAC-MD5 over data buffer (RFC 2104)' 139 | * 140 | * @key: Key for HMAC operations 141 | * @key_len: Length of the key in bytes 142 | * @data: Pointers to the data area 143 | * @data_len: Length of the data area 144 | * @mac: Buffer for the hash (16 bytes) 145 | * Returns: 0 on success, -1 on failure 146 | */ 147 | typedef int (*esp_hmac_md5_t)(const unsigned char *key, unsigned int key_len, const unsigned char *data, 148 | unsigned int data_len, unsigned char *mac); 149 | 150 | /** 151 | * @brief HMAC-MD5 over data vector (RFC 2104) 152 | * 153 | * @key: Key for HMAC operations 154 | * @key_len: Length of the key in bytes 155 | * @num_elem: Number of elements in the data vector 156 | * @addr: Pointers to the data areas 157 | * @len: Lengths of the data blocks 158 | * @mac: Buffer for the hash (16 bytes) 159 | * Returns: 0 on success, -1 on failure 160 | */ 161 | typedef int (*esp_hmac_md5_vector_t)(const unsigned char *key, unsigned int key_len, unsigned int num_elem, 162 | const unsigned char *addr[], const unsigned int *len, unsigned char *mac); 163 | 164 | /** 165 | * @brief HMAC-SHA1 over data buffer (RFC 2104) 166 | * 167 | * @key: Key for HMAC operations 168 | * @key_len: Length of the key in bytes 169 | * @data: Pointers to the data area 170 | * @data_len: Length of the data area 171 | * @mac: Buffer for the hash (20 bytes) 172 | * Returns: 0 on success, -1 of failure 173 | */ 174 | typedef int (*esp_hmac_sha1_t)(const unsigned char *key, unsigned int key_len, const unsigned char *data, 175 | unsigned int data_len, unsigned char *mac); 176 | 177 | /** 178 | * @brief HMAC-SHA1 over data vector (RFC 2104) 179 | * 180 | * @key: Key for HMAC operations 181 | * @key_len: Length of the key in bytes 182 | * @num_elem: Number of elements in the data vector 183 | * @addr: Pointers to the data areas 184 | * @len: Lengths of the data blocks 185 | * @mac: Buffer for the hash (20 bytes) 186 | * Returns: 0 on success, -1 on failure 187 | */ 188 | typedef int (*esp_hmac_sha1_vector_t)(const unsigned char *key, unsigned int key_len, unsigned int num_elem, 189 | const unsigned char *addr[], const unsigned int *len, unsigned char *mac); 190 | 191 | /** 192 | * @brief SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) 193 | * 194 | * @key: Key for PRF 195 | * @key_len: Length of the key in bytes 196 | * @label: A unique label for each purpose of the PRF 197 | * @data: Extra data to bind into the key 198 | * @data_len: Length of the data 199 | * @buf: Buffer for the generated pseudo-random key 200 | * @buf_len: Number of bytes of key to generate 201 | * Returns: 0 on success, -1 of failure 202 | * 203 | * This function is used to derive new, cryptographically separate keys from a 204 | * given key (e.g., PMK in IEEE 802.11i). 205 | */ 206 | typedef int (*esp_sha1_prf_t)(const unsigned char *key, unsigned int key_len, const char *label, 207 | const unsigned char *data, unsigned int data_len, unsigned char *buf, unsigned int buf_len); 208 | 209 | /** 210 | * @brief SHA-1 hash for data vector 211 | * 212 | * @num_elem: Number of elements in the data vector 213 | * @addr: Pointers to the data areas 214 | * @len: Lengths of the data blocks 215 | * @mac: Buffer for the hash 216 | * Returns: 0 on success, -1 on failure 217 | */ 218 | typedef int (*esp_sha1_vector_t)(unsigned int num_elem, const unsigned char *addr[], const unsigned int *len, 219 | unsigned char *mac); 220 | 221 | /** 222 | * @brief SHA1-based key derivation function (PBKDF2) for IEEE 802.11i 223 | * 224 | * @passphrase: ASCII passphrase 225 | * @ssid: SSID 226 | * @ssid_len: SSID length in bytes 227 | * @iterations: Number of iterations to run 228 | * @buf: Buffer for the generated key 229 | * @buflen: Length of the buffer in bytes 230 | * Returns: 0 on success, -1 of failure 231 | * 232 | * This function is used to derive PSK for WPA-PSK. For this protocol, 233 | * iterations is set to 4096 and buflen to 32. This function is described in 234 | * IEEE Std 802.11-2004, Clause H.4. The main construction is from PKCS#5 v2.0. 235 | */ 236 | typedef int (*esp_pbkdf2_sha1_t)(const char *passphrase, const char *ssid, unsigned int ssid_len, 237 | int iterations, unsigned char *buf, unsigned int buflen); 238 | 239 | /** 240 | * @brief XOR RC4 stream to given data with skip-stream-start 241 | * 242 | * @key: RC4 key 243 | * @keylen: RC4 key length 244 | * @skip: number of bytes to skip from the beginning of the RC4 stream 245 | * @data: data to be XOR'ed with RC4 stream 246 | * @data_len: buf length 247 | * Returns: 0 on success, -1 on failure 248 | * 249 | * Generate RC4 pseudo random stream for the given key, skip beginning of the 250 | * stream, and XOR the end result with the data buffer to perform RC4 251 | * encryption/decryption. 252 | */ 253 | typedef int (*esp_rc4_skip_t)(const unsigned char *key, unsigned int keylen, unsigned int skip, 254 | unsigned char *data, unsigned int data_len); 255 | 256 | /** 257 | * @brief MD5 hash for data vector 258 | * 259 | * @num_elem: Number of elements in the data vector 260 | * @addr: Pointers to the data areas 261 | * @len: Lengths of the data blocks 262 | * @mac: Buffer for the hash 263 | * Returns: 0 on success, -1 on failure 264 | */ 265 | typedef int (*esp_md5_vector_t)(unsigned int num_elem, const unsigned char *addr[], const unsigned int *len, 266 | unsigned char *mac); 267 | 268 | /** 269 | * @brief Encrypt one AES block 270 | * 271 | * @ctx: Context pointer from aes_encrypt_init() 272 | * @plain: Plaintext data to be encrypted (16 bytes) 273 | * @crypt: Buffer for the encrypted data (16 bytes) 274 | */ 275 | typedef void (*esp_aes_encrypt_t)(void *ctx, const unsigned char *plain, unsigned char *crypt); 276 | 277 | /** 278 | * @brief Initialize AES for encryption 279 | * 280 | * @key: Encryption key 281 | * @len: Key length in bytes (usually 16, i.e., 128 bits) 282 | * Returns: Pointer to context data or %NULL on failure 283 | */ 284 | typedef void * (*esp_aes_encrypt_init_t)(const unsigned char *key, unsigned int len); 285 | 286 | /** 287 | * @brief Deinitialize AES encryption 288 | * 289 | * @ctx: Context pointer from aes_encrypt_init() 290 | */ 291 | typedef void (*esp_aes_encrypt_deinit_t)(void *ctx); 292 | 293 | /** 294 | * @brief Decrypt one AES block 295 | * 296 | * @ctx: Context pointer from aes_encrypt_init() 297 | * @crypt: Encrypted data (16 bytes) 298 | * @plain: Buffer for the decrypted data (16 bytes) 299 | */ 300 | typedef void (*esp_aes_decrypt_t)(void *ctx, const unsigned char *crypt, unsigned char *plain); 301 | 302 | /** 303 | * @brief Initialize AES for decryption 304 | * 305 | * @key: Decryption key 306 | * @len: Key length in bytes (usually 16, i.e., 128 bits) 307 | * Returns: Pointer to context data or %NULL on failure 308 | */ 309 | typedef void * (*esp_aes_decrypt_init_t)(const unsigned char *key, unsigned int len); 310 | 311 | /** 312 | * @brief Deinitialize AES decryption 313 | * 314 | * @ctx: Context pointer from aes_encrypt_init() 315 | */ 316 | typedef void (*esp_aes_decrypt_deinit_t)(void *ctx); 317 | 318 | /** 319 | * @brief One-Key CBC MAC (OMAC1) hash with AES-128 for MIC computation 320 | * 321 | * @key: 128-bit key for the hash operation 322 | * @data: Data buffer for which a MIC is computed 323 | * @data_len: Length of data buffer in bytes 324 | * @mic: Buffer for MIC (128 bits, i.e., 16 bytes) 325 | * Returns: 0 on success, -1 on failure 326 | */ 327 | typedef int (*esp_omac1_aes_128_t)(const uint8_t *key, const uint8_t *data, size_t data_len, 328 | uint8_t *mic); 329 | 330 | /** 331 | * @brief Decrypt data using CCMP (Counter Mode CBC-MAC Protocol OR 332 | * Counter Mode Cipher Block Chaining Message Authentication 333 | * Code Protocol) which is used in IEEE 802.11i RSN standard. 334 | * @tk: 128-bit Temporal Key for obtained during 4-way handshake 335 | * @hdr: Pointer to IEEE802.11 frame headeri needed for AAD 336 | * @data: Pointer to encrypted data buffer 337 | * @data_len: Encrypted data length in bytes 338 | * @decrypted_len: Length of decrypted data 339 | * @espnow_pkt: Indicates if it's an ESPNOW packet 340 | * Returns: Pointer to decrypted data on success, NULL on failure 341 | */ 342 | typedef uint8_t * (*esp_ccmp_decrypt_t)(const uint8_t *tk, const uint8_t *ieee80211_hdr, 343 | const uint8_t *data, size_t data_len, 344 | size_t *decrypted_len, bool espnow_pkt); 345 | 346 | /** 347 | * @brief Encrypt data using CCMP (Counter Mode CBC-MAC Protocol OR 348 | * Counter Mode Cipher Block Chaining Message Authentication 349 | * Code Protocol) which is used in IEEE 802.11i RSN standard. 350 | * @tk: 128-bit Temporal Key for obtained during 4-way handshake 351 | * @frame: Pointer to IEEE802.11 frame including header 352 | * @len: Length of the frame including header 353 | * @hdrlen: Length of the header 354 | * @pn: Packet Number counter 355 | * @keyid: Key ID to be mentioned in CCMP Vector 356 | * @encrypted_len: Length of the encrypted frame including header 357 | */ 358 | typedef uint8_t * (*esp_ccmp_encrypt_t)(const uint8_t *tk, uint8_t *frame, size_t len, size_t hdrlen, 359 | uint8_t *pn, int keyid, size_t *encrypted_len); 360 | 361 | /** 362 | * @brief The crypto callback function structure used when do station security connect. 363 | * The structure can be set as software crypto or the crypto optimized by ESP32 364 | * hardware. 365 | */ 366 | typedef struct { 367 | uint32_t size; 368 | uint32_t version; 369 | esp_aes_wrap_t aes_wrap; /**< station connect function used when send EAPOL frame */ 370 | esp_aes_unwrap_t aes_unwrap; /**< station connect function used when decrypt key data */ 371 | esp_hmac_sha256_vector_t hmac_sha256_vector; /**< station connect function used when check MIC */ 372 | esp_sha256_prf_t sha256_prf; /**< station connect function used when check MIC */ 373 | esp_hmac_md5_t hmac_md5; 374 | esp_hmac_md5_vector_t hamc_md5_vector; 375 | esp_hmac_sha1_t hmac_sha1; 376 | esp_hmac_sha1_vector_t hmac_sha1_vector; 377 | esp_sha1_prf_t sha1_prf; 378 | esp_sha1_vector_t sha1_vector; 379 | esp_pbkdf2_sha1_t pbkdf2_sha1; 380 | esp_rc4_skip_t rc4_skip; 381 | esp_md5_vector_t md5_vector; 382 | esp_aes_encrypt_t aes_encrypt; 383 | esp_aes_encrypt_init_t aes_encrypt_init; 384 | esp_aes_encrypt_deinit_t aes_encrypt_deinit; 385 | esp_aes_decrypt_t aes_decrypt; 386 | esp_aes_decrypt_init_t aes_decrypt_init; 387 | esp_aes_decrypt_deinit_t aes_decrypt_deinit; 388 | esp_aes_128_encrypt_t aes_128_encrypt; 389 | esp_aes_128_decrypt_t aes_128_decrypt; 390 | esp_omac1_aes_128_t omac1_aes_128; 391 | esp_ccmp_decrypt_t ccmp_decrypt; 392 | esp_ccmp_encrypt_t ccmp_encrypt; 393 | }wpa_crypto_funcs_t; 394 | 395 | /** 396 | * @brief The crypto callback function structure used in mesh vendor IE encryption. The 397 | * structure can be set as software crypto or the crypto optimized by ESP32 398 | * hardware. 399 | */ 400 | typedef struct{ 401 | esp_aes_128_encrypt_t aes_128_encrypt; /**< function used in mesh vendor IE encryption */ 402 | esp_aes_128_decrypt_t aes_128_decrypt; /**< function used in mesh vendor IE decryption */ 403 | } mesh_crypto_funcs_t; 404 | 405 | #ifdef __cplusplus 406 | } 407 | #endif 408 | #endif 409 | -------------------------------------------------------------------------------- /include/esp_wifi_default.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _ESP_WIFI_DEFAULT_H 16 | #define _ESP_WIFI_DEFAULT_H 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /** 23 | * @brief Attaches wifi station interface to supplied netif 24 | * 25 | * @param esp_netif instance to attach the wifi station to 26 | * 27 | * @return 28 | * - ESP_OK on success 29 | * - ESP_FAIL if attach failed 30 | */ 31 | esp_err_t esp_netif_attach_wifi_station(esp_netif_t *esp_netif); 32 | 33 | /** 34 | * @brief Attaches wifi soft AP interface to supplied netif 35 | * 36 | * @param esp_netif instance to attach the wifi AP to 37 | * 38 | * @return 39 | * - ESP_OK on success 40 | * - ESP_FAIL if attach failed 41 | */ 42 | esp_err_t esp_netif_attach_wifi_ap(esp_netif_t *esp_netif); 43 | 44 | /** 45 | * @brief Sets default wifi event handlers for STA interface 46 | * 47 | * @return 48 | * - ESP_OK on success, error returned from esp_event_handler_register if failed 49 | */ 50 | esp_err_t esp_wifi_set_default_wifi_sta_handlers(void); 51 | 52 | /** 53 | * @brief Sets default wifi event handlers for STA interface 54 | * 55 | * @return 56 | * - ESP_OK on success, error returned from esp_event_handler_register if failed 57 | */ 58 | esp_err_t esp_wifi_set_default_wifi_ap_handlers(void); 59 | 60 | /** 61 | * @brief Clears default wifi event handlers for supplied network interface 62 | * 63 | * @param esp_netif instance of corresponding if object 64 | * 65 | * @return 66 | * - ESP_OK on success, error returned from esp_event_handler_register if failed 67 | */ 68 | esp_err_t esp_wifi_clear_default_wifi_driver_and_handlers(void *esp_netif); 69 | 70 | /** 71 | * @brief Creates default WIFI AP. In case of any init error this API aborts. 72 | * 73 | * @return pointer to esp-netif instance 74 | */ 75 | esp_netif_t* esp_netif_create_default_wifi_ap(void); 76 | 77 | /** 78 | * @brief Creates default WIFI STA. In case of any init error this API aborts. 79 | * 80 | * @return pointer to esp-netif instance 81 | */ 82 | esp_netif_t* esp_netif_create_default_wifi_sta(void); 83 | 84 | /** 85 | * @brief Creates esp_netif WiFi object based on the custom configuration. 86 | * 87 | * @attention This API DOES NOT register default handlers! 88 | * 89 | * @param[in] wifi_if type of wifi interface 90 | * @param[in] esp_netif_config inherent esp-netif configuration pointer 91 | * 92 | * @return pointer to esp-netif instance 93 | */ 94 | esp_netif_t* esp_netif_create_wifi(wifi_interface_t wifi_if, esp_netif_inherent_config_t *esp_netif_config); 95 | 96 | /** 97 | * @brief Creates default STA and AP network interfaces for esp-mesh. 98 | * 99 | * Both netifs are almost identical to the default station and softAP, but with 100 | * DHCP client and server disabled. Please note that the DHCP client is typically 101 | * enabled only if the device is promoted to a root node. 102 | * 103 | * Returns created interfaces which could be ignored setting parameters to NULL 104 | * if an application code does not need to save the interface instances 105 | * for further processing. 106 | * 107 | * @param[out] p_netif_sta pointer where the resultant STA interface is saved (if non NULL) 108 | * @param[out] p_netif_ap pointer where the resultant AP interface is saved (if non NULL) 109 | * 110 | * @return ESP_OK on success 111 | */ 112 | esp_err_t esp_netif_create_default_wifi_mesh_netifs(esp_netif_t **p_netif_sta, esp_netif_t **p_netif_ap); 113 | 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | 118 | #endif //_ESP_WIFI_DEFAULT_H 119 | -------------------------------------------------------------------------------- /include/esp_wpa.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef __ESP_WPA_H__ 16 | #define __ESP_WPA_H__ 17 | 18 | #include 19 | #include 20 | #include "esp_err.h" 21 | #include "esp_wifi_crypto_types.h" 22 | #include "esp_wifi_types.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** \defgroup WiFi_APIs WiFi Related APIs 29 | * @brief WiFi APIs 30 | */ 31 | 32 | /** @addtogroup WiFi_APIs 33 | * @{ 34 | */ 35 | 36 | /** \defgroup WPA_APIs WPS APIs 37 | * @brief ESP32 Supplicant APIs 38 | * 39 | */ 40 | 41 | /** @addtogroup WPA_APIs 42 | * @{ 43 | */ 44 | /* Crypto callback functions */ 45 | extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; 46 | /* Mesh crypto callback functions */ 47 | extern const mesh_crypto_funcs_t g_wifi_default_mesh_crypto_funcs; 48 | 49 | /** 50 | * @brief Supplicant initialization 51 | * 52 | * @return 53 | * - ESP_OK : succeed 54 | * - ESP_ERR_NO_MEM : out of memory 55 | */ 56 | esp_err_t esp_supplicant_init(void); 57 | 58 | /** 59 | * @brief Supplicant deinitialization 60 | * 61 | * @return 62 | * - ESP_OK : succeed 63 | * - others: failed 64 | */ 65 | esp_err_t esp_supplicant_deinit(void); 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* __ESP_WPA_H__ */ 80 | -------------------------------------------------------------------------------- /include/esp_wpa2.h: -------------------------------------------------------------------------------- 1 | // Hardware crypto support Copyright 2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _ESP_WPA2_H 16 | #define _ESP_WPA2_H 17 | 18 | #include 19 | 20 | #include "esp_err.h" 21 | 22 | typedef enum { 23 | ESP_EAP_TTLS_PHASE2_EAP, 24 | ESP_EAP_TTLS_PHASE2_MSCHAPV2, 25 | ESP_EAP_TTLS_PHASE2_MSCHAP, 26 | ESP_EAP_TTLS_PHASE2_PAP, 27 | ESP_EAP_TTLS_PHASE2_CHAP 28 | } esp_eap_ttls_phase2_types ; 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * @brief Enable wpa2 enterprise authentication. 36 | * 37 | * @attention 1. wpa2 enterprise authentication can only be used when ESP32 station is enabled. 38 | * @attention 2. wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method. 39 | * 40 | * @return 41 | * - ESP_OK: succeed. 42 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 43 | */ 44 | esp_err_t esp_wifi_sta_wpa2_ent_enable(void); 45 | 46 | /** 47 | * @brief Disable wpa2 enterprise authentication. 48 | * 49 | * @attention 1. wpa2 enterprise authentication can only be used when ESP32 station is enabled. 50 | * @attention 2. wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method. 51 | * 52 | * @return 53 | * - ESP_OK: succeed. 54 | */ 55 | esp_err_t esp_wifi_sta_wpa2_ent_disable(void); 56 | 57 | /** 58 | * @brief Set identity for PEAP/TTLS method. 59 | * 60 | * @attention The API only passes the parameter identity to the global pointer variable in wpa2 enterprise module. 61 | * 62 | * @param identity: point to address where stores the identity; 63 | * @param len: length of identity, limited to 1~127 64 | * 65 | * @return 66 | * - ESP_OK: succeed 67 | * - ESP_ERR_INVALID_ARG: fail(len <= 0 or len >= 128) 68 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 69 | */ 70 | esp_err_t esp_wifi_sta_wpa2_ent_set_identity(const unsigned char *identity, int len); 71 | 72 | /** 73 | * @brief Clear identity for PEAP/TTLS method. 74 | */ 75 | void esp_wifi_sta_wpa2_ent_clear_identity(void); 76 | 77 | /** 78 | * @brief Set username for PEAP/TTLS method. 79 | * 80 | * @attention The API only passes the parameter username to the global pointer variable in wpa2 enterprise module. 81 | * 82 | * @param username: point to address where stores the username; 83 | * @param len: length of username, limited to 1~127 84 | * 85 | * @return 86 | * - ESP_OK: succeed 87 | * - ESP_ERR_INVALID_ARG: fail(len <= 0 or len >= 128) 88 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 89 | */ 90 | esp_err_t esp_wifi_sta_wpa2_ent_set_username(const unsigned char *username, int len); 91 | 92 | /** 93 | * @brief Clear username for PEAP/TTLS method. 94 | */ 95 | void esp_wifi_sta_wpa2_ent_clear_username(void); 96 | 97 | /** 98 | * @brief Set password for PEAP/TTLS method.. 99 | * 100 | * @attention The API only passes the parameter password to the global pointer variable in wpa2 enterprise module. 101 | * 102 | * @param password: point to address where stores the password; 103 | * @param len: length of password(len > 0) 104 | * 105 | * @return 106 | * - ESP_OK: succeed 107 | * - ESP_ERR_INVALID_ARG: fail(len <= 0) 108 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 109 | */ 110 | esp_err_t esp_wifi_sta_wpa2_ent_set_password(const unsigned char *password, int len); 111 | 112 | /** 113 | * @brief Clear password for PEAP/TTLS method.. 114 | */ 115 | void esp_wifi_sta_wpa2_ent_clear_password(void); 116 | 117 | /** 118 | * @brief Set new password for MSCHAPv2 method.. 119 | * 120 | * @attention 1. The API only passes the parameter password to the global pointer variable in wpa2 enterprise module. 121 | * @attention 2. The new password is used to substitute the old password when eap-mschapv2 failure request message with error code ERROR_PASSWD_EXPIRED is received. 122 | * 123 | * @param new_password: point to address where stores the password; 124 | * @param len: length of password 125 | * 126 | * @return 127 | * - ESP_OK: succeed 128 | * - ESP_ERR_INVALID_ARG: fail(len <= 0) 129 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 130 | */ 131 | 132 | esp_err_t esp_wifi_sta_wpa2_ent_set_new_password(const unsigned char *new_password, int len); 133 | 134 | /** 135 | * @brief Clear new password for MSCHAPv2 method.. 136 | */ 137 | void esp_wifi_sta_wpa2_ent_clear_new_password(void); 138 | 139 | /** 140 | * @brief Set CA certificate for PEAP/TTLS method. 141 | * 142 | * @attention 1. The API only passes the parameter ca_cert to the global pointer variable in wpa2 enterprise module. 143 | * @attention 2. The ca_cert should be zero terminated. 144 | * 145 | * @param ca_cert: point to address where stores the CA certificate; 146 | * @param ca_cert_len: length of ca_cert 147 | * 148 | * @return 149 | * - ESP_OK: succeed 150 | */ 151 | esp_err_t esp_wifi_sta_wpa2_ent_set_ca_cert(const unsigned char *ca_cert, int ca_cert_len); 152 | 153 | /** 154 | * @brief Clear CA certificate for PEAP/TTLS method. 155 | */ 156 | void esp_wifi_sta_wpa2_ent_clear_ca_cert(void); 157 | 158 | /** 159 | * @brief Set client certificate and key. 160 | * 161 | * @attention 1. The API only passes the parameter client_cert, private_key and private_key_passwd to the global pointer variable in wpa2 enterprise module. 162 | * @attention 2. The client_cert, private_key and private_key_passwd should be zero terminated. 163 | * 164 | * @param client_cert: point to address where stores the client certificate; 165 | * @param client_cert_len: length of client certificate; 166 | * @param private_key: point to address where stores the private key; 167 | * @param private_key_len: length of private key, limited to 1~2048; 168 | * @param private_key_password: point to address where stores the private key password; 169 | * @param private_key_password_len: length of private key password; 170 | * 171 | * @return 172 | * - ESP_OK: succeed 173 | */ 174 | esp_err_t esp_wifi_sta_wpa2_ent_set_cert_key(const unsigned char *client_cert, int client_cert_len, const unsigned char *private_key, int private_key_len, const unsigned char *private_key_passwd, int private_key_passwd_len); 175 | 176 | /** 177 | * @brief Clear client certificate and key. 178 | */ 179 | void esp_wifi_sta_wpa2_ent_clear_cert_key(void); 180 | 181 | /** 182 | * @brief Set wpa2 enterprise certs time check(disable or not). 183 | * 184 | * @param true: disable wpa2 enterprise certs time check 185 | * @param false: enable wpa2 enterprise certs time check 186 | * 187 | * @return 188 | * - ESP_OK: succeed 189 | */ 190 | esp_err_t esp_wifi_sta_wpa2_ent_set_disable_time_check(bool disable); 191 | 192 | /** 193 | * @brief Get wpa2 enterprise certs time check(disable or not). 194 | * 195 | * @param disable: store disable value 196 | * 197 | * @return 198 | * - ESP_OK: succeed 199 | */ 200 | esp_err_t esp_wifi_sta_wpa2_ent_get_disable_time_check(bool *disable); 201 | 202 | /** 203 | * @brief Set wpa2 enterprise ttls phase2 method 204 | * 205 | * @param type: the type of phase 2 method to be used 206 | * 207 | * @return 208 | * - ESP_OK: succeed 209 | */ 210 | esp_err_t esp_wifi_sta_wpa2_ent_set_ttls_phase2_method(esp_eap_ttls_phase2_types type); 211 | 212 | #ifdef __cplusplus 213 | } 214 | #endif 215 | #endif 216 | -------------------------------------------------------------------------------- /include/espidf_types.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | #ifndef _ESPIDF_TYPES_H_ 15 | #define _ESPIDF_TYPES_H_ 16 | 17 | #include 18 | 19 | #define IDF_DEPRECATED(_s) 20 | 21 | enum esp_log_level_e 22 | { 23 | ESP_LOG_NONE, 24 | ESP_LOG_ERROR, 25 | ESP_LOG_WARN, 26 | ESP_LOG_INFO, 27 | ESP_LOG_DEBUG, 28 | ESP_LOG_VERBOSE 29 | }; 30 | 31 | typedef uint32_t TickType_t; 32 | typedef uint32_t UBaseType_t; 33 | typedef int32_t BaseType_t; 34 | 35 | typedef void* QueueHandle_t; 36 | 37 | typedef void* esp_netif_t; 38 | typedef void* esp_netif_inherent_config_t; 39 | 40 | struct ets_timer 41 | { 42 | struct timer_adpt *next; 43 | uint32_t expire; 44 | uint32_t period; 45 | void (*func)(void *priv); 46 | void *priv; 47 | }; 48 | 49 | #endif /* _ESPIDF_TYPES_H_ */ 50 | -------------------------------------------------------------------------------- /include/espidf_wifi.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | #ifndef _ESPIDF_WIFI_H_ 15 | #define _ESPIDF_WIFI_H_ 16 | 17 | #include "sdkconfig.h" 18 | #include "espidf_types.h" 19 | #include "esp_private/wifi_os_adapter.h" 20 | #include "esp_phy_init.h" 21 | #include "esp_private/wifi.h" 22 | #include "phy.h" 23 | #include "phy_init_data.h" 24 | #include "nvs.h" 25 | #include "esp_wpa.h" 26 | #include "esp_timer.h" 27 | #include "esp_system.h" 28 | #include "esp_wpa2.h" 29 | 30 | #endif /* _ESPIDF_WIFI_H_ */ 31 | -------------------------------------------------------------------------------- /include/phy.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | #include "esp_phy_init.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #define ESP_CAL_DATA_CHECK_FAIL 1 23 | 24 | /** 25 | * @file phy.h 26 | * @brief Declarations for functions provided by libphy.a 27 | */ 28 | 29 | /** 30 | * @brief Return ROM function pointer table from PHY library. 31 | */ 32 | void phy_get_romfunc_addr(void); 33 | 34 | /** 35 | * @brief Initialize PHY module and do RF calibration 36 | * @param[in] init_data Initialization parameters to be used by the PHY 37 | * @param[inout] cal_data As input, calibration data previously obtained. As output, will contain new calibration data. 38 | * @param[in] cal_mode RF calibration mode 39 | * @return ESP_CAL_DATA_CHECK_FAIL if calibration data checksum fails, other values are reserved for future use 40 | */ 41 | int register_chipv7_phy(const esp_phy_init_data_t* init_data, esp_phy_calibration_data_t *cal_data, esp_phy_calibration_mode_t cal_mode); 42 | 43 | /** 44 | * @brief Get the format version of calibration data used by PHY library. 45 | * @return Format version number, OR'ed with BIT(16) if PHY is in WIFI only mode. 46 | */ 47 | uint32_t phy_get_rf_cal_version(void); 48 | 49 | /** 50 | * @brief Set RF/BB for only WIFI mode or coexist(WIFI & BT) mode 51 | * @param[in] true is for only WIFI mode, false is for coexist mode. default is 0. 52 | * @return NULL 53 | */ 54 | void phy_set_wifi_mode_only(bool wifi_only); 55 | 56 | /** 57 | * @brief Set BT the highest priority in coexist mode. 58 | * @return NULL 59 | */ 60 | void coex_bt_high_prio(void); 61 | 62 | /** 63 | * @brief Open PHY and RF. 64 | */ 65 | void phy_wakeup_init(void); 66 | 67 | /** 68 | * @brief Shutdown PHY and RF. 69 | */ 70 | void phy_close_rf(void); 71 | 72 | #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 73 | /** 74 | * @brief Disable PHY temperature sensor. 75 | */ 76 | void phy_xpd_tsens(void); 77 | #endif 78 | 79 | /** 80 | * @brief Store and load PHY digital registers. 81 | * 82 | * @param backup_en if backup_en is true, store PHY digital registers to memory. Otherwise load PHY digital registers from memory 83 | * @param mem_addr Memory address to store and load PHY digital registers 84 | * 85 | * @return memory size 86 | */ 87 | uint8_t phy_dig_reg_backup(bool backup_en, uint32_t *mem_addr); 88 | 89 | #if CONFIG_MAC_BB_PD 90 | /** 91 | * @brief Store and load baseband registers. 92 | */ 93 | void phy_freq_mem_backup(bool backup_en, uint32_t *mem); 94 | #endif 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | -------------------------------------------------------------------------------- /libs/esp32/libbtdm_app.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libbtdm_app.a -------------------------------------------------------------------------------- /libs/esp32/libcoexist.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libcoexist.a -------------------------------------------------------------------------------- /libs/esp32/libcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libcore.a -------------------------------------------------------------------------------- /libs/esp32/libespnow.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libespnow.a -------------------------------------------------------------------------------- /libs/esp32/libmesh.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libmesh.a -------------------------------------------------------------------------------- /libs/esp32/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libnet80211.a -------------------------------------------------------------------------------- /libs/esp32/libphy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libphy.a -------------------------------------------------------------------------------- /libs/esp32/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libpp.a -------------------------------------------------------------------------------- /libs/esp32/librtc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/librtc.a -------------------------------------------------------------------------------- /libs/esp32/libsmartconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libsmartconfig.a -------------------------------------------------------------------------------- /libs/esp32/libwapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libwapi.a -------------------------------------------------------------------------------- /libs/esp32/libwpa_supplicant.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32/libwpa_supplicant.a -------------------------------------------------------------------------------- /libs/esp32c3/libbtbb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libbtbb.a -------------------------------------------------------------------------------- /libs/esp32c3/libbtdm_app.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libbtdm_app.a -------------------------------------------------------------------------------- /libs/esp32c3/libcoexist.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libcoexist.a -------------------------------------------------------------------------------- /libs/esp32c3/libcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libcore.a -------------------------------------------------------------------------------- /libs/esp32c3/libespnow.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libespnow.a -------------------------------------------------------------------------------- /libs/esp32c3/libmesh.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libmesh.a -------------------------------------------------------------------------------- /libs/esp32c3/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libnet80211.a -------------------------------------------------------------------------------- /libs/esp32c3/libphy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libphy.a -------------------------------------------------------------------------------- /libs/esp32c3/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libpp.a -------------------------------------------------------------------------------- /libs/esp32c3/libsmartconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libsmartconfig.a -------------------------------------------------------------------------------- /libs/esp32c3/libwapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libwapi.a -------------------------------------------------------------------------------- /libs/esp32c3/libwpa_supplicant.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-wireless-drivers-3rdparty/45701c0dd3a2b8f4bfe07ab0c1cecc45de8ecaaf/libs/esp32c3/libwpa_supplicant.a -------------------------------------------------------------------------------- /patch/esp32/sdkconfig.h: -------------------------------------------------------------------------------- 1 | 2 | /* Options for Nuttx */ 3 | 4 | #undef CONFIG_ESP32_WIFI_NVS_ENABLED 5 | #ifdef CONFIG_ESP32_WIFI_SAVE_PARAM 6 | #define CONFIG_ESP32_WIFI_NVS_ENABLED 1 7 | #else 8 | #define CONFIG_ESP32_WIFI_NVS_ENABLED 0 9 | #endif 10 | 11 | #define CONFIG_MAC_BB_PD 0 12 | #define SOC_WIFI_HW_TSF 0 13 | #define CONFIG_ESP32_WIFI_AMSDU_TX_ENABLED 0 14 | 15 | #define CONFIG_WPA_MBEDTLS_CRYPTO 0 16 | #define CONFIG_ESP32_ECO3_CACHE_LOCK_FIX 0 17 | #define CONFIG_IDF_TARGET_ESP32S2 0 18 | #define CONFIG_IDF_TARGET_ESP32S3 0 19 | #define CONFIG_IDF_TARGET_ESP32C3 0 20 | #define CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN 0 21 | #define CONFIG_ESP32_WIFI_CSI_ENABLED 0 22 | #define CONFIG_NEWLIB_NANO_FORMAT 0 23 | #define CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 0 24 | #define CONFIG_ESP32_SPIRAM_SUPPORT 0 25 | #define CONFIG_ESP32S2_SPIRAM_SUPPORT 0 26 | #define CONFIG_ESP32S3_SPIRAM_SUPPORT 0 27 | 28 | #define CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE 0 29 | 30 | #define SOC_COEX_HW_PTI 0 31 | 32 | #define ESP_TASK_BT_CONTROLLER_STACK 0 33 | #define ESP_TASK_BT_CONTROLLER_PRIO 0 34 | -------------------------------------------------------------------------------- /patch/esp32c3/sdkconfig.h: -------------------------------------------------------------------------------- 1 | 2 | /* Options for Nuttx */ 3 | 4 | #undef CONFIG_ESP32_WIFI_NVS_ENABLED 5 | #ifdef CONFIG_ESP32C3_WIFI_SAVE_PARAM 6 | #define CONFIG_ESP32_WIFI_NVS_ENABLED 1 7 | #else 8 | #define CONFIG_ESP32_WIFI_NVS_ENABLED 0 9 | #endif 10 | 11 | #define CONFIG_MAC_BB_PD 0 12 | #define SOC_WIFI_HW_TSF 1 13 | #define CONFIG_ESP32_WIFI_AMSDU_TX_ENABLED 0 14 | 15 | #define CONFIG_WPA_MBEDTLS_CRYPTO 0 16 | #define CONFIG_ESP32_ECO3_CACHE_LOCK_FIX 0 17 | #define CONFIG_IDF_TARGET_ESP32 0 18 | #define CONFIG_IDF_TARGET_ESP32S2 0 19 | #define CONFIG_IDF_TARGET_ESP32S3 0 20 | #define CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN 0 21 | #define CONFIG_ESP32_WIFI_CSI_ENABLED 0 22 | #define CONFIG_NEWLIB_NANO_FORMAT 0 23 | #define CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 0 24 | #define CONFIG_ESP32_SPIRAM_SUPPORT 0 25 | #define CONFIG_ESP32S2_SPIRAM_SUPPORT 0 26 | #define CONFIG_ESP32S3_SPIRAM_SUPPORT 0 27 | 28 | #define CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE 0 29 | 30 | #define SOC_COEX_HW_PTI 1 31 | 32 | #define ESP_TASK_BT_CONTROLLER_STACK 0 33 | #define ESP_TASK_BT_CONTROLLER_PRIO 0 34 | -------------------------------------------------------------------------------- /patch/espidf_types.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | #ifndef _ESPIDF_TYPES_H_ 15 | #define _ESPIDF_TYPES_H_ 16 | 17 | #include 18 | 19 | #define IDF_DEPRECATED(_s) 20 | 21 | enum esp_log_level_e 22 | { 23 | ESP_LOG_NONE, 24 | ESP_LOG_ERROR, 25 | ESP_LOG_WARN, 26 | ESP_LOG_INFO, 27 | ESP_LOG_DEBUG, 28 | ESP_LOG_VERBOSE 29 | }; 30 | 31 | typedef uint32_t TickType_t; 32 | typedef uint32_t UBaseType_t; 33 | typedef int32_t BaseType_t; 34 | 35 | typedef void* QueueHandle_t; 36 | 37 | typedef void* esp_netif_t; 38 | typedef void* esp_netif_inherent_config_t; 39 | 40 | struct ets_timer 41 | { 42 | struct timer_adpt *next; 43 | uint32_t expire; 44 | uint32_t period; 45 | void (*func)(void *priv); 46 | void *priv; 47 | }; 48 | 49 | #endif /* _ESPIDF_TYPES_H_ */ 50 | -------------------------------------------------------------------------------- /patch/espidf_wifi.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | #ifndef _ESPIDF_WIFI_H_ 15 | #define _ESPIDF_WIFI_H_ 16 | 17 | #include "sdkconfig.h" 18 | #include "espidf_types.h" 19 | #include "esp_private/wifi_os_adapter.h" 20 | #include "esp_phy_init.h" 21 | #include "esp_private/wifi.h" 22 | #include "phy.h" 23 | #include "phy_init_data.h" 24 | #include "nvs.h" 25 | #include "esp_wpa.h" 26 | #include "esp_timer.h" 27 | #include "esp_system.h" 28 | #include "esp_wpa2.h" 29 | 30 | #endif /* _ESPIDF_WIFI_H_ */ 31 | -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- 1 | qa-test-v4.3-20210430-12-g918b3f9 commit 918b3f901955b02a7ac30463d3240111b3d13c0a 2 | --------------------------------------------------------------------------------