mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-03 16:41:44 +01:00
Merge branch 'feature/derive_esp_wifi_from_esp32' into 'master'
derive esp_wifi from esp32 component See merge request idf/esp-idf!4602
This commit is contained in:
@@ -13,7 +13,6 @@ else()
|
||||
"cache_err_int.c"
|
||||
"cache_sram_mmu.c"
|
||||
"clk.c"
|
||||
"coexist.c"
|
||||
"cpu_start.c"
|
||||
"crosscore_int.c"
|
||||
"dport_access.c"
|
||||
@@ -21,26 +20,21 @@ else()
|
||||
"esp_adapter.c"
|
||||
"esp_timer_esp32.c"
|
||||
"esp_himem.c"
|
||||
"fast_crypto_ops.c"
|
||||
"freertos_hooks.c"
|
||||
"gdbstub.c"
|
||||
"hw_random.c"
|
||||
"int_wdt.c"
|
||||
"intr_alloc.c"
|
||||
"ipc.c"
|
||||
"lib_printf.c"
|
||||
"panic.c"
|
||||
"phy_init.c"
|
||||
"pm_esp32.c"
|
||||
"pm_trace.c"
|
||||
"reset_reason.c"
|
||||
"restore.c"
|
||||
"sleep_modes.c"
|
||||
"spiram.c"
|
||||
"spiram_psram.c"
|
||||
"system_api.c"
|
||||
"task_wdt.c"
|
||||
"wifi_init.c")
|
||||
"task_wdt.c")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||
|
||||
set(COMPONENT_REQUIRES driver esp_event efuse)
|
||||
@@ -48,16 +42,12 @@ else()
|
||||
# app_update is added here because cpu_start.c uses esp_ota_get_app_description() function.
|
||||
set(COMPONENT_PRIV_REQUIRES
|
||||
app_trace app_update bootloader_support log mbedtls nvs_flash
|
||||
pthread smartconfig_ack spi_flash vfs wpa_supplicant espcoredump esp_common)
|
||||
pthread smartconfig_ack spi_flash vfs wpa_supplicant espcoredump esp_common esp_wifi)
|
||||
|
||||
set(COMPONENT_ADD_LDFRAGMENTS linker.lf ld/esp32_fragments.lf)
|
||||
|
||||
register_component()
|
||||
|
||||
target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
||||
if(NOT CONFIG_NO_BLOBS)
|
||||
target_link_libraries(${COMPONENT_TARGET} coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps)
|
||||
endif()
|
||||
target_linker_script(${COMPONENT_TARGET} "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
|
||||
|
||||
if(CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY)
|
||||
@@ -101,27 +91,6 @@ else()
|
||||
add_custom_target(esp32_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld)
|
||||
add_dependencies(${COMPONENT_TARGET} esp32_linker_script)
|
||||
|
||||
if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION AND IDF_BUILD_ARTIFACTS)
|
||||
partition_table_get_partition_info(phy_partition_offset "--partition-type data --partition-subtype phy" "offset")
|
||||
set(phy_init_data_bin "${IDF_BUILD_ARTIFACTS_DIR}/phy_init_data.bin")
|
||||
|
||||
# To get the phy_init_data.bin file, compile phy_init_data.h as a C file and then objcopy
|
||||
# the object file to a raw binary
|
||||
add_custom_command(
|
||||
OUTPUT ${phy_init_data_bin}
|
||||
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h
|
||||
COMMAND ${CMAKE_C_COMPILER} -x c -c
|
||||
-I ${CMAKE_CURRENT_LIST_DIR} -I ${CMAKE_CURRENT_LIST_DIR}/include -I ${IDF_BUILD_ARTIFACTS_DIR}
|
||||
-o phy_init_data.obj
|
||||
${CMAKE_CURRENT_LIST_DIR}/phy_init_data.h
|
||||
COMMAND ${CMAKE_OBJCOPY} -O binary phy_init_data.obj ${phy_init_data_bin}
|
||||
)
|
||||
add_custom_target(phy_init_data ALL DEPENDS ${phy_init_data_bin})
|
||||
add_dependencies(flash phy_init_data)
|
||||
|
||||
esptool_py_flash_project_args(phy ${phy_partition_offset} ${phy_init_data_bin} FLASH_IN_PROJECT)
|
||||
endif()
|
||||
|
||||
# Enable dynamic esp_timer overflow value if building unit tests
|
||||
if(esp32_test IN_LIST BUILD_TEST_COMPONENTS)
|
||||
add_definitions(-DESP_TIMER_DYNAMIC_OVERFLOW_VAL)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "esp_coexist.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
|
||||
const char *esp_coex_version_get(void)
|
||||
{
|
||||
return coex_version_get();
|
||||
}
|
||||
|
||||
esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer)
|
||||
{
|
||||
return coex_preference_set((coex_prefer_t)prefer);
|
||||
}
|
||||
@@ -3,10 +3,6 @@
|
||||
#
|
||||
|
||||
COMPONENT_SRCDIRS := .
|
||||
LIBS ?=
|
||||
ifndef CONFIG_NO_BLOBS
|
||||
LIBS += core rtc net80211 pp wpa smartconfig coexist wps wpa2 espnow phy mesh
|
||||
endif
|
||||
|
||||
ifdef CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
|
||||
# This linker script must come before esp32.project.ld
|
||||
@@ -22,8 +18,6 @@ LINKER_SCRIPTS += $(COMPONENT_BUILD_DIR)/esp32.project.ld esp32.peripherals.ld
|
||||
#linker will ignore panic_highint_hdl.S as it has no other files depending on any
|
||||
#symbols in it.
|
||||
COMPONENT_ADD_LDFLAGS += $(COMPONENT_PATH)/libhal.a \
|
||||
-L$(COMPONENT_PATH)/lib \
|
||||
$(addprefix -l,$(LIBS)) \
|
||||
-L $(COMPONENT_PATH)/ld \
|
||||
-T esp32_out.ld \
|
||||
-u ld_include_panic_highint_hdl \
|
||||
@@ -31,14 +25,9 @@ COMPONENT_ADD_LDFLAGS += $(COMPONENT_PATH)/libhal.a \
|
||||
|
||||
COMPONENT_ADD_LDFRAGMENTS += ld/esp32_fragments.lf linker.lf
|
||||
|
||||
ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))
|
||||
|
||||
COMPONENT_SUBMODULES += lib
|
||||
|
||||
# final linking of project ELF depends on all binary libraries, and
|
||||
# all linker scripts (except esp32_out.ld, as this is code generated here.)
|
||||
COMPONENT_ADD_LINKER_DEPS := $(ALL_LIB_FILES) \
|
||||
$(addprefix ld/, $(filter-out $(COMPONENT_BUILD_DIR)/esp32.project.ld, $(LINKER_SCRIPTS))) \
|
||||
COMPONENT_ADD_LINKER_DEPS := $(addprefix ld/, $(filter-out $(COMPONENT_BUILD_DIR)/esp32.project.ld, $(LINKER_SCRIPTS))) \
|
||||
$(COMPONENT_BUILD_DIR)/esp32.project.ld
|
||||
|
||||
# Preprocess esp32.ld linker script into esp32_out.ld
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
#include "esp_attr.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_wifi_os_adapter.h"
|
||||
#include "esp_wifi_internal.h"
|
||||
#include "esp_private/wifi_os_adapter.h"
|
||||
#include "esp_private/wifi.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include "crypto/md5.h"
|
||||
#include "crypto/sha1.h"
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "crypto/common.h"
|
||||
#include "crypto/aes_wrap.h"
|
||||
#include "crypto/sha256.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "crypto/md5.h"
|
||||
#include "crypto/sha1.h"
|
||||
#include "crypto/aes.h"
|
||||
#include "crypto/dh_group5.h"
|
||||
#include "wps/wps.h"
|
||||
#include "wps/wps_i.h"
|
||||
#include "wpa2/eap_peer/eap.h"
|
||||
#include "wpa2/tls/tls.h"
|
||||
#include "wpa2/eap_peer/eap_methods.h"
|
||||
#include "wpa2/eap_peer/eap_i.h"
|
||||
#include "wpa2/eap_peer/eap_common.h"
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
/*
|
||||
* The parameters is used to set the cyrpto callback function for station connect when in security mode,
|
||||
* every callback function can register as fast_xxx or normal one, i.e, fast_aes_wrap or aes_wrap, the
|
||||
* difference between them is the normal API is calculate by software, the fast one use the hardware
|
||||
* crypto in it, can be faster than the normal one, so the callback function register in default is which
|
||||
* we recommend, so as the API in WPS default and WPA2 default.
|
||||
*/
|
||||
const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs = {
|
||||
.size = sizeof(wpa_crypto_funcs_t),
|
||||
.version = ESP_WIFI_CRYPTO_VERSION,
|
||||
.aes_wrap = (esp_aes_wrap_t)fast_aes_wrap,
|
||||
.aes_unwrap = (esp_aes_unwrap_t)fast_aes_unwrap,
|
||||
.hmac_sha256_vector = (esp_hmac_sha256_vector_t)fast_hmac_sha256_vector,
|
||||
.sha256_prf = (esp_sha256_prf_t)fast_sha256_prf,
|
||||
.hmac_md5 = (esp_hmac_md5_t)hmac_md5,
|
||||
.hamc_md5_vector = (esp_hmac_md5_vector_t)hmac_md5_vector,
|
||||
.hmac_sha1 = (esp_hmac_sha1_t)hmac_sha1,
|
||||
.hmac_sha1_vector = (esp_hmac_sha1_vector_t)hmac_sha1_vector,
|
||||
.sha1_prf = (esp_sha1_prf_t)sha1_prf,
|
||||
.sha1_vector = (esp_sha1_vector_t)sha1_vector,
|
||||
.pbkdf2_sha1 = (esp_pbkdf2_sha1_t)pbkdf2_sha1,
|
||||
.rc4_skip = (esp_rc4_skip_t)rc4_skip,
|
||||
.md5_vector = (esp_md5_vector_t)md5_vector,
|
||||
.aes_encrypt = (esp_aes_encrypt_t)aes_encrypt,
|
||||
.aes_encrypt_init = (esp_aes_encrypt_init_t)aes_encrypt_init,
|
||||
.aes_encrypt_deinit = (esp_aes_encrypt_deinit_t)aes_encrypt_deinit,
|
||||
.aes_decrypt = (esp_aes_decrypt_t)aes_decrypt,
|
||||
.aes_decrypt_init = (esp_aes_decrypt_init_t)aes_decrypt_init,
|
||||
.aes_decrypt_deinit = (esp_aes_decrypt_deinit_t)aes_decrypt_deinit
|
||||
};
|
||||
|
||||
const wps_crypto_funcs_t g_wifi_default_wps_crypto_funcs = {
|
||||
.size = sizeof(wps_crypto_funcs_t),
|
||||
.version = ESP_WIFI_CRYPTO_VERSION,
|
||||
.aes_128_encrypt = (esp_aes_128_encrypt_t)fast_aes_128_cbc_encrypt,
|
||||
.aes_128_decrypt = (esp_aes_128_decrypt_t)fast_aes_128_cbc_decrypt,
|
||||
.crypto_mod_exp = (esp_crypto_mod_exp_t)fast_crypto_mod_exp,
|
||||
.hmac_sha256 = (esp_hmac_sha256_t)fast_hmac_sha256,
|
||||
.hmac_sha256_vector = (esp_hmac_sha256_vector_t)fast_hmac_sha256_vector,
|
||||
.sha256_vector = (esp_sha256_vector_t)fast_sha256_vector,
|
||||
.uuid_gen_mac_addr = (esp_uuid_gen_mac_addr_t)uuid_gen_mac_addr,
|
||||
.dh5_free = (esp_dh5_free_t)dh5_free,
|
||||
.wps_build_assoc_req_ie = (esp_wps_build_assoc_req_ie_t)wps_build_assoc_req_ie,
|
||||
.wps_build_assoc_resp_ie = (esp_wps_build_assoc_resp_ie_t)wps_build_assoc_resp_ie,
|
||||
.wps_build_probe_req_ie = (esp_wps_build_probe_req_ie_t)wps_build_probe_req_ie,
|
||||
.wps_build_public_key = (esp_wps_build_public_key_t)wps_build_public_key,
|
||||
.wps_enrollee_get_msg = (esp_wps_enrollee_get_msg_t)wps_enrollee_get_msg,
|
||||
.wps_enrollee_process_msg = (esp_wps_enrollee_process_msg_t)wps_enrollee_process_msg,
|
||||
.wps_generate_pin = (esp_wps_generate_pin_t)wps_generate_pin,
|
||||
.wps_is_selected_pin_registrar = (esp_wps_is_selected_pin_registrar_t)wps_is_selected_pin_registrar,
|
||||
.wps_is_selected_pbc_registrar = (esp_wps_is_selected_pbc_registrar_t)wps_is_selected_pbc_registrar,
|
||||
.eap_msg_alloc = (esp_eap_msg_alloc_t)eap_msg_alloc
|
||||
};
|
||||
|
||||
/*
|
||||
* What should notice is that the cyrpto hash type function and crypto cipher type function can not register
|
||||
* as different, i.e, if you use fast_crypto_hash_init, you should use fast_crypto_hash_update and
|
||||
* fast_crypto_hash_finish for finish hash calculate, rather than call crypto_hash_update and
|
||||
* crypto_hash_finish, so do crypto_cipher.
|
||||
*/
|
||||
const wpa2_crypto_funcs_t g_wifi_default_wpa2_crypto_funcs = {
|
||||
.size = sizeof(wpa2_crypto_funcs_t),
|
||||
.version = ESP_WIFI_CRYPTO_VERSION,
|
||||
.crypto_hash_init = (esp_crypto_hash_init_t)fast_crypto_hash_init,
|
||||
.crypto_hash_update = (esp_crypto_hash_update_t)fast_crypto_hash_update,
|
||||
.crypto_hash_finish = (esp_crypto_hash_finish_t)fast_crypto_hash_finish,
|
||||
.crypto_cipher_init = (esp_crypto_cipher_init_t)fast_crypto_cipher_init,
|
||||
.crypto_cipher_encrypt = (esp_crypto_cipher_encrypt_t)fast_crypto_cipher_encrypt,
|
||||
.crypto_cipher_decrypt = (esp_crypto_cipher_decrypt_t)fast_crypto_cipher_decrypt,
|
||||
.crypto_cipher_deinit = (esp_crypto_cipher_deinit_t)fast_crypto_cipher_deinit,
|
||||
.crypto_mod_exp = (esp_crypto_mod_exp_t)crypto_mod_exp,
|
||||
.sha256_vector = (esp_sha256_vector_t)fast_sha256_vector,
|
||||
.tls_init = (esp_tls_init_t)tls_init,
|
||||
.tls_deinit = (esp_tls_deinit_t)tls_deinit,
|
||||
.eap_peer_blob_init = (esp_eap_peer_blob_init_t)eap_peer_blob_init,
|
||||
.eap_peer_blob_deinit = (esp_eap_peer_blob_deinit_t)eap_peer_blob_deinit,
|
||||
.eap_peer_config_init = (esp_eap_peer_config_init_t)eap_peer_config_init,
|
||||
.eap_peer_config_deinit = (esp_eap_peer_config_deinit_t)eap_peer_config_deinit,
|
||||
.eap_peer_register_methods = (esp_eap_peer_register_methods_t)eap_peer_register_methods,
|
||||
.eap_peer_unregister_methods = (esp_eap_peer_unregister_methods_t)eap_peer_unregister_methods,
|
||||
.eap_deinit_prev_method = (esp_eap_deinit_prev_method_t)eap_deinit_prev_method,
|
||||
.eap_peer_get_eap_method = (esp_eap_peer_get_eap_method_t)eap_peer_get_eap_method,
|
||||
.eap_sm_abort = (esp_eap_sm_abort_t)eap_sm_abort,
|
||||
.eap_sm_build_nak = (esp_eap_sm_build_nak_t)eap_sm_build_nak,
|
||||
.eap_sm_build_identity_resp = (esp_eap_sm_build_identity_resp_t)eap_sm_build_identity_resp,
|
||||
.eap_msg_alloc = (esp_eap_msg_alloc_t)eap_msg_alloc
|
||||
};
|
||||
|
||||
const mesh_crypto_funcs_t g_wifi_default_mesh_crypto_funcs = {
|
||||
.aes_128_encrypt = (esp_aes_128_encrypt_t)fast_aes_128_cbc_encrypt,
|
||||
.aes_128_decrypt = (esp_aes_128_decrypt_t)fast_aes_128_cbc_decrypt,
|
||||
};
|
||||
@@ -1,59 +0,0 @@
|
||||
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_COEXIST_H__
|
||||
#define __ESP_COEXIST_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief coex prefer value
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_COEX_PREFER_WIFI = 0, /*!< Prefer to WiFi, WiFi will have more opportunity to use RF */
|
||||
ESP_COEX_PREFER_BT, /*!< Prefer to bluetooth, bluetooth will have more opportunity to use RF */
|
||||
ESP_COEX_PREFER_BALANCE, /*!< Do balance of WiFi and bluetooth */
|
||||
ESP_COEX_PREFER_NUM, /*!< Prefer value numbers */
|
||||
} esp_coex_prefer_t;
|
||||
|
||||
/**
|
||||
* @brief Get software coexist version string
|
||||
*
|
||||
* @return : version string
|
||||
*/
|
||||
const char *esp_coex_version_get(void);
|
||||
|
||||
/**
|
||||
* @brief Set coexist preference of performance
|
||||
* For example, if prefer to bluetooth, then it will make A2DP(play audio via classic bt)
|
||||
* more smooth while wifi is runnning something.
|
||||
* If prefer to wifi, it will do similar things as prefer to bluetooth.
|
||||
* Default, it prefer to balance.
|
||||
*
|
||||
* @param prefer : the prefer enumeration value
|
||||
* @return : ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ESP_COEXIST_H__ */
|
||||
@@ -1,59 +0,0 @@
|
||||
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_COEXIST_ADAPTER_H__
|
||||
#define __ESP_COEXIST_ADAPTER_H__
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define COEX_ADAPTER_VERSION 0x00000001
|
||||
#define COEX_ADAPTER_MAGIC 0xDEADBEAF
|
||||
|
||||
#define COEX_ADAPTER_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
|
||||
typedef struct {
|
||||
int32_t _version;
|
||||
void *(* _spin_lock_create)(void);
|
||||
void (* _spin_lock_delete)(void *lock);
|
||||
uint32_t (*_int_disable)(void *mux);
|
||||
void (*_int_enable)(void *mux, uint32_t tmp);
|
||||
void (*_task_yield_from_isr)(void);
|
||||
void *(*_semphr_create)(uint32_t max, uint32_t init);
|
||||
void (*_semphr_delete)(void *semphr);
|
||||
int32_t (*_semphr_take_from_isr)(void *semphr, void *hptw);
|
||||
int32_t (*_semphr_give_from_isr)(void *semphr, void *hptw);
|
||||
int32_t (*_semphr_take)(void *semphr, uint32_t block_time_tick);
|
||||
int32_t (*_semphr_give)(void *semphr);
|
||||
int32_t (* _is_in_isr)(void);
|
||||
void * (* _malloc_internal)(size_t size);
|
||||
void (* _free)(void *p);
|
||||
void (* _timer_disarm)(void *timer);
|
||||
void (* _timer_done)(void *ptimer);
|
||||
void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg);
|
||||
void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat);
|
||||
int64_t (* _esp_timer_get_time)(void);
|
||||
int32_t _magic;
|
||||
} coex_adapter_funcs_t;
|
||||
|
||||
extern coex_adapter_funcs_t g_coex_adapter_funcs;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_COEXIST_ADAPTER_H__ */
|
||||
@@ -1,163 +0,0 @@
|
||||
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_COEXIST_INTERNAL_H__
|
||||
#define __ESP_COEXIST_INTERNAL_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_coexist_adapter.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
COEX_PREFER_WIFI = 0,
|
||||
COEX_PREFER_BT,
|
||||
COEX_PREFER_BALANCE,
|
||||
COEX_PREFER_NUM,
|
||||
} coex_prefer_t;
|
||||
|
||||
typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt);
|
||||
|
||||
/**
|
||||
* @brief Init software coexist
|
||||
* extern function for internal use.
|
||||
*
|
||||
* @return Init ok or failed.
|
||||
*/
|
||||
esp_err_t coex_init(void);
|
||||
|
||||
/**
|
||||
* @brief De-init software coexist
|
||||
* extern function for internal use.
|
||||
*/
|
||||
void coex_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Pause software coexist
|
||||
* extern function for internal use.
|
||||
*/
|
||||
void coex_pause(void);
|
||||
|
||||
/**
|
||||
* @brief Resume software coexist
|
||||
* extern function for internal use.
|
||||
*/
|
||||
void coex_resume(void);
|
||||
|
||||
/**
|
||||
* @brief Get software coexist version string
|
||||
* extern function for internal use.
|
||||
* @return : version string
|
||||
*/
|
||||
const char *coex_version_get(void);
|
||||
|
||||
/**
|
||||
* @brief Coexist performance preference set from libbt.a
|
||||
* extern function for internal use.
|
||||
*
|
||||
* @param prefer : the prefer enumeration value
|
||||
* @return : ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t coex_preference_set(coex_prefer_t prefer);
|
||||
|
||||
/**
|
||||
* @brief Get software coexist status.
|
||||
* @return : software coexist status
|
||||
*/
|
||||
uint32_t coex_status_get(void);
|
||||
|
||||
/**
|
||||
* @brief WiFi requests coexistence.
|
||||
*
|
||||
* @param event : WiFi event
|
||||
* @param latency : WiFi will request coexistence after latency
|
||||
* @param duration : duration for WiFi to request coexistence
|
||||
* @return : 0 - success, other - failed
|
||||
*/
|
||||
int coex_wifi_request(uint32_t event, uint32_t latency, uint32_t duration);
|
||||
|
||||
/**
|
||||
* @brief WiFi release coexistence.
|
||||
*
|
||||
* @param event : WiFi event
|
||||
* @return : 0 - success, other - failed
|
||||
*/
|
||||
int coex_wifi_release(uint32_t event);
|
||||
|
||||
/**
|
||||
* @brief Blue tooth requests coexistence.
|
||||
*
|
||||
* @param event : blue tooth event
|
||||
* @param latency : blue tooth will request coexistence after latency
|
||||
* @param duration : duration for blue tooth to request coexistence
|
||||
* @return : 0 - success, other - failed
|
||||
*/
|
||||
int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration);
|
||||
|
||||
/**
|
||||
* @brief Blue tooth release coexistence.
|
||||
*
|
||||
* @param event : blue tooth event
|
||||
* @return : 0 - success, other - failed
|
||||
*/
|
||||
int coex_bt_release(uint32_t event);
|
||||
|
||||
/**
|
||||
* @brief Register callback function for blue tooth.
|
||||
*
|
||||
* @param cb : callback function
|
||||
* @return : 0 - success, other - failed
|
||||
*/
|
||||
int coex_register_bt_cb(coex_func_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Lock before reset base band.
|
||||
*
|
||||
* @return : lock value
|
||||
*/
|
||||
uint32_t coex_bb_reset_lock(void);
|
||||
|
||||
/**
|
||||
* @brief Unlock after reset base band.
|
||||
*
|
||||
* @param restore : lock value
|
||||
*/
|
||||
void coex_bb_reset_unlock(uint32_t restore);
|
||||
|
||||
/**
|
||||
* @brief Register coexistence adapter functions.
|
||||
*
|
||||
* @param funcs : coexistence adapter functions
|
||||
* @return : ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
|
||||
|
||||
/**
|
||||
* @brief Check the MD5 values of the coexistence adapter header files in IDF and WiFi library
|
||||
*
|
||||
* @attention 1. It is used for internal CI version check
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_WIFI_INVALID_ARG : MD5 check fail
|
||||
*/
|
||||
esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_COEXIST_INTERNAL_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,269 +0,0 @@
|
||||
// Copyright 2017-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_MESH_INTERNAL_H__
|
||||
#define __ESP_MESH_INTERNAL_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_wifi_types.h"
|
||||
#include "esp_wifi_internal.h"
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************
|
||||
* Constants
|
||||
*******************************************************/
|
||||
|
||||
/*******************************************************
|
||||
* Structures
|
||||
*******************************************************/
|
||||
typedef struct {
|
||||
int scan; /**< minimum scan times before being a root, default:10 */
|
||||
int vote; /**< max vote times in self-healing, default:1000 */
|
||||
int fail; /**< parent selection fail times, if the scan times reach this value,
|
||||
device will disconnect with associated children and join self-healing. default:60 */
|
||||
int monitor_ie; /**< acceptable times of parent networking IE change before update its own networking IE. default:3 */
|
||||
} mesh_attempts_t;
|
||||
|
||||
typedef struct {
|
||||
int duration_ms; /* parent weak RSSI monitor duration, if the RSSI continues to be weak during this duration_ms,
|
||||
device will search for a new parent. */
|
||||
int cnx_rssi; /* RSSI threshold for keeping a good connection with parent.
|
||||
If set a value greater than -120 dBm, a timer will be armed to monitor parent RSSI at a period time of duration_ms. */
|
||||
int select_rssi; /* RSSI threshold for parent selection. It should be a value greater than switch_rssi. */
|
||||
int switch_rssi; /* Disassociate with current parent and switch to a new parent when the RSSI is greater than this set threshold. */
|
||||
int backoff_rssi; /* RSSI threshold for connecting to the root */
|
||||
} mesh_switch_parent_t;
|
||||
|
||||
typedef struct {
|
||||
int high;
|
||||
int medium;
|
||||
int low;
|
||||
} mesh_rssi_threshold_t;
|
||||
|
||||
/**
|
||||
* @brief Mesh networking IE
|
||||
*/
|
||||
typedef struct {
|
||||
/**< mesh networking IE head */
|
||||
uint8_t eid; /**< element ID */
|
||||
uint8_t len; /**< element length */
|
||||
uint8_t oui[3]; /**< organization identifier */
|
||||
/**< mesh networking IE content */
|
||||
uint8_t type; /** ESP defined IE type */
|
||||
uint8_t encrypted : 1; /**< whether mesh networking IE is encrypted */
|
||||
uint8_t version : 7; /**< mesh networking IE version */
|
||||
/**< content */
|
||||
uint8_t mesh_type; /**< mesh device type */
|
||||
uint8_t mesh_id[6]; /**< mesh ID */
|
||||
uint8_t layer_cap; /**< max layer */
|
||||
uint8_t layer; /**< current layer */
|
||||
uint8_t assoc_cap; /**< max connections of mesh AP */
|
||||
uint8_t assoc; /**< current connections */
|
||||
uint8_t leaf_cap; /**< leaf capacity */
|
||||
uint8_t leaf_assoc; /**< the number of current connected leaf */
|
||||
uint16_t root_cap; /**< root capacity */
|
||||
uint16_t self_cap; /**< self capacity */
|
||||
uint16_t layer2_cap; /**< layer2 capacity */
|
||||
uint16_t scan_ap_num; /**< the number of scanning APs */
|
||||
int8_t rssi; /**< RSSI of the parent */
|
||||
int8_t router_rssi; /**< RSSI of the router */
|
||||
uint8_t flag; /**< flag of networking */
|
||||
uint8_t rc_addr[6]; /**< root address */
|
||||
int8_t rc_rssi; /**< root RSSI */
|
||||
uint8_t vote_addr[6]; /**< voter address */
|
||||
int8_t vote_rssi; /**< vote RSSI of the router */
|
||||
uint8_t vote_ttl; /**< vote ttl */
|
||||
uint16_t votes; /**< votes */
|
||||
uint16_t my_votes; /**< my votes */
|
||||
uint8_t reason; /**< reason */
|
||||
uint8_t child[6]; /**< child address */
|
||||
uint8_t toDS; /**< toDS state */
|
||||
} __attribute__((packed)) mesh_assoc_t;
|
||||
|
||||
/*******************************************************
|
||||
* Function Definitions
|
||||
*******************************************************/
|
||||
/**
|
||||
* @brief Set mesh softAP beacon interval
|
||||
*
|
||||
* @param[in] interval beacon interval (msecs) (100 msecs ~ 60000 msecs)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
* - ESP_ERR_WIFI_ARG
|
||||
*/
|
||||
esp_err_t esp_mesh_set_beacon_interval(int interval_ms);
|
||||
|
||||
/**
|
||||
* @brief Get mesh softAP beacon interval
|
||||
*
|
||||
* @param[out] interval beacon interval (msecs)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t esp_mesh_get_beacon_interval(int *interval_ms);
|
||||
|
||||
/**
|
||||
* @brief Set attempts for mesh self-organized networking
|
||||
*
|
||||
* @param[in] attempts
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_mesh_set_attempts(mesh_attempts_t *attempts);
|
||||
|
||||
/**
|
||||
* @brief Get attempts for mesh self-organized networking
|
||||
*
|
||||
* @param[out] attempts
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_MESH_ARGUMENT
|
||||
*/
|
||||
esp_err_t esp_mesh_get_attempts(mesh_attempts_t *attempts);
|
||||
|
||||
/**
|
||||
* @brief Set parameters for parent switch
|
||||
*
|
||||
* @param[in] paras parameters for parent switch
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_MESH_ARGUMENT
|
||||
*/
|
||||
esp_err_t esp_mesh_set_switch_parent_paras(mesh_switch_parent_t *paras);
|
||||
|
||||
/**
|
||||
* @brief Get parameters for parent switch
|
||||
*
|
||||
* @param[out] paras parameters for parent switch
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_MESH_ARGUMENT
|
||||
*/
|
||||
esp_err_t esp_mesh_get_switch_parent_paras(mesh_switch_parent_t *paras);
|
||||
|
||||
/**
|
||||
* @brief Set RSSI threshold
|
||||
* - The default high RSSI threshold value is -78 dBm.
|
||||
* - The default medium RSSI threshold value is -82 dBm.
|
||||
* - The default low RSSI threshold value is -85 dBm.
|
||||
*
|
||||
* @param[in] threshold RSSI threshold
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_MESH_ARGUMENT
|
||||
*/
|
||||
esp_err_t esp_mesh_set_rssi_threshold(const mesh_rssi_threshold_t *threshold);
|
||||
|
||||
/**
|
||||
* @brief Get RSSI threshold
|
||||
*
|
||||
* @param[out] threshold RSSI threshold
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_ERR_MESH_ARGUMENT
|
||||
*/
|
||||
esp_err_t esp_mesh_get_rssi_threshold(mesh_rssi_threshold_t *threshold);
|
||||
|
||||
/**
|
||||
* @brief Enable the minimum rate to 6 Mbps
|
||||
*
|
||||
* @attention This API shall be called before Wi-Fi is started.
|
||||
*
|
||||
* @param[in] is_6m enable or not
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t esp_mesh_set_6m_rate(bool is_6m);
|
||||
|
||||
/**
|
||||
* @brief Print the number of txQ waiting
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_mesh_print_txQ_waiting(void);
|
||||
|
||||
/**
|
||||
* @brief Print the number of rxQ waiting
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_mesh_print_rxQ_waiting(void);
|
||||
|
||||
/**
|
||||
* @brief Set passive scan time
|
||||
*
|
||||
* @param[in] interval_ms passive scan time (msecs)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
* - ESP_ERR_ARGUMENT
|
||||
*/
|
||||
esp_err_t esp_mesh_set_passive_scan_time(int time_ms);
|
||||
|
||||
/**
|
||||
* @brief Get passive scan time
|
||||
*
|
||||
* @return interval_ms passive scan time (msecs)
|
||||
*/
|
||||
int esp_mesh_get_passive_scan_time(void);
|
||||
|
||||
/**
|
||||
* @brief Set announce interval
|
||||
* - The default short interval is 500 milliseconds.
|
||||
* - The default long interval is 3000 milliseconds.
|
||||
*
|
||||
* @param[in] short_ms shall be greater than the default value
|
||||
* @param[in] long_ms shall be greater than the default value
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t esp_mesh_set_announce_interval(int short_ms, int long_ms);
|
||||
|
||||
/**
|
||||
* @brief Get announce interval
|
||||
*
|
||||
* @param[out] short_ms short interval
|
||||
* @param[out] long_ms long interval
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t esp_mesh_get_announce_interval(int *short_ms, int *long_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __ESP_MESH_INTERNAL_H__ */
|
||||
@@ -1,317 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_NOW_H__
|
||||
#define __ESP_NOW_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup WiFi_APIs WiFi Related APIs
|
||||
* @brief WiFi APIs
|
||||
*/
|
||||
|
||||
/** @addtogroup WiFi_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \defgroup ESPNOW_APIs ESPNOW APIs
|
||||
* @brief ESP32 ESPNOW APIs
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup ESPNOW_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define ESP_ERR_ESPNOW_BASE (ESP_ERR_WIFI_BASE + 100) /*!< ESPNOW error number base. */
|
||||
#define ESP_ERR_ESPNOW_NOT_INIT (ESP_ERR_ESPNOW_BASE + 1) /*!< ESPNOW is not initialized. */
|
||||
#define ESP_ERR_ESPNOW_ARG (ESP_ERR_ESPNOW_BASE + 2) /*!< Invalid argument */
|
||||
#define ESP_ERR_ESPNOW_NO_MEM (ESP_ERR_ESPNOW_BASE + 3) /*!< Out of memory */
|
||||
#define ESP_ERR_ESPNOW_FULL (ESP_ERR_ESPNOW_BASE + 4) /*!< ESPNOW peer list is full */
|
||||
#define ESP_ERR_ESPNOW_NOT_FOUND (ESP_ERR_ESPNOW_BASE + 5) /*!< ESPNOW peer is not found */
|
||||
#define ESP_ERR_ESPNOW_INTERNAL (ESP_ERR_ESPNOW_BASE + 6) /*!< Internal error */
|
||||
#define ESP_ERR_ESPNOW_EXIST (ESP_ERR_ESPNOW_BASE + 7) /*!< ESPNOW peer has existed */
|
||||
#define ESP_ERR_ESPNOW_IF (ESP_ERR_ESPNOW_BASE + 8) /*!< Interface error */
|
||||
|
||||
#define ESP_NOW_ETH_ALEN 6 /*!< Length of ESPNOW peer MAC address */
|
||||
#define ESP_NOW_KEY_LEN 16 /*!< Length of ESPNOW peer local master key */
|
||||
|
||||
#define ESP_NOW_MAX_TOTAL_PEER_NUM 20 /*!< Maximum number of ESPNOW total peers */
|
||||
#define ESP_NOW_MAX_ENCRYPT_PEER_NUM 6 /*!< Maximum number of ESPNOW encrypted peers */
|
||||
|
||||
#define ESP_NOW_MAX_DATA_LEN 250 /*!< Maximum length of ESPNOW data which is sent very time */
|
||||
|
||||
/**
|
||||
* @brief Status of sending ESPNOW data .
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_NOW_SEND_SUCCESS = 0, /**< Send ESPNOW data successfully */
|
||||
ESP_NOW_SEND_FAIL, /**< Send ESPNOW data fail */
|
||||
} esp_now_send_status_t;
|
||||
|
||||
/**
|
||||
* @brief ESPNOW peer information parameters.
|
||||
*/
|
||||
typedef struct esp_now_peer_info {
|
||||
uint8_t peer_addr[ESP_NOW_ETH_ALEN]; /**< ESPNOW peer MAC address that is also the MAC address of station or softap */
|
||||
uint8_t lmk[ESP_NOW_KEY_LEN]; /**< ESPNOW peer local master key that is used to encrypt data */
|
||||
uint8_t channel; /**< Wi-Fi channel that peer uses to send/receive ESPNOW data. If the value is 0,
|
||||
use the current channel which station or softap is on. Otherwise, it must be
|
||||
set as the channel that station or softap is on. */
|
||||
wifi_interface_t ifidx; /**< Wi-Fi interface that peer uses to send/receive ESPNOW data */
|
||||
bool encrypt; /**< ESPNOW data that this peer sends/receives is encrypted or not */
|
||||
void *priv; /**< ESPNOW peer private data */
|
||||
} esp_now_peer_info_t;
|
||||
|
||||
/**
|
||||
* @brief Number of ESPNOW peers which exist currently.
|
||||
*/
|
||||
typedef struct esp_now_peer_num {
|
||||
int total_num; /**< Total number of ESPNOW peers, maximum value is ESP_NOW_MAX_TOTAL_PEER_NUM */
|
||||
int encrypt_num; /**< Number of encrypted ESPNOW peers, maximum value is ESP_NOW_MAX_ENCRYPT_PEER_NUM */
|
||||
} esp_now_peer_num_t;
|
||||
|
||||
/**
|
||||
* @brief Callback function of receiving ESPNOW data
|
||||
* @param mac_addr peer MAC address
|
||||
* @param data received data
|
||||
* @param data_len length of received data
|
||||
*/
|
||||
typedef void (*esp_now_recv_cb_t)(const uint8_t *mac_addr, const uint8_t *data, int data_len);
|
||||
|
||||
/**
|
||||
* @brief Callback function of sending ESPNOW data
|
||||
* @param mac_addr peer MAC address
|
||||
* @param status status of sending ESPNOW data (succeed or fail)
|
||||
*/
|
||||
typedef void (*esp_now_send_cb_t)(const uint8_t *mac_addr, esp_now_send_status_t status);
|
||||
|
||||
/**
|
||||
* @brief Initialize ESPNOW function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : Internal error
|
||||
*/
|
||||
esp_err_t esp_now_init(void);
|
||||
|
||||
/**
|
||||
* @brief De-initialize ESPNOW function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
*/
|
||||
esp_err_t esp_now_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Get the version of ESPNOW
|
||||
*
|
||||
* @param version ESPNOW version
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_now_get_version(uint32_t *version);
|
||||
|
||||
/**
|
||||
* @brief Register callback function of receiving ESPNOW data
|
||||
*
|
||||
* @param cb callback function of receiving ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : internal error
|
||||
*/
|
||||
esp_err_t esp_now_register_recv_cb(esp_now_recv_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Unregister callback function of receiving ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
*/
|
||||
esp_err_t esp_now_unregister_recv_cb(void);
|
||||
|
||||
/**
|
||||
* @brief Register callback function of sending ESPNOW data
|
||||
*
|
||||
* @param cb callback function of sending ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : internal error
|
||||
*/
|
||||
esp_err_t esp_now_register_send_cb(esp_now_send_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Unregister callback function of sending ESPNOW data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
*/
|
||||
esp_err_t esp_now_unregister_send_cb(void);
|
||||
|
||||
/**
|
||||
* @brief Send ESPNOW data
|
||||
*
|
||||
* @attention 1. If peer_addr is not NULL, send data to the peer whose MAC address matches peer_addr
|
||||
* @attention 2. If peer_addr is NULL, send data to all of the peers that are added to the peer list
|
||||
* @attention 3. The maximum length of data must be less than ESP_NOW_MAX_DATA_LEN
|
||||
* @attention 4. The buffer pointed to by data argument does not need to be valid after esp_now_send returns
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
* @param data data to send
|
||||
* @param len length of data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_INTERNAL : internal error
|
||||
* - ESP_ERR_ESPNOW_NO_MEM : out of memory
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
* - ESP_ERR_ESPNOW_IF : current WiFi interface doesn't match that of peer
|
||||
*/
|
||||
esp_err_t esp_now_send(const uint8_t *peer_addr, const uint8_t *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Add a peer to peer list
|
||||
*
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_FULL : peer list is full
|
||||
* - ESP_ERR_ESPNOW_NO_MEM : out of memory
|
||||
* - ESP_ERR_ESPNOW_EXIST : peer has existed
|
||||
*/
|
||||
esp_err_t esp_now_add_peer(const esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Delete a peer from peer list
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
*/
|
||||
esp_err_t esp_now_del_peer(const uint8_t *peer_addr);
|
||||
|
||||
/**
|
||||
* @brief Modify a peer
|
||||
*
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_FULL : peer list is full
|
||||
*/
|
||||
esp_err_t esp_now_mod_peer(const esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Get a peer whose MAC address matches peer_addr from peer list
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
*/
|
||||
esp_err_t esp_now_get_peer(const uint8_t *peer_addr, esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Fetch a peer from peer list
|
||||
*
|
||||
* @param from_head fetch from head of list or not
|
||||
* @param peer peer information
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
* - ESP_ERR_ESPNOW_NOT_FOUND : peer is not found
|
||||
*/
|
||||
esp_err_t esp_now_fetch_peer(bool from_head, esp_now_peer_info_t *peer);
|
||||
|
||||
/**
|
||||
* @brief Peer exists or not
|
||||
*
|
||||
* @param peer_addr peer MAC address
|
||||
*
|
||||
* @return
|
||||
* - true : peer exists
|
||||
* - false : peer not exists
|
||||
*/
|
||||
bool esp_now_is_peer_exist(const uint8_t *peer_addr);
|
||||
|
||||
/**
|
||||
* @brief Get the number of peers
|
||||
*
|
||||
* @param num number of peers
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_now_get_peer_num(esp_now_peer_num_t *num);
|
||||
|
||||
/**
|
||||
* @brief Set the primary master key
|
||||
*
|
||||
* @param pmk primary master key
|
||||
*
|
||||
* @attention 1. primary master key is used to encrypt local master key
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized
|
||||
* - ESP_ERR_ESPNOW_ARG : invalid argument
|
||||
*/
|
||||
esp_err_t esp_now_set_pmk(const uint8_t *pmk);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_NOW_H__ */
|
||||
@@ -1,238 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file PHY init parameters and API
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Structure holding PHY init parameters
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t params[128]; /*!< opaque PHY initialization parameters */
|
||||
} esp_phy_init_data_t;
|
||||
|
||||
/**
|
||||
* @brief Opaque PHY calibration data
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t version[4]; /*!< PHY version */
|
||||
uint8_t mac[6]; /*!< The MAC address of the station */
|
||||
uint8_t opaque[1894]; /*!< calibration data */
|
||||
} esp_phy_calibration_data_t;
|
||||
|
||||
typedef enum {
|
||||
PHY_RF_CAL_PARTIAL = 0x00000000, /*!< Do part of RF calibration. This should be used after power-on reset. */
|
||||
PHY_RF_CAL_NONE = 0x00000001, /*!< Don't do any RF calibration. This mode is only suggested to be used after deep sleep reset. */
|
||||
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. */
|
||||
} esp_phy_calibration_mode_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Modules for modem sleep
|
||||
*/
|
||||
typedef enum{
|
||||
MODEM_BLE_MODULE, //!< BLE controller used
|
||||
MODEM_CLASSIC_BT_MODULE, //!< Classic BT controller used
|
||||
MODEM_WIFI_STATION_MODULE, //!< Wi-Fi Station used
|
||||
MODEM_WIFI_SOFTAP_MODULE, //!< Wi-Fi SoftAP used
|
||||
MODEM_WIFI_SNIFFER_MODULE, //!< Wi-Fi Sniffer used
|
||||
MODEM_WIFI_NULL_MODULE, //!< Wi-Fi Null mode used
|
||||
MODEM_USER_MODULE, //!< User used
|
||||
MODEM_MODULE_COUNT //!< Number of items
|
||||
}modem_sleep_module_t;
|
||||
|
||||
/**
|
||||
* @brief Module WIFI mask for medem sleep
|
||||
*/
|
||||
#define MODEM_BT_MASK ((1<<MODEM_BLE_MODULE) | \
|
||||
(1<<MODEM_CLASSIC_BT_MODULE))
|
||||
|
||||
/**
|
||||
* @brief Module WIFI mask for medem sleep
|
||||
*/
|
||||
#define MODEM_WIFI_MASK ((1<<MODEM_WIFI_STATION_MODULE) | \
|
||||
(1<<MODEM_WIFI_SOFTAP_MODULE) | \
|
||||
(1<<MODEM_WIFI_SNIFFER_MODULE) | \
|
||||
(1<<MODEM_WIFI_NULL_MODULE))
|
||||
|
||||
/**
|
||||
* @brief Modules needing to call phy_rf_init
|
||||
*/
|
||||
typedef enum{
|
||||
PHY_BT_MODULE, //!< Bluetooth used
|
||||
PHY_WIFI_MODULE, //!< Wi-Fi used
|
||||
PHY_MODEM_MODULE, //!< Modem sleep used
|
||||
PHY_MODULE_COUNT //!< Number of items
|
||||
}phy_rf_module_t;
|
||||
|
||||
/**
|
||||
* @brief Get PHY init data
|
||||
*
|
||||
* If "Use a partition to store PHY init data" option is set in menuconfig,
|
||||
* This function will load PHY init data from a partition. Otherwise,
|
||||
* PHY init data will be compiled into the application itself, and this function
|
||||
* will return a pointer to PHY init data located in read-only memory (DROM).
|
||||
*
|
||||
* If "Use a partition to store PHY init data" option is enabled, this function
|
||||
* may return NULL if the data loaded from flash is not valid.
|
||||
*
|
||||
* @note Call esp_phy_release_init_data to release the pointer obtained using
|
||||
* this function after the call to esp_wifi_init.
|
||||
*
|
||||
* @return pointer to PHY init data structure
|
||||
*/
|
||||
const esp_phy_init_data_t* esp_phy_get_init_data();
|
||||
|
||||
/**
|
||||
* @brief Release PHY init data
|
||||
* @param data pointer to PHY init data structure obtained from
|
||||
* esp_phy_get_init_data function
|
||||
*/
|
||||
void esp_phy_release_init_data(const esp_phy_init_data_t* data);
|
||||
|
||||
/**
|
||||
* @brief Function called by esp_phy_init to load PHY calibration data
|
||||
*
|
||||
* This is a convenience function which can be used to load PHY calibration
|
||||
* data from NVS. Data can be stored to NVS using esp_phy_store_cal_data_to_nvs
|
||||
* function.
|
||||
*
|
||||
* If calibration data is not present in the NVS, or
|
||||
* data is not valid (was obtained for a chip with a different MAC address,
|
||||
* or obtained for a different version of software), this function will
|
||||
* return an error.
|
||||
*
|
||||
* If "Initialize PHY in startup code" option is set in menuconfig, this
|
||||
* function will be used to load calibration data. To provide a different
|
||||
* mechanism for loading calibration data, disable
|
||||
* "Initialize PHY in startup code" option in menuconfig and call esp_phy_init
|
||||
* function from the application. For an example usage of esp_phy_init and
|
||||
* this function, see esp_phy_store_cal_data_to_nvs function in cpu_start.c
|
||||
*
|
||||
* @param out_cal_data pointer to calibration data structure to be filled with
|
||||
* loaded data.
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_data);
|
||||
|
||||
/**
|
||||
* @brief Function called by esp_phy_init to store PHY calibration data
|
||||
*
|
||||
* This is a convenience function which can be used to store PHY calibration
|
||||
* data to the NVS. Calibration data is returned by esp_phy_init function.
|
||||
* Data saved using this function to the NVS can later be loaded using
|
||||
* esp_phy_store_cal_data_to_nvs function.
|
||||
*
|
||||
* If "Initialize PHY in startup code" option is set in menuconfig, this
|
||||
* function will be used to store calibration data. To provide a different
|
||||
* mechanism for storing calibration data, disable
|
||||
* "Initialize PHY in startup code" option in menuconfig and call esp_phy_init
|
||||
* function from the application.
|
||||
*
|
||||
* @param cal_data pointer to calibration data which has to be saved.
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_data);
|
||||
|
||||
/**
|
||||
* @brief Erase PHY calibration data which is stored in the NVS
|
||||
*
|
||||
* This is a function which can be used to trigger full calibration as a last-resort remedy
|
||||
* if partial calibration is used. It can be called in the application based on some conditions
|
||||
* (e.g. an option provided in some diagnostic mode).
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* @return others on fail. Please refer to NVS API return value error number.
|
||||
*/
|
||||
esp_err_t esp_phy_erase_cal_data_in_nvs(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize PHY and RF module
|
||||
*
|
||||
* PHY and RF module should be initialized in order to use WiFi or BT.
|
||||
* Now PHY and RF initializing job is done automatically when start WiFi or BT. Users should not
|
||||
* call this API in their application.
|
||||
*
|
||||
* @param init_data PHY parameters. Default set of parameters can
|
||||
* be obtained by calling esp_phy_get_default_init_data
|
||||
* function.
|
||||
* @param mode Calibration mode (Full, partial, or no calibration)
|
||||
* @param[inout] calibration_data
|
||||
* @return ESP_OK on success.
|
||||
* @return ESP_FAIL on fail.
|
||||
*/
|
||||
esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data,esp_phy_calibration_mode_t mode,
|
||||
esp_phy_calibration_data_t* calibration_data, phy_rf_module_t module);
|
||||
|
||||
/**
|
||||
* @brief De-initialize PHY and RF module
|
||||
*
|
||||
* PHY module should be de-initialized in order to shutdown WiFi or BT.
|
||||
* Now PHY and RF de-initializing job is done automatically when stop WiFi or BT. Users should not
|
||||
* call this API in their application.
|
||||
*
|
||||
* @return ESP_OK on success.
|
||||
*/
|
||||
esp_err_t esp_phy_rf_deinit(phy_rf_module_t module);
|
||||
|
||||
/**
|
||||
* @brief Load calibration data from NVS and initialize PHY and RF module
|
||||
*/
|
||||
void esp_phy_load_cal_and_init(phy_rf_module_t module);
|
||||
|
||||
/**
|
||||
* @brief Module requires to enter modem sleep
|
||||
*/
|
||||
esp_err_t esp_modem_sleep_enter(modem_sleep_module_t module);
|
||||
|
||||
/**
|
||||
* @brief Module requires to exit modem sleep
|
||||
*/
|
||||
esp_err_t esp_modem_sleep_exit(modem_sleep_module_t module);
|
||||
|
||||
/**
|
||||
* @brief Register module to make it be able to require to enter/exit modem sleep
|
||||
* Although the module has no sleep function, as long as the module use RF,
|
||||
* it must call esp_modem_sleep_regsiter. Otherwise, other modules with sleep
|
||||
* function will disable RF without checking the module which doesn't call
|
||||
* esp_modem_sleep_regsiter.
|
||||
*/
|
||||
esp_err_t esp_modem_sleep_register(modem_sleep_module_t module);
|
||||
|
||||
/**
|
||||
* @brief De-register module from modem sleep list
|
||||
*/
|
||||
esp_err_t esp_modem_sleep_deregister(modem_sleep_module_t module);
|
||||
|
||||
/**
|
||||
* @brief Get the time stamp when PHY/RF was switched on
|
||||
* @return return 0 if PHY/RF is never switched on. Otherwise return time in
|
||||
* microsecond since boot when phy/rf was last switched on
|
||||
*/
|
||||
int64_t esp_phy_rf_get_on_ts(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_SMARTCONFIG_H__
|
||||
#define __ESP_SMARTCONFIG_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
SC_STATUS_WAIT = 0, /**< Waiting to start connect */
|
||||
SC_STATUS_FIND_CHANNEL, /**< Finding target channel */
|
||||
SC_STATUS_GETTING_SSID_PSWD, /**< Getting SSID and password of target AP */
|
||||
SC_STATUS_LINK, /**< Connecting to target AP */
|
||||
SC_STATUS_LINK_OVER, /**< Connected to AP successfully */
|
||||
} smartconfig_status_t;
|
||||
|
||||
typedef enum {
|
||||
SC_TYPE_ESPTOUCH = 0, /**< protocol: ESPTouch */
|
||||
SC_TYPE_AIRKISS, /**< protocol: AirKiss */
|
||||
SC_TYPE_ESPTOUCH_AIRKISS, /**< protocol: ESPTouch and AirKiss */
|
||||
} smartconfig_type_t;
|
||||
|
||||
/**
|
||||
* @brief The callback of SmartConfig, executed when smart-config status changed.
|
||||
*
|
||||
* @param status Status of SmartConfig:
|
||||
* - SC_STATUS_GETTING_SSID_PSWD : pdata is a pointer of smartconfig_type_t, means config type.
|
||||
* - SC_STATUS_LINK : pdata is a pointer to wifi_config_t.
|
||||
* - SC_STATUS_LINK_OVER : pdata is a pointer of phone's IP address(4 bytes) if pdata unequal NULL.
|
||||
* - otherwise : parameter void *pdata is NULL.
|
||||
* @param pdata According to the different status have different values.
|
||||
*
|
||||
*/
|
||||
typedef void (*sc_callback_t)(smartconfig_status_t status, void *pdata);
|
||||
|
||||
/**
|
||||
* @brief Get the version of SmartConfig.
|
||||
*
|
||||
* @return
|
||||
* - SmartConfig version const char.
|
||||
*/
|
||||
const char *esp_smartconfig_get_version(void);
|
||||
|
||||
/**
|
||||
* @brief Start SmartConfig, config ESP device to connect AP. You need to broadcast information by phone APP.
|
||||
* Device sniffer special packets from the air that containing SSID and password of target AP.
|
||||
*
|
||||
* @attention 1. This API can be called in station or softAP-station mode.
|
||||
* @attention 2. Can not call esp_smartconfig_start twice before it finish, please call
|
||||
* esp_smartconfig_stop first.
|
||||
*
|
||||
* @param cb SmartConfig callback function.
|
||||
* @param ... log 1: UART output logs; 0: UART only outputs the result.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - others: fail
|
||||
*/
|
||||
esp_err_t esp_smartconfig_start(sc_callback_t cb, ...);
|
||||
|
||||
/**
|
||||
* @brief Stop SmartConfig, free the buffer taken by esp_smartconfig_start.
|
||||
*
|
||||
* @attention Whether connect to AP succeed or not, this API should be called to free
|
||||
* memory taken by smartconfig_start.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - others: fail
|
||||
*/
|
||||
esp_err_t esp_smartconfig_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Set timeout of SmartConfig process.
|
||||
*
|
||||
* @attention Timing starts from SC_STATUS_FIND_CHANNEL status. SmartConfig will restart if timeout.
|
||||
*
|
||||
* @param time_s range 15s~255s, offset:45s.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - others: fail
|
||||
*/
|
||||
esp_err_t esp_esptouch_set_timeout(uint8_t time_s);
|
||||
|
||||
/**
|
||||
* @brief Set protocol type of SmartConfig.
|
||||
*
|
||||
* @attention If users need to set the SmartConfig type, please set it before calling
|
||||
* esp_smartconfig_start.
|
||||
*
|
||||
* @param type Choose from the smartconfig_type_t.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - others: fail
|
||||
*/
|
||||
esp_err_t esp_smartconfig_set_type(smartconfig_type_t type);
|
||||
|
||||
/**
|
||||
* @brief Set mode of SmartConfig. default normal mode.
|
||||
*
|
||||
* @attention 1. Please call it before API esp_smartconfig_start.
|
||||
* @attention 2. Fast mode have corresponding APP(phone).
|
||||
* @attention 3. Two mode is compatible.
|
||||
*
|
||||
* @param enable false-disable(default); true-enable;
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - others: fail
|
||||
*/
|
||||
esp_err_t esp_smartconfig_fast_mode(bool enable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,799 +0,0 @@
|
||||
// Hardware crypto support Copyright 2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#ifndef __ESP_WIFI_CRYPTO_TYPES_H__
|
||||
#define __ESP_WIFI_CRYPTO_TYPES_H__
|
||||
|
||||
/* This is an internal API header for configuring the implementation used for WiFi cryptographic
|
||||
operations.
|
||||
|
||||
During normal operation, you don't need to use any of these types or functions in this header.
|
||||
See esp_wifi.h & esp_wifi_types.h instead.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_WIFI_CRYPTO_VERSION 0x00000001
|
||||
|
||||
/*
|
||||
* Enumeration for hash operations.
|
||||
* When WPA2 is connecting, this enum is used to
|
||||
* request a hash algorithm via crypto_hash_xxx functions.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_CRYPTO_HASH_ALG_MD5, ESP_CRYPTO_HASH_ALG_SHA1,
|
||||
ESP_CRYPTO_HASH_ALG_HMAC_MD5, ESP_CRYPTO_HASH_ALG_HMAC_SHA1,
|
||||
ESP_CRYPTO_HASH_ALG_SHA256, ESP_CRYPTO_HASH_ALG_HMAC_SHA256
|
||||
}esp_crypto_hash_alg_t;
|
||||
|
||||
/*
|
||||
* Enumeration for block cipher operations.
|
||||
* When WPA2 is connecting, this enum is used to request a block
|
||||
* cipher algorithm via crypto_cipher_xxx functions.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_CRYPTO_CIPHER_NULL, ESP_CRYPTO_CIPHER_ALG_AES, ESP_CRYPTO_CIPHER_ALG_3DES,
|
||||
ESP_CRYPTO_CIPHER_ALG_DES, ESP_CRYPTO_CIPHER_ALG_RC2, ESP_CRYPTO_CIPHER_ALG_RC4
|
||||
} esp_crypto_cipher_alg_t;
|
||||
|
||||
/*
|
||||
* This structure is about the algorithm when do crypto_hash operation, for detail,
|
||||
* please reference to the structure crypto_hash.
|
||||
*/
|
||||
typedef struct crypto_hash esp_crypto_hash_t;
|
||||
|
||||
/*
|
||||
* This structure is about the algorithm when do crypto_cipher operation, for detail,
|
||||
* please reference to the structure crypto_cipher.
|
||||
*/
|
||||
typedef struct crypto_cipher esp_crypto_cipher_t;
|
||||
|
||||
/**
|
||||
* @brief The crypto callback function used in wpa enterprise hash operation when connect.
|
||||
* Initialize a esp_crypto_hash_t structure.
|
||||
*
|
||||
* @param alg Hash algorithm.
|
||||
* @param key Key for keyed hash (e.g., HMAC) or %NULL if not needed.
|
||||
* @param key_len Length of the key in bytes
|
||||
*
|
||||
*/
|
||||
typedef esp_crypto_hash_t * (*esp_crypto_hash_init_t)(esp_crypto_hash_alg_t alg, const unsigned char *key, int key_len);
|
||||
|
||||
/**
|
||||
* @brief The crypto callback function used in wpa enterprise hash operation when connect.
|
||||
* Add data to hash calculation.
|
||||
*
|
||||
* @param ctz Context pointer from esp_crypto_hash_init_t function.
|
||||
* @param data Data buffer to add.
|
||||
* @param len Length of the buffer.
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_crypto_hash_update_t)(esp_crypto_hash_t *ctx, const unsigned char *data, int len);
|
||||
|
||||
/**
|
||||
* @brief The crypto callback function used in wpa enterprise hash operation when connect.
|
||||
* Complete hash calculation.
|
||||
*
|
||||
* @param ctz Context pointer from esp_crypto_hash_init_t function.
|
||||
* @param hash Buffer for hash value or %NULL if caller is just freeing the hash
|
||||
* context.
|
||||
* @param len Pointer to length of the buffer or %NULL if caller is just freeing the
|
||||
* hash context; on return, this is set to the actual length of the hash value
|
||||
* Returns: 0 on success, -1 if buffer is too small (len set to needed length),
|
||||
* or -2 on other failures (including failed crypto_hash_update() operations)
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_crypto_hash_finish_t)(esp_crypto_hash_t *ctx, unsigned char *hash, int *len);
|
||||
|
||||
/**
|
||||
* @brief The AES callback function when do WPS connect.
|
||||
*
|
||||
* @param key Encryption key.
|
||||
* @param iv Encryption IV for CBC mode (16 bytes).
|
||||
* @param data Data to encrypt in-place.
|
||||
* @param data_len Length of data in bytes (must be divisible by 16)
|
||||
*/
|
||||
typedef int (*esp_aes_128_encrypt_t)(const unsigned char *key, const unsigned char *iv, unsigned char *data, int data_len);
|
||||
|
||||
/**
|
||||
* @brief The AES callback function when do WPS connect.
|
||||
*
|
||||
* @param key Decryption key.
|
||||
* @param iv Decryption IV for CBC mode (16 bytes).
|
||||
* @param data Data to decrypt in-place.
|
||||
* @param data_len Length of data in bytes (must be divisible by 16)
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_aes_128_decrypt_t)(const unsigned char *key, const unsigned char *iv, unsigned char *data, int data_len);
|
||||
|
||||
/**
|
||||
* @brief The AES callback function when do STA connect.
|
||||
*
|
||||
* @param kek 16-octet Key encryption key (KEK).
|
||||
* @param n Length of the plaintext key in 64-bit units;
|
||||
* @param plain Plaintext key to be wrapped, n * 64 bits
|
||||
* @param cipher Wrapped key, (n + 1) * 64 bits
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_aes_wrap_t)(const unsigned char *kek, int n, const unsigned char *plain, unsigned char *cipher);
|
||||
|
||||
/**
|
||||
* @brief The AES callback function when do STA connect.
|
||||
*
|
||||
* @param kek 16-octet Key decryption key (KEK).
|
||||
* @param n Length of the plaintext key in 64-bit units;
|
||||
* @param cipher Wrapped key to be unwrapped, (n + 1) * 64 bits
|
||||
* @param plain Plaintext key, n * 64 bits
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_aes_unwrap_t)(const unsigned char *kek, int n, const unsigned char *cipher, unsigned char *plain);
|
||||
|
||||
/**
|
||||
* @brief The crypto callback function used in wpa enterprise cipher operation when connect.
|
||||
* Initialize a esp_crypto_cipher_t structure.
|
||||
*
|
||||
* @param alg cipher algorithm.
|
||||
* @param iv Initialization vector for block ciphers or %NULL for stream ciphers.
|
||||
* @param key Cipher key
|
||||
* @param key_len Length of key in bytes
|
||||
*
|
||||
*/
|
||||
typedef esp_crypto_cipher_t * (*esp_crypto_cipher_init_t)(esp_crypto_cipher_alg_t alg, const unsigned char *iv, const unsigned char *key, int key_len);
|
||||
|
||||
/**
|
||||
* @brief The crypto callback function used in wpa enterprise cipher operation when connect.
|
||||
* Cipher encrypt.
|
||||
*
|
||||
* @param ctx Context pointer from esp_crypto_cipher_init_t callback function.
|
||||
* @param plain Plaintext to cipher.
|
||||
* @param crypt Resulting ciphertext.
|
||||
* @param len Length of the plaintext.
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_crypto_cipher_encrypt_t)(esp_crypto_cipher_t *ctx,
|
||||
const unsigned char *plain, unsigned char *crypt, int len);
|
||||
/**
|
||||
* @brief The crypto callback function used in wpa enterprise cipher operation when connect.
|
||||
* Cipher decrypt.
|
||||
*
|
||||
* @param ctx Context pointer from esp_crypto_cipher_init_t callback function.
|
||||
* @param crypt Ciphertext to decrypt.
|
||||
* @param plain Resulting plaintext.
|
||||
* @param len Length of the cipher text.
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_crypto_cipher_decrypt_t)(esp_crypto_cipher_t *ctx,
|
||||
const unsigned char *crypt, unsigned char *plain, int len);
|
||||
/**
|
||||
* @brief The crypto callback function used in wpa enterprise cipher operation when connect.
|
||||
* Free cipher context.
|
||||
*
|
||||
* @param ctx Context pointer from esp_crypto_cipher_init_t callback function.
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_crypto_cipher_deinit_t)(esp_crypto_cipher_t *ctx);
|
||||
|
||||
/**
|
||||
* @brief The SHA256 callback function when do WPS connect.
|
||||
*
|
||||
* @param key Key for HMAC operations.
|
||||
* @param key_len Length of the key in bytes.
|
||||
* @param data Pointers to the data area.
|
||||
* @param data_len Length of the data area.
|
||||
* @param mac Buffer for the hash (20 bytes).
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_hmac_sha256_t)(const unsigned char *key, int key_len, const unsigned char *data,
|
||||
int data_len, unsigned char *mac);
|
||||
|
||||
/**
|
||||
* @brief The SHA256 callback function when do WPS connect.
|
||||
*
|
||||
* @param key Key for HMAC operations.
|
||||
* @param key_len Length of the key in bytes.
|
||||
* @param num_elem Number of elements in the data vector.
|
||||
* @param addr Pointers to the data areas.
|
||||
* @param len Lengths of the data blocks.
|
||||
* @param mac Buffer for the hash (32 bytes).
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_hmac_sha256_vector_t)(const unsigned char *key, int key_len, int num_elem,
|
||||
const unsigned char *addr[], const int *len, unsigned char *mac);
|
||||
|
||||
/**
|
||||
* @brief The AES callback function when do STA connect.
|
||||
*
|
||||
* @param key Key for PRF.
|
||||
* @param key_len Length of the key in bytes.
|
||||
* @param label A unique label for each purpose of the PRF.
|
||||
* @param data Extra data to bind into the key.
|
||||
* @param data_len Length of the data.
|
||||
* @param buf Buffer for the generated pseudo-random key.
|
||||
* @param buf_len Number of bytes of key to generate.
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_sha256_prf_t)(const unsigned char *key, int key_len, const char *label,
|
||||
const unsigned char *data, int data_len, unsigned char *buf, int buf_len);
|
||||
|
||||
/**
|
||||
* @brief The SHA256 callback function when do WPS connect.
|
||||
*
|
||||
* @param num_elem Number of elements in the data vector.
|
||||
* @param addr Pointers to the data areas.
|
||||
* @param len Lengths of the data blocks.
|
||||
* @paramac Buffer for the hash.
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_sha256_vector_t)(int num_elem, const unsigned char *addr[], const int *len,
|
||||
unsigned char *mac);
|
||||
|
||||
/**
|
||||
* @brief The bignum calculate callback function used when do connect.
|
||||
* In WPS process, it used to calculate public key and private key.
|
||||
*
|
||||
* @param base Base integer (big endian byte array).
|
||||
* @param base_len Length of base integer in bytes.
|
||||
* @param power Power integer (big endian byte array).
|
||||
* @param power_len Length of power integer in bytes.
|
||||
* @param modulus Modulus integer (big endian byte array).
|
||||
* @param modulus_len Length of modulus integer in bytes.
|
||||
* @param result Buffer for the result.
|
||||
* @param result_len Result length (max buffer size on input, real len on output).
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_crypto_mod_exp_t)(const unsigned char *base, int base_len,
|
||||
const unsigned char *power, int power_len,
|
||||
const unsigned char *modulus, int modulus_len,
|
||||
unsigned char *result, unsigned int *result_len);
|
||||
|
||||
/**
|
||||
* @brief HMAC-MD5 over data buffer (RFC 2104)'
|
||||
*
|
||||
* @key: Key for HMAC operations
|
||||
* @key_len: Length of the key in bytes
|
||||
* @data: Pointers to the data area
|
||||
* @data_len: Length of the data area
|
||||
* @mac: Buffer for the hash (16 bytes)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
typedef int (*esp_hmac_md5_t)(const unsigned char *key, unsigned int key_len, const unsigned char *data,
|
||||
unsigned int data_len, unsigned char *mac);
|
||||
|
||||
/**
|
||||
* @brief HMAC-MD5 over data vector (RFC 2104)
|
||||
*
|
||||
* @key: Key for HMAC operations
|
||||
* @key_len: Length of the key in bytes
|
||||
* @num_elem: Number of elements in the data vector
|
||||
* @addr: Pointers to the data areas
|
||||
* @len: Lengths of the data blocks
|
||||
* @mac: Buffer for the hash (16 bytes)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
typedef int (*esp_hmac_md5_vector_t)(const unsigned char *key, unsigned int key_len, unsigned int num_elem,
|
||||
const unsigned char *addr[], const unsigned int *len, unsigned char *mac);
|
||||
|
||||
/**
|
||||
* @brief HMAC-SHA1 over data buffer (RFC 2104)
|
||||
*
|
||||
* @key: Key for HMAC operations
|
||||
* @key_len: Length of the key in bytes
|
||||
* @data: Pointers to the data area
|
||||
* @data_len: Length of the data area
|
||||
* @mac: Buffer for the hash (20 bytes)
|
||||
* Returns: 0 on success, -1 of failure
|
||||
*/
|
||||
typedef int (*esp_hmac_sha1_t)(const unsigned char *key, unsigned int key_len, const unsigned char *data,
|
||||
unsigned int data_len, unsigned char *mac);
|
||||
|
||||
/**
|
||||
* @brief HMAC-SHA1 over data vector (RFC 2104)
|
||||
*
|
||||
* @key: Key for HMAC operations
|
||||
* @key_len: Length of the key in bytes
|
||||
* @num_elem: Number of elements in the data vector
|
||||
* @addr: Pointers to the data areas
|
||||
* @len: Lengths of the data blocks
|
||||
* @mac: Buffer for the hash (20 bytes)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
typedef int (*esp_hmac_sha1_vector_t)(const unsigned char *key, unsigned int key_len, unsigned int num_elem,
|
||||
const unsigned char *addr[], const unsigned int *len, unsigned char *mac);
|
||||
|
||||
/**
|
||||
* @brief SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1)
|
||||
*
|
||||
* @key: Key for PRF
|
||||
* @key_len: Length of the key in bytes
|
||||
* @label: A unique label for each purpose of the PRF
|
||||
* @data: Extra data to bind into the key
|
||||
* @data_len: Length of the data
|
||||
* @buf: Buffer for the generated pseudo-random key
|
||||
* @buf_len: Number of bytes of key to generate
|
||||
* Returns: 0 on success, -1 of failure
|
||||
*
|
||||
* This function is used to derive new, cryptographically separate keys from a
|
||||
* given key (e.g., PMK in IEEE 802.11i).
|
||||
*/
|
||||
typedef int (*esp_sha1_prf_t)(const unsigned char *key, unsigned int key_len, const char *label,
|
||||
const unsigned char *data, unsigned int data_len, unsigned char *buf, unsigned int buf_len);
|
||||
|
||||
/**
|
||||
* @brief SHA-1 hash for data vector
|
||||
*
|
||||
* @num_elem: Number of elements in the data vector
|
||||
* @addr: Pointers to the data areas
|
||||
* @len: Lengths of the data blocks
|
||||
* @mac: Buffer for the hash
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
typedef int (*esp_sha1_vector_t)(unsigned int num_elem, const unsigned char *addr[], const unsigned int *len,
|
||||
unsigned char *mac);
|
||||
|
||||
/**
|
||||
* @brief SHA1-based key derivation function (PBKDF2) for IEEE 802.11i
|
||||
*
|
||||
* @passphrase: ASCII passphrase
|
||||
* @ssid: SSID
|
||||
* @ssid_len: SSID length in bytes
|
||||
* @iterations: Number of iterations to run
|
||||
* @buf: Buffer for the generated key
|
||||
* @buflen: Length of the buffer in bytes
|
||||
* Returns: 0 on success, -1 of failure
|
||||
*
|
||||
* This function is used to derive PSK for WPA-PSK. For this protocol,
|
||||
* iterations is set to 4096 and buflen to 32. This function is described in
|
||||
* IEEE Std 802.11-2004, Clause H.4. The main construction is from PKCS#5 v2.0.
|
||||
*/
|
||||
typedef int (*esp_pbkdf2_sha1_t)(const char *passphrase, const char *ssid, unsigned int ssid_len,
|
||||
int iterations, unsigned char *buf, unsigned int buflen);
|
||||
|
||||
/**
|
||||
* @brief XOR RC4 stream to given data with skip-stream-start
|
||||
*
|
||||
* @key: RC4 key
|
||||
* @keylen: RC4 key length
|
||||
* @skip: number of bytes to skip from the beginning of the RC4 stream
|
||||
* @data: data to be XOR'ed with RC4 stream
|
||||
* @data_len: buf length
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Generate RC4 pseudo random stream for the given key, skip beginning of the
|
||||
* stream, and XOR the end result with the data buffer to perform RC4
|
||||
* encryption/decryption.
|
||||
*/
|
||||
typedef int (*esp_rc4_skip_t)(const unsigned char *key, unsigned int keylen, unsigned int skip,
|
||||
unsigned char *data, unsigned int data_len);
|
||||
|
||||
/**
|
||||
* @brief MD5 hash for data vector
|
||||
*
|
||||
* @num_elem: Number of elements in the data vector
|
||||
* @addr: Pointers to the data areas
|
||||
* @len: Lengths of the data blocks
|
||||
* @mac: Buffer for the hash
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
typedef int (*esp_md5_vector_t)(unsigned int num_elem, const unsigned char *addr[], const unsigned int *len,
|
||||
unsigned char *mac);
|
||||
|
||||
/**
|
||||
* @brief Encrypt one AES block
|
||||
*
|
||||
* @ctx: Context pointer from aes_encrypt_init()
|
||||
* @plain: Plaintext data to be encrypted (16 bytes)
|
||||
* @crypt: Buffer for the encrypted data (16 bytes)
|
||||
*/
|
||||
typedef void (*esp_aes_encrypt_t)(void *ctx, const unsigned char *plain, unsigned char *crypt);
|
||||
|
||||
/**
|
||||
* @brief Initialize AES for encryption
|
||||
*
|
||||
* @key: Encryption key
|
||||
* @len: Key length in bytes (usually 16, i.e., 128 bits)
|
||||
* Returns: Pointer to context data or %NULL on failure
|
||||
*/
|
||||
typedef void * (*esp_aes_encrypt_init_t)(const unsigned char *key, unsigned int len);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize AES encryption
|
||||
*
|
||||
* @ctx: Context pointer from aes_encrypt_init()
|
||||
*/
|
||||
typedef void (*esp_aes_encrypt_deinit_t)(void *ctx);
|
||||
|
||||
/**
|
||||
* @brief Decrypt one AES block
|
||||
*
|
||||
* @ctx: Context pointer from aes_encrypt_init()
|
||||
* @crypt: Encrypted data (16 bytes)
|
||||
* @plain: Buffer for the decrypted data (16 bytes)
|
||||
*/
|
||||
typedef void (*esp_aes_decrypt_t)(void *ctx, const unsigned char *crypt, unsigned char *plain);
|
||||
|
||||
/**
|
||||
* @brief Initialize AES for decryption
|
||||
*
|
||||
* @key: Decryption key
|
||||
* @len: Key length in bytes (usually 16, i.e., 128 bits)
|
||||
* Returns: Pointer to context data or %NULL on failure
|
||||
*/
|
||||
typedef void * (*esp_aes_decrypt_init_t)(const unsigned char *key, unsigned int len);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize AES decryption
|
||||
*
|
||||
* @ctx: Context pointer from aes_encrypt_init()
|
||||
*/
|
||||
typedef void (*esp_aes_decrypt_deinit_t)(void *ctx);
|
||||
|
||||
/**
|
||||
* @brief Initialize TLS library
|
||||
*
|
||||
* @conf: Configuration data for TLS library
|
||||
* Returns: Context data to be used as tls_ctx in calls to other functions,
|
||||
* or %NULL on failure.
|
||||
*
|
||||
* Called once during program startup and once for each RSN pre-authentication
|
||||
* session. In other words, there can be two concurrent TLS contexts. If global
|
||||
* library initialization is needed (i.e., one that is shared between both
|
||||
* authentication types), the TLS library wrapper should maintain a reference
|
||||
* counter and do global initialization only when moving from 0 to 1 reference.
|
||||
*/
|
||||
typedef void * (*esp_tls_init_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize TLS library
|
||||
*
|
||||
* @tls_ctx: TLS context data from tls_init()
|
||||
*
|
||||
* Called once during program shutdown and once for each RSN pre-authentication
|
||||
* session. If global library deinitialization is needed (i.e., one that is
|
||||
* shared between both authentication types), the TLS library wrapper should
|
||||
* maintain a reference counter and do global deinitialization only when moving
|
||||
* from 1 to 0 references.
|
||||
*/
|
||||
typedef void (*esp_tls_deinit_t)(void *tls_ctx);
|
||||
|
||||
/**
|
||||
* @brief Add certificate and private key for connect
|
||||
|
||||
* @sm: eap state machine
|
||||
*
|
||||
* Returns: 0 for success, -1 state machine didn't exist, -2 short of certificate or key
|
||||
*/
|
||||
typedef int (*esp_eap_peer_blob_init_t)(void *sm);
|
||||
|
||||
/**
|
||||
* @brief delete the certificate and private
|
||||
*
|
||||
* @sm: eap state machine
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_eap_peer_blob_deinit_t)(void *sm);
|
||||
|
||||
/**
|
||||
* @brief Initialize the eap state machine
|
||||
*
|
||||
* @sm: eap state machine
|
||||
* @private_key_passwd: the start address of private_key_passwd
|
||||
* @private_key_passwd_len: length of private_key_password
|
||||
*
|
||||
* Returns: 0 is success, -1 state machine didn't exist, -2 short of parameters
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_eap_peer_config_init_t)(void *sm, unsigned char *private_key_passwd,int private_key_passwd_len);
|
||||
|
||||
/**
|
||||
* @brief Deinit the eap state machine
|
||||
*
|
||||
* @sm: eap state machine
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_eap_peer_config_deinit_t)(void *sm);
|
||||
|
||||
/**
|
||||
* @brief Register the eap method
|
||||
*
|
||||
* Note: ESP32 only support PEAP/TTLS/TLS three eap methods now.
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_eap_peer_register_methods_t)(void);
|
||||
|
||||
/**
|
||||
* @brief remove the eap method
|
||||
*
|
||||
* Note: ESP32 only support PEAP/TTLS/TLS three eap methods now.
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_eap_peer_unregister_methods_t)(void);
|
||||
|
||||
/**
|
||||
* @brief remove the eap method before build new connect
|
||||
*
|
||||
* @sm: eap state machine
|
||||
* @txt: not used now
|
||||
*/
|
||||
typedef void (*esp_eap_deinit_prev_method_t)(void *sm, const char *txt);
|
||||
|
||||
/**
|
||||
* @brief Get EAP method based on type number
|
||||
*
|
||||
* @vendor: EAP Vendor-Id (0 = IETF)
|
||||
* @method: EAP type number
|
||||
* Returns: Pointer to EAP method or %NULL if not found
|
||||
*/
|
||||
typedef const void * (*esp_eap_peer_get_eap_method_t)(int vendor, int method);
|
||||
|
||||
/**
|
||||
* @brief Abort EAP authentication
|
||||
*
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
*
|
||||
* Release system resources that have been allocated for the authentication
|
||||
* session without fully deinitializing the EAP state machine.
|
||||
*/
|
||||
typedef void (*esp_eap_sm_abort_t)(void *sm);
|
||||
|
||||
/**
|
||||
* @brief Build EAP-NAK for the current network
|
||||
*
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @type: EAP type of the fail reason
|
||||
* @id: EAP identifier for the packet
|
||||
*
|
||||
* This function allocates and builds a nak packet for the
|
||||
* current network. The caller is responsible for freeing the returned data.
|
||||
*/
|
||||
typedef void * (*esp_eap_sm_build_nak_t)(void *sm, int type, unsigned char id);
|
||||
|
||||
/**
|
||||
* @brief Build EAP-Identity/Response for the current network
|
||||
*
|
||||
* @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
|
||||
* @id: EAP identifier for the packet
|
||||
* @encrypted: Whether the packet is for encrypted tunnel (EAP phase 2)
|
||||
* Returns: Pointer to the allocated EAP-Identity/Response packet or %NULL on
|
||||
* failure
|
||||
*
|
||||
* This function allocates and builds an EAP-Identity/Response packet for the
|
||||
* current network. The caller is responsible for freeing the returned data.
|
||||
*/
|
||||
typedef void * (*esp_eap_sm_build_identity_resp_t)(void *sm, unsigned char id, int encrypted);
|
||||
|
||||
/**
|
||||
* @brief Allocate a buffer for an EAP message
|
||||
*
|
||||
* @vendor: Vendor-Id (0 = IETF)
|
||||
* @type: EAP type
|
||||
* @payload_len: Payload length in bytes (data after Type)
|
||||
* @code: Message Code (EAP_CODE_*)
|
||||
* @identifier: Identifier
|
||||
* Returns: Pointer to the allocated message buffer or %NULL on error
|
||||
*
|
||||
* This function can be used to allocate a buffer for an EAP message and fill
|
||||
* in the EAP header. This function is automatically using expanded EAP header
|
||||
* if the selected Vendor-Id is not IETF. In other words, most EAP methods do
|
||||
* not need to separately select which header type to use when using this
|
||||
* function to allocate the message buffers. The returned buffer has room for
|
||||
* payload_len bytes and has the EAP header and Type field already filled in.
|
||||
*/
|
||||
typedef void * (*esp_eap_msg_alloc_t)(int vendor, int type, unsigned int payload_len,
|
||||
unsigned char code, unsigned char identifier);
|
||||
|
||||
/**
|
||||
* @brief get the enrollee mac address
|
||||
* @mac_addr: instore the mac address of enrollee
|
||||
* @uuid: Universally Unique Identifer of the enrollee
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_uuid_gen_mac_addr_t)(const unsigned char *mac_addr, unsigned char *uuid);
|
||||
|
||||
/**
|
||||
* @brief free the message after finish DH
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_dh5_free_t)(void *ctx);
|
||||
|
||||
/**
|
||||
* @brief Build WPS IE for (Re)Association Request
|
||||
*
|
||||
* @req_type: Value for Request Type attribute
|
||||
* Returns: WPS IE or %NULL on failure
|
||||
*
|
||||
* The caller is responsible for freeing the buffer.
|
||||
*/
|
||||
typedef void * (*esp_wps_build_assoc_req_ie_t)(int req_type);
|
||||
|
||||
/**
|
||||
* @brief Build WPS IE for (Re)Association Response
|
||||
*
|
||||
* Returns: WPS IE or %NULL on failure
|
||||
*
|
||||
* The caller is responsible for freeing the buffer.
|
||||
*/
|
||||
typedef void * (*esp_wps_build_assoc_resp_ie_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Build WPS IE for Probe Request
|
||||
*
|
||||
* @pw_id: Password ID (DEV_PW_PUSHBUTTON for active PBC and DEV_PW_DEFAULT for
|
||||
* most other use cases)
|
||||
* @dev: Device attributes
|
||||
* @uuid: Own UUID
|
||||
* @req_type: Value for Request Type attribute
|
||||
* @num_req_dev_types: Number of requested device types
|
||||
* @req_dev_types: Requested device types (8 * num_req_dev_types octets) or
|
||||
* %NULL if none
|
||||
* Returns: WPS IE or %NULL on failure
|
||||
*
|
||||
* The caller is responsible for freeing the buffer.
|
||||
*/
|
||||
typedef void * (*esp_wps_build_probe_req_ie_t)(uint16_t pw_id, void *dev, const unsigned char *uuid,
|
||||
int req_type, unsigned int num_req_dev_types, const unsigned char *req_dev_types);
|
||||
|
||||
/**
|
||||
* @brief build public key for exchange in M1
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_wps_build_public_key_t)(void *wps, void *msg, int mode);
|
||||
|
||||
|
||||
/**
|
||||
* @brief get the wps information in exchange password
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef void * (*esp_wps_enrollee_get_msg_t)(void *wps, void *op_code);
|
||||
|
||||
/**
|
||||
* @brief deal with the wps information in exchange password
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef int (*esp_wps_enrollee_process_msg_t)(void *wps, int op_code, const void *msg);
|
||||
|
||||
/**
|
||||
* @brief Generate a random PIN
|
||||
*
|
||||
* Returns: Eight digit PIN (i.e., including the checksum digit)
|
||||
*/
|
||||
typedef unsigned int (*esp_wps_generate_pin_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Check whether WPS IE indicates active PIN
|
||||
*
|
||||
* @msg: WPS IE contents from Beacon or Probe Response frame
|
||||
* Returns: 1 if PIN Registrar is active, 0 if not
|
||||
*/
|
||||
typedef int (*esp_wps_is_selected_pin_registrar_t)(const void *msg, unsigned char *bssid);
|
||||
|
||||
/**
|
||||
* @brief Check whether WPS IE indicates active PBC
|
||||
*
|
||||
* @msg: WPS IE contents from Beacon or Probe Response frame
|
||||
* Returns: 1 if PBC Registrar is active, 0 if not
|
||||
*/
|
||||
typedef int (*esp_wps_is_selected_pbc_registrar_t)(const void *msg, unsigned char *bssid);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief The crypto callback function structure used when do station security connect.
|
||||
* The structure can be set as software crypto or the crypto optimized by ESP32
|
||||
* hardware.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t size;
|
||||
uint32_t version;
|
||||
esp_aes_wrap_t aes_wrap; /**< station connect function used when send EAPOL frame */
|
||||
esp_aes_unwrap_t aes_unwrap; /**< station connect function used when decrypt key data */
|
||||
esp_hmac_sha256_vector_t hmac_sha256_vector; /**< station connect function used when check MIC */
|
||||
esp_sha256_prf_t sha256_prf; /**< station connect function used when check MIC */
|
||||
esp_hmac_md5_t hmac_md5;
|
||||
esp_hmac_md5_vector_t hamc_md5_vector;
|
||||
esp_hmac_sha1_t hmac_sha1;
|
||||
esp_hmac_sha1_vector_t hmac_sha1_vector;
|
||||
esp_sha1_prf_t sha1_prf;
|
||||
esp_sha1_vector_t sha1_vector;
|
||||
esp_pbkdf2_sha1_t pbkdf2_sha1;
|
||||
esp_rc4_skip_t rc4_skip;
|
||||
esp_md5_vector_t md5_vector;
|
||||
esp_aes_encrypt_t aes_encrypt;
|
||||
esp_aes_encrypt_init_t aes_encrypt_init;
|
||||
esp_aes_encrypt_deinit_t aes_encrypt_deinit;
|
||||
esp_aes_decrypt_t aes_decrypt;
|
||||
esp_aes_decrypt_init_t aes_decrypt_init;
|
||||
esp_aes_decrypt_deinit_t aes_decrypt_deinit;
|
||||
}wpa_crypto_funcs_t;
|
||||
|
||||
/**
|
||||
* @brief The crypto callback function structure used when do WPS process. The
|
||||
* structure can be set as software crypto or the crypto optimized by ESP32
|
||||
* hardware.
|
||||
*/
|
||||
typedef struct{
|
||||
uint32_t size;
|
||||
uint32_t version;
|
||||
esp_aes_128_encrypt_t aes_128_encrypt; /**< function used to process message when do WPS */
|
||||
esp_aes_128_decrypt_t aes_128_decrypt; /**< function used to process message when do WPS */
|
||||
esp_crypto_mod_exp_t crypto_mod_exp; /**< function used to calculate public key and private key */
|
||||
esp_hmac_sha256_t hmac_sha256; /**< function used to get attribute */
|
||||
esp_hmac_sha256_vector_t hmac_sha256_vector; /**< function used to process message when do WPS */
|
||||
esp_sha256_vector_t sha256_vector; /**< function used to process message when do WPS */
|
||||
esp_uuid_gen_mac_addr_t uuid_gen_mac_addr;
|
||||
esp_dh5_free_t dh5_free;
|
||||
esp_wps_build_assoc_req_ie_t wps_build_assoc_req_ie;
|
||||
esp_wps_build_assoc_resp_ie_t wps_build_assoc_resp_ie;
|
||||
esp_wps_build_probe_req_ie_t wps_build_probe_req_ie;
|
||||
esp_wps_build_public_key_t wps_build_public_key;
|
||||
esp_wps_enrollee_get_msg_t wps_enrollee_get_msg;
|
||||
esp_wps_enrollee_process_msg_t wps_enrollee_process_msg;
|
||||
esp_wps_generate_pin_t wps_generate_pin;
|
||||
esp_wps_is_selected_pin_registrar_t wps_is_selected_pin_registrar;
|
||||
esp_wps_is_selected_pbc_registrar_t wps_is_selected_pbc_registrar;
|
||||
esp_eap_msg_alloc_t eap_msg_alloc;
|
||||
}wps_crypto_funcs_t;
|
||||
|
||||
/**
|
||||
* @brief The crypto callback function structure used when do WPA enterprise connect.
|
||||
* The structure can be set as software crypto or the crypto optimized by ESP32
|
||||
* hardware.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t size;
|
||||
uint32_t version;
|
||||
esp_crypto_hash_init_t crypto_hash_init; /**< function used to initialize a crypto_hash structure when use TLSV1 */
|
||||
esp_crypto_hash_update_t crypto_hash_update; /**< function used to calculate hash data when use TLSV1 */
|
||||
esp_crypto_hash_finish_t crypto_hash_finish; /**< function used to finish the hash calculate when use TLSV1 */
|
||||
esp_crypto_cipher_init_t crypto_cipher_init; /**< function used to initialize a crypt_cipher structure when use TLSV1 */
|
||||
esp_crypto_cipher_encrypt_t crypto_cipher_encrypt; /**< function used to encrypt cipher when use TLSV1 */
|
||||
esp_crypto_cipher_decrypt_t crypto_cipher_decrypt; /**< function used to decrypt cipher when use TLSV1 */
|
||||
esp_crypto_cipher_deinit_t crypto_cipher_deinit; /**< function used to free context when use TLSV1 */
|
||||
esp_crypto_mod_exp_t crypto_mod_exp; /**< function used to do key exchange when use TLSV1 */
|
||||
esp_sha256_vector_t sha256_vector; /**< function used to do X.509v3 certificate parsing and processing */
|
||||
esp_tls_init_t tls_init;
|
||||
esp_tls_deinit_t tls_deinit;
|
||||
esp_eap_peer_blob_init_t eap_peer_blob_init;
|
||||
esp_eap_peer_blob_deinit_t eap_peer_blob_deinit;
|
||||
esp_eap_peer_config_init_t eap_peer_config_init;
|
||||
esp_eap_peer_config_deinit_t eap_peer_config_deinit;
|
||||
esp_eap_peer_register_methods_t eap_peer_register_methods;
|
||||
esp_eap_peer_unregister_methods_t eap_peer_unregister_methods;
|
||||
esp_eap_deinit_prev_method_t eap_deinit_prev_method;
|
||||
esp_eap_peer_get_eap_method_t eap_peer_get_eap_method;
|
||||
esp_eap_sm_abort_t eap_sm_abort;
|
||||
esp_eap_sm_build_nak_t eap_sm_build_nak;
|
||||
esp_eap_sm_build_identity_resp_t eap_sm_build_identity_resp;
|
||||
esp_eap_msg_alloc_t eap_msg_alloc;
|
||||
} wpa2_crypto_funcs_t;
|
||||
|
||||
/**
|
||||
* @brief The crypto callback function structure used in mesh vendor IE encryption. The
|
||||
* structure can be set as software crypto or the crypto optimized by ESP32
|
||||
* hardware.
|
||||
*/
|
||||
typedef struct{
|
||||
esp_aes_128_encrypt_t aes_128_encrypt; /**< function used in mesh vendor IE encryption */
|
||||
esp_aes_128_decrypt_t aes_128_decrypt; /**< function used in mesh vendor IE decryption */
|
||||
} mesh_crypto_funcs_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,314 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*
|
||||
* All the APIs declared here are internal only APIs, it can only be used by
|
||||
* espressif internal modules, such as SSC, LWIP, TCPIP adapter etc, espressif
|
||||
* customers are not recommended to use them.
|
||||
*
|
||||
* If someone really want to use specified APIs declared in here, please contact
|
||||
* espressif AE/developer to make sure you know the limitations or risk of
|
||||
* the API, otherwise you may get unexpected behavior!!!
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __ESP_WIFI_INTERNAL_H__
|
||||
#define __ESP_WIFI_INTERNAL_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "sys/queue.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_types.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
QueueHandle_t handle; /**< FreeRTOS queue handler */
|
||||
void *storage; /**< storage for FreeRTOS queue */
|
||||
} wifi_static_queue_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi log level
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_LOG_ERROR = 0, /*enabled by default*/
|
||||
WIFI_LOG_WARNING, /*enabled by default*/
|
||||
WIFI_LOG_INFO, /*enabled by default*/
|
||||
WIFI_LOG_DEBUG, /*can be set in menuconfig*/
|
||||
WIFI_LOG_VERBOSE, /*can be set in menuconfig*/
|
||||
} wifi_log_level_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi log module definition
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_LOG_MODULE_ALL = 0, /*all log modules */
|
||||
WIFI_LOG_MODULE_WIFI, /*logs related to WiFi*/
|
||||
WIFI_LOG_MODULE_COEX, /*logs related to WiFi and BT(or BLE) coexist*/
|
||||
WIFI_LOG_MODULE_MESH, /*logs related to Mesh*/
|
||||
} wifi_log_module_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi log submodule definition
|
||||
*
|
||||
*/
|
||||
#define WIFI_LOG_SUBMODULE_ALL (0) /*all log submodules*/
|
||||
#define WIFI_LOG_SUBMODULE_INIT (1) /*logs related to initialization*/
|
||||
#define WIFI_LOG_SUBMODULE_IOCTL (1<<1) /*logs related to API calling*/
|
||||
#define WIFI_LOG_SUBMODULE_CONN (1<<2) /*logs related to connecting*/
|
||||
#define WIFI_LOG_SUBMODULE_SCAN (1<<3) /*logs related to scaning*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize Wi-Fi Driver
|
||||
* Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
|
||||
* WiFi NVS structure among others.
|
||||
*
|
||||
* For the most part, you need not call this function directly. It gets called
|
||||
* from esp_wifi_init().
|
||||
*
|
||||
* This function may be called, if you only need to initialize the Wi-Fi driver
|
||||
* without having to use the network stack on top.
|
||||
*
|
||||
* @param config provide WiFi init configuration
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_NO_MEM: out of memory
|
||||
* - others: refer to error code esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_init_internal(const wifi_init_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief get whether the wifi driver is allowed to transmit data or not
|
||||
*
|
||||
* @return
|
||||
* - true : upper layer should stop to transmit data to wifi driver
|
||||
* - false : upper layer can transmit data to wifi driver
|
||||
*/
|
||||
bool esp_wifi_internal_tx_is_stop(void);
|
||||
|
||||
/**
|
||||
* @brief free the rx buffer which allocated by wifi driver
|
||||
*
|
||||
* @param void* buffer: rx buffer pointer
|
||||
*/
|
||||
void esp_wifi_internal_free_rx_buffer(void* buffer);
|
||||
|
||||
/**
|
||||
* @brief transmit the buffer via wifi driver
|
||||
*
|
||||
* @param wifi_interface_t wifi_if : wifi interface id
|
||||
* @param void *buffer : the buffer to be tansmit
|
||||
* @param uint16_t len : the length of buffer
|
||||
*
|
||||
* @return
|
||||
* - ERR_OK : Successfully transmit the buffer to wifi driver
|
||||
* - ERR_MEM : Out of memory
|
||||
* - ERR_IF : WiFi driver error
|
||||
* - ERR_ARG : Invalid argument
|
||||
*/
|
||||
int esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief The WiFi RX callback function
|
||||
*
|
||||
* Each time the WiFi need to forward the packets to high layer, the callback function will be called
|
||||
*/
|
||||
typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void *eb);
|
||||
|
||||
/**
|
||||
* @brief Set the WiFi RX callback
|
||||
*
|
||||
* @attention 1. Currently we support only one RX callback for each interface
|
||||
*
|
||||
* @param wifi_interface_t ifx : interface
|
||||
* @param wifi_rxcb_t fn : WiFi RX callback
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - others : fail
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn);
|
||||
|
||||
/**
|
||||
* @brief Notify WIFI driver that the station got ip successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - others : fail
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_set_sta_ip(void);
|
||||
|
||||
/**
|
||||
* @brief enable or disable transmitting WiFi MAC frame with fixed rate
|
||||
*
|
||||
* @attention 1. If fixed rate is enabled, both management and data frame are transmitted with fixed rate
|
||||
* @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
|
||||
*
|
||||
* @param ifx : wifi interface
|
||||
* @param en : false - disable, true - enable
|
||||
* @param rate : PHY rate
|
||||
*
|
||||
* @return
|
||||
* - ERR_OK : succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_STARTED: WiFi was not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_IF : invalid WiFi interface
|
||||
* - ESP_ERR_INVALID_ARG : invalid rate
|
||||
* - ESP_ERR_NOT_SUPPORTED : do not support to set fixed rate if TX AMPDU is enabled
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_set_fix_rate(wifi_interface_t ifx, bool en, wifi_phy_rate_t rate);
|
||||
|
||||
/**
|
||||
* @brief Check the MD5 values of the OS adapter header files in IDF and WiFi library
|
||||
*
|
||||
* @attention 1. It is used for internal CI version check
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_WIFI_INVALID_ARG : MD5 check fail
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_osi_funcs_md5_check(const char *md5);
|
||||
|
||||
/**
|
||||
* @brief Check the MD5 values of the crypto types header files in IDF and WiFi library
|
||||
*
|
||||
* @attention 1. It is used for internal CI version check
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_WIFI_INVALID_ARG : MD5 check fail
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_crypto_funcs_md5_check(const char *md5);
|
||||
|
||||
/**
|
||||
* @brief Check the git commit id of WiFi library
|
||||
*
|
||||
* @attention 1. It is used for internal CI WiFi library check
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_FAIL : fail
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_git_commit_id_check(void);
|
||||
|
||||
/**
|
||||
* @brief Allocate a chunk of memory for WiFi driver
|
||||
*
|
||||
* @attention This API is not used for DMA memory allocation.
|
||||
*
|
||||
* @param size_t size : Size, in bytes, of the amount of memory to allocate
|
||||
*
|
||||
* @return A pointer to the memory allocated on success, NULL on failure
|
||||
*/
|
||||
void *wifi_malloc( size_t size );
|
||||
|
||||
/**
|
||||
* @brief Reallocate a chunk of memory for WiFi driver
|
||||
*
|
||||
* @attention This API is not used for DMA memory allocation.
|
||||
*
|
||||
* @param void * ptr : Pointer to previously allocated memory, or NULL for a new allocation.
|
||||
* @param size_t size : Size, in bytes, of the amount of memory to allocate
|
||||
*
|
||||
* @return A pointer to the memory allocated on success, NULL on failure
|
||||
*/
|
||||
void *wifi_realloc( void *ptr, size_t size );
|
||||
|
||||
/**
|
||||
* @brief Callocate memory for WiFi driver
|
||||
*
|
||||
* @attention This API is not used for DMA memory allocation.
|
||||
*
|
||||
* @param size_t n : Number of continuing chunks of memory to allocate
|
||||
* @param size_t size : Size, in bytes, of the amount of memory to allocate
|
||||
*
|
||||
* @return A pointer to the memory allocated on success, NULL on failure
|
||||
*/
|
||||
void *wifi_calloc( size_t n, size_t size );
|
||||
|
||||
/**
|
||||
* @brief Update WiFi MAC time
|
||||
*
|
||||
* @param uint32_t time_delta : time duration since the WiFi/BT common clock is disabled
|
||||
*
|
||||
* @return Always returns ESP_OK
|
||||
*/
|
||||
typedef esp_err_t (* wifi_mac_time_update_cb_t)( uint32_t time_delta );
|
||||
|
||||
/**
|
||||
* @brief Update WiFi MAC time
|
||||
*
|
||||
* @param uint32_t time_delta : time duration since the WiFi/BT common clock is disabled
|
||||
*
|
||||
* @return Always returns ESP_OK
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_update_mac_time( uint32_t time_delta );
|
||||
|
||||
/**
|
||||
* @brief Set current WiFi log level
|
||||
*
|
||||
* @param level Log level.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_FAIL: level is invalid
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_set_log_level(wifi_log_level_t level);
|
||||
|
||||
/**
|
||||
* @brief Set current log module and submodule
|
||||
*
|
||||
* @param module Log module
|
||||
* @param submodule Log submodule
|
||||
* @param enable enable or disable
|
||||
* If module == 0 && enable == 0, all log modules are disabled.
|
||||
* If module == 0 && enable == 1, all log modules are enabled.
|
||||
* If submodule == 0 && enable == 0, all log submodules are disabled.
|
||||
* If submodule == 0 && enable == 1, all log submodules are enabled.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG: invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_set_log_mod(wifi_log_module_t module, uint32_t submodule, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Get current WiFi log info
|
||||
*
|
||||
* @param log_level the return log level.
|
||||
* @param log_mod the return log module and submodule
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
*/
|
||||
esp_err_t esp_wifi_internal_get_log(wifi_log_level_t *log_level, uint32_t *log_mod);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_WIFI_H__ */
|
||||
@@ -1,134 +0,0 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef ESP_WIFI_OS_ADAPTER_H_
|
||||
#define ESP_WIFI_OS_ADAPTER_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000002
|
||||
#define ESP_WIFI_OS_ADAPTER_MAGIC 0xDEADBEAF
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
|
||||
#define OSI_QUEUE_SEND_FRONT 0
|
||||
#define OSI_QUEUE_SEND_BACK 1
|
||||
#define OSI_QUEUE_SEND_OVERWRITE 2
|
||||
|
||||
typedef struct {
|
||||
int32_t _version;
|
||||
void (*_set_isr)(int32_t n, void *f, void *arg);
|
||||
void (*_ints_on)(uint32_t mask);
|
||||
void (*_ints_off)(uint32_t mask);
|
||||
void *(* _spin_lock_create)(void);
|
||||
void (* _spin_lock_delete)(void *lock);
|
||||
uint32_t (*_wifi_int_disable)(void *wifi_int_mux);
|
||||
void (*_wifi_int_restore)(void *wifi_int_mux, uint32_t tmp);
|
||||
void (*_task_yield_from_isr)(void);
|
||||
void *(*_semphr_create)(uint32_t max, uint32_t init);
|
||||
void (*_semphr_delete)(void *semphr);
|
||||
int32_t (*_semphr_take)(void *semphr, uint32_t block_time_tick);
|
||||
int32_t (*_semphr_give)(void *semphr);
|
||||
void *(*_mutex_create)(void);
|
||||
void *(*_recursive_mutex_create)(void);
|
||||
void (*_mutex_delete)(void *mutex);
|
||||
int32_t (*_mutex_lock)(void *mutex);
|
||||
int32_t (*_mutex_unlock)(void *mutex);
|
||||
void *(* _queue_create)(uint32_t queue_len, uint32_t item_size);
|
||||
void (* _queue_delete)(void *queue);
|
||||
int32_t (* _queue_send)(void *queue, void *item, uint32_t block_time_tick);
|
||||
int32_t (* _queue_send_from_isr)(void *queue, void *item, void *hptw);
|
||||
int32_t (* _queue_send_to_back)(void *queue, void *item, uint32_t block_time_tick);
|
||||
int32_t (* _queue_send_to_front)(void *queue, void *item, uint32_t block_time_tick);
|
||||
int32_t (* _queue_recv)(void *queue, void *item, uint32_t block_time_tick);
|
||||
uint32_t (* _queue_msg_waiting)(void *queue);
|
||||
void *(* _event_group_create)(void);
|
||||
void (* _event_group_delete)(void *event);
|
||||
uint32_t (* _event_group_set_bits)(void *event, uint32_t bits);
|
||||
uint32_t (* _event_group_clear_bits)(void *event, uint32_t bits);
|
||||
uint32_t (* _event_group_wait_bits)(void *event, uint32_t bits_to_wait_for, int32_t clear_on_exit, int32_t wait_for_all_bits, uint32_t block_time_tick);
|
||||
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);
|
||||
int32_t (* _task_create)(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle);
|
||||
void (* _task_delete)(void *task_handle);
|
||||
void (* _task_delay)(uint32_t tick);
|
||||
int32_t (* _task_ms_to_tick)(uint32_t ms);
|
||||
void *(* _task_get_current_task)(void);
|
||||
int32_t (* _task_get_max_priority)(void);
|
||||
void *(* _malloc)(uint32_t size);
|
||||
void (* _free)(void *p);
|
||||
uint32_t (* _get_free_heap_size)(void);
|
||||
uint32_t (* _rand)(void);
|
||||
void (* _dport_access_stall_other_cpu_start_wrap)(void);
|
||||
void (* _dport_access_stall_other_cpu_end_wrap)(void);
|
||||
int32_t (* _phy_rf_deinit)(uint32_t module);
|
||||
void (* _phy_load_cal_and_init)(uint32_t module);
|
||||
int32_t (* _read_mac)(uint8_t* mac, uint32_t type);
|
||||
void (* _timer_arm)(void *timer, uint32_t tmout, bool repeat);
|
||||
void (* _timer_disarm)(void *timer);
|
||||
void (* _timer_done)(void *ptimer);
|
||||
void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg);
|
||||
void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat);
|
||||
void (* _periph_module_enable)(uint32_t periph);
|
||||
void (* _periph_module_disable)(uint32_t periph);
|
||||
int64_t (* _esp_timer_get_time)(void);
|
||||
int32_t (* _nvs_set_i8)(uint32_t handle, const char* key, int8_t value);
|
||||
int32_t (* _nvs_get_i8)(uint32_t handle, const char* key, int8_t* out_value);
|
||||
int32_t (* _nvs_set_u8)(uint32_t handle, const char* key, uint8_t value);
|
||||
int32_t (* _nvs_get_u8)(uint32_t handle, const char* key, uint8_t* out_value);
|
||||
int32_t (* _nvs_set_u16)(uint32_t handle, const char* key, uint16_t value);
|
||||
int32_t (* _nvs_get_u16)(uint32_t handle, const char* key, uint16_t* out_value);
|
||||
int32_t (* _nvs_open)(const char* name, uint32_t open_mode, uint32_t *out_handle);
|
||||
void (* _nvs_close)(uint32_t handle);
|
||||
int32_t (* _nvs_commit)(uint32_t handle);
|
||||
int32_t (* _nvs_set_blob)(uint32_t handle, const char* key, const void* value, size_t length);
|
||||
int32_t (* _nvs_get_blob)(uint32_t handle, const char* key, void* out_value, size_t* length);
|
||||
int32_t (* _nvs_erase_key)(uint32_t handle, const char* key);
|
||||
int32_t (* _get_random)(uint8_t *buf, size_t len);
|
||||
int32_t (* _get_time)(void *t);
|
||||
unsigned long (* _random)(void);
|
||||
void (* _log_write)(uint32_t level, const char* tag, const char* format, ...);
|
||||
uint32_t (* _log_timestamp)(void);
|
||||
void * (* _malloc_internal)(size_t size);
|
||||
void * (* _realloc_internal)(void *ptr, size_t size);
|
||||
void * (* _calloc_internal)(size_t n, size_t size);
|
||||
void * (* _zalloc_internal)(size_t size);
|
||||
void * (* _wifi_malloc)(size_t size);
|
||||
void * (* _wifi_realloc)(void *ptr, size_t size);
|
||||
void * (* _wifi_calloc)(size_t n, size_t size);
|
||||
void * (* _wifi_zalloc)(size_t size);
|
||||
void * (* _wifi_create_queue)(int32_t queue_len, int32_t item_size);
|
||||
void (* _wifi_delete_queue)(void * queue);
|
||||
int32_t (* _modem_sleep_enter)(uint32_t module);
|
||||
int32_t (* _modem_sleep_exit)(uint32_t module);
|
||||
int32_t (* _modem_sleep_register)(uint32_t module);
|
||||
int32_t (* _modem_sleep_deregister)(uint32_t module);
|
||||
void (* _sc_ack_send)(void *param);
|
||||
void (* _sc_ack_send_stop)(void);
|
||||
uint32_t (* _coex_status_get)(void);
|
||||
int32_t (* _coex_wifi_request)(uint32_t event, uint32_t latency, uint32_t duration);
|
||||
int32_t (* _coex_wifi_release)(uint32_t event);
|
||||
int32_t _magic;
|
||||
} wifi_osi_funcs_t;
|
||||
|
||||
extern wifi_osi_funcs_t g_wifi_osi_funcs;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ESP_WIFI_OS_ADAPTER_H_ */
|
||||
@@ -1,499 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#ifndef __ESP_WIFI_TYPES_H__
|
||||
#define __ESP_WIFI_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "sys/queue.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
WIFI_MODE_NULL = 0, /**< null mode */
|
||||
WIFI_MODE_STA, /**< WiFi station mode */
|
||||
WIFI_MODE_AP, /**< WiFi soft-AP mode */
|
||||
WIFI_MODE_APSTA, /**< WiFi station + soft-AP mode */
|
||||
WIFI_MODE_MAX
|
||||
} wifi_mode_t;
|
||||
|
||||
typedef esp_interface_t wifi_interface_t;
|
||||
|
||||
#define WIFI_IF_STA ESP_IF_WIFI_STA
|
||||
#define WIFI_IF_AP ESP_IF_WIFI_AP
|
||||
|
||||
typedef enum {
|
||||
WIFI_COUNTRY_POLICY_AUTO, /**< Country policy is auto, use the country info of AP to which the station is connected */
|
||||
WIFI_COUNTRY_POLICY_MANUAL, /**< Country policy is manual, always use the configured country info */
|
||||
} wifi_country_policy_t;
|
||||
|
||||
/** @brief Structure describing WiFi country-based regional restrictions. */
|
||||
typedef struct {
|
||||
char cc[3]; /**< country code string */
|
||||
uint8_t schan; /**< start channel */
|
||||
uint8_t nchan; /**< total channel number */
|
||||
int8_t max_tx_power; /**< maximum tx power */
|
||||
wifi_country_policy_t policy; /**< country policy */
|
||||
} wifi_country_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_AUTH_OPEN = 0, /**< authenticate mode : open */
|
||||
WIFI_AUTH_WEP, /**< authenticate mode : WEP */
|
||||
WIFI_AUTH_WPA_PSK, /**< authenticate mode : WPA_PSK */
|
||||
WIFI_AUTH_WPA2_PSK, /**< authenticate mode : WPA2_PSK */
|
||||
WIFI_AUTH_WPA_WPA2_PSK, /**< authenticate mode : WPA_WPA2_PSK */
|
||||
WIFI_AUTH_WPA2_ENTERPRISE, /**< authenticate mode : WPA2_ENTERPRISE */
|
||||
WIFI_AUTH_MAX
|
||||
} wifi_auth_mode_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_REASON_UNSPECIFIED = 1,
|
||||
WIFI_REASON_AUTH_EXPIRE = 2,
|
||||
WIFI_REASON_AUTH_LEAVE = 3,
|
||||
WIFI_REASON_ASSOC_EXPIRE = 4,
|
||||
WIFI_REASON_ASSOC_TOOMANY = 5,
|
||||
WIFI_REASON_NOT_AUTHED = 6,
|
||||
WIFI_REASON_NOT_ASSOCED = 7,
|
||||
WIFI_REASON_ASSOC_LEAVE = 8,
|
||||
WIFI_REASON_ASSOC_NOT_AUTHED = 9,
|
||||
WIFI_REASON_DISASSOC_PWRCAP_BAD = 10,
|
||||
WIFI_REASON_DISASSOC_SUPCHAN_BAD = 11,
|
||||
WIFI_REASON_IE_INVALID = 13,
|
||||
WIFI_REASON_MIC_FAILURE = 14,
|
||||
WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
|
||||
WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,
|
||||
WIFI_REASON_IE_IN_4WAY_DIFFERS = 17,
|
||||
WIFI_REASON_GROUP_CIPHER_INVALID = 18,
|
||||
WIFI_REASON_PAIRWISE_CIPHER_INVALID = 19,
|
||||
WIFI_REASON_AKMP_INVALID = 20,
|
||||
WIFI_REASON_UNSUPP_RSN_IE_VERSION = 21,
|
||||
WIFI_REASON_INVALID_RSN_IE_CAP = 22,
|
||||
WIFI_REASON_802_1X_AUTH_FAILED = 23,
|
||||
WIFI_REASON_CIPHER_SUITE_REJECTED = 24,
|
||||
|
||||
WIFI_REASON_BEACON_TIMEOUT = 200,
|
||||
WIFI_REASON_NO_AP_FOUND = 201,
|
||||
WIFI_REASON_AUTH_FAIL = 202,
|
||||
WIFI_REASON_ASSOC_FAIL = 203,
|
||||
WIFI_REASON_HANDSHAKE_TIMEOUT = 204,
|
||||
WIFI_REASON_CONNECTION_FAIL = 205,
|
||||
} wifi_err_reason_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_SECOND_CHAN_NONE = 0, /**< the channel width is HT20 */
|
||||
WIFI_SECOND_CHAN_ABOVE, /**< the channel width is HT40 and the secondary channel is above the primary channel */
|
||||
WIFI_SECOND_CHAN_BELOW, /**< the channel width is HT40 and the secondary channel is below the primary channel */
|
||||
} wifi_second_chan_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_SCAN_TYPE_ACTIVE = 0, /**< active scan */
|
||||
WIFI_SCAN_TYPE_PASSIVE, /**< passive scan */
|
||||
} wifi_scan_type_t;
|
||||
|
||||
/** @brief Range of active scan times per channel */
|
||||
typedef struct {
|
||||
uint32_t min; /**< minimum active scan time per channel, units: millisecond */
|
||||
uint32_t max; /**< maximum active scan time per channel, units: millisecond, values above 1500ms may
|
||||
cause station to disconnect from AP and are not recommended. */
|
||||
} wifi_active_scan_time_t;
|
||||
|
||||
/** @brief Aggregate of active & passive scan time per channel */
|
||||
typedef union {
|
||||
wifi_active_scan_time_t active; /**< active scan time per channel, units: millisecond. */
|
||||
uint32_t passive; /**< passive scan time per channel, units: millisecond, values above 1500ms may
|
||||
cause station to disconnect from AP and are not recommended. */
|
||||
} wifi_scan_time_t;
|
||||
|
||||
/** @brief Parameters for an SSID scan. */
|
||||
typedef struct {
|
||||
uint8_t *ssid; /**< SSID of AP */
|
||||
uint8_t *bssid; /**< MAC address of AP */
|
||||
uint8_t channel; /**< channel, scan the specific channel */
|
||||
bool show_hidden; /**< enable to scan AP whose SSID is hidden */
|
||||
wifi_scan_type_t scan_type; /**< scan type, active or passive */
|
||||
wifi_scan_time_t scan_time; /**< scan time per channel */
|
||||
} wifi_scan_config_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_CIPHER_TYPE_NONE = 0, /**< the cipher type is none */
|
||||
WIFI_CIPHER_TYPE_WEP40, /**< the cipher type is WEP40 */
|
||||
WIFI_CIPHER_TYPE_WEP104, /**< the cipher type is WEP104 */
|
||||
WIFI_CIPHER_TYPE_TKIP, /**< the cipher type is TKIP */
|
||||
WIFI_CIPHER_TYPE_CCMP, /**< the cipher type is CCMP */
|
||||
WIFI_CIPHER_TYPE_TKIP_CCMP, /**< the cipher type is TKIP and CCMP */
|
||||
WIFI_CIPHER_TYPE_UNKNOWN, /**< the cipher type is unknown */
|
||||
} wifi_cipher_type_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi antenna
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_ANT_ANT0, /**< WiFi antenna 0 */
|
||||
WIFI_ANT_ANT1, /**< WiFi antenna 1 */
|
||||
WIFI_ANT_MAX, /**< Invalid WiFi antenna */
|
||||
} wifi_ant_t;
|
||||
|
||||
/** @brief Description of a WiFi AP */
|
||||
typedef struct {
|
||||
uint8_t bssid[6]; /**< MAC address of AP */
|
||||
uint8_t ssid[33]; /**< SSID of AP */
|
||||
uint8_t primary; /**< channel of AP */
|
||||
wifi_second_chan_t second; /**< secondary channel of AP */
|
||||
int8_t rssi; /**< signal strength of AP */
|
||||
wifi_auth_mode_t authmode; /**< authmode of AP */
|
||||
wifi_cipher_type_t pairwise_cipher; /**< pairwise cipher of AP */
|
||||
wifi_cipher_type_t group_cipher; /**< group cipher of AP */
|
||||
wifi_ant_t ant; /**< antenna used to receive beacon from AP */
|
||||
uint32_t phy_11b:1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
|
||||
uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
|
||||
uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
|
||||
uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */
|
||||
uint32_t wps:1; /**< bit: 4 flag to identify if WPS is supported or not */
|
||||
uint32_t reserved:27; /**< bit: 5..31 reserved */
|
||||
wifi_country_t country; /**< country information of AP */
|
||||
} wifi_ap_record_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_FAST_SCAN = 0, /**< Do fast scan, scan will end after find SSID match AP */
|
||||
WIFI_ALL_CHANNEL_SCAN, /**< All channel scan, scan will end after scan all the channel */
|
||||
}wifi_scan_method_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_CONNECT_AP_BY_SIGNAL = 0, /**< Sort match AP in scan list by RSSI */
|
||||
WIFI_CONNECT_AP_BY_SECURITY, /**< Sort match AP in scan list by security mode */
|
||||
}wifi_sort_method_t;
|
||||
|
||||
/** @brief Structure describing parameters for a WiFi fast scan */
|
||||
typedef struct {
|
||||
int8_t rssi; /**< The minimum rssi to accept in the fast scan mode */
|
||||
wifi_auth_mode_t authmode; /**< The weakest authmode to accept in the fast scan mode */
|
||||
}wifi_fast_scan_threshold_t;
|
||||
|
||||
typedef wifi_fast_scan_threshold_t wifi_scan_threshold_t; /**< wifi_fast_scan_threshold_t only used in fast scan mode once, now it enabled in all channel scan, the wifi_fast_scan_threshold_t will be remove in version 4.0 */
|
||||
|
||||
typedef enum {
|
||||
WIFI_PS_NONE, /**< No power save */
|
||||
WIFI_PS_MIN_MODEM, /**< Minimum modem power saving. In this mode, station wakes up to receive beacon every DTIM period */
|
||||
WIFI_PS_MAX_MODEM, /**< Maximum modem power saving. In this mode, interval to receive beacons is determined by the listen_interval parameter in wifi_sta_config_t */
|
||||
} wifi_ps_type_t;
|
||||
|
||||
#define WIFI_PS_MODEM WIFI_PS_MIN_MODEM /**< @deprecated Use WIFI_PS_MIN_MODEM or WIFI_PS_MAX_MODEM instead */
|
||||
|
||||
#define WIFI_PROTOCOL_11B 1
|
||||
#define WIFI_PROTOCOL_11G 2
|
||||
#define WIFI_PROTOCOL_11N 4
|
||||
#define WIFI_PROTOCOL_LR 8
|
||||
|
||||
typedef enum {
|
||||
WIFI_BW_HT20 = 1, /* Bandwidth is HT20 */
|
||||
WIFI_BW_HT40, /* Bandwidth is HT40 */
|
||||
} wifi_bandwidth_t;
|
||||
|
||||
/** @brief Soft-AP configuration settings for the ESP32 */
|
||||
typedef struct {
|
||||
uint8_t ssid[32]; /**< SSID of ESP32 soft-AP. If ssid_len field is 0, this must be a Null terminated string. Otherwise, length is set according to ssid_len. */
|
||||
uint8_t password[64]; /**< Password of ESP32 soft-AP. Null terminated string. */
|
||||
uint8_t ssid_len; /**< Optional length of SSID field. */
|
||||
uint8_t channel; /**< Channel of ESP32 soft-AP */
|
||||
wifi_auth_mode_t authmode; /**< Auth mode of ESP32 soft-AP. Do not support AUTH_WEP in soft-AP mode */
|
||||
uint8_t ssid_hidden; /**< Broadcast SSID or not, default 0, broadcast the SSID */
|
||||
uint8_t max_connection; /**< Max number of stations allowed to connect in, default 4, max 4 */
|
||||
uint16_t beacon_interval; /**< Beacon interval, 100 ~ 60000 ms, default 100 ms */
|
||||
} wifi_ap_config_t;
|
||||
|
||||
/** @brief STA configuration settings for the ESP32 */
|
||||
typedef struct {
|
||||
uint8_t ssid[32]; /**< SSID of target AP. Null terminated string. */
|
||||
uint8_t password[64]; /**< Password of target AP. Null terminated string.*/
|
||||
wifi_scan_method_t scan_method; /**< do all channel scan or fast scan */
|
||||
bool bssid_set; /**< whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.*/
|
||||
uint8_t bssid[6]; /**< MAC address of target AP*/
|
||||
uint8_t channel; /**< channel of target AP. Set to 1~13 to scan starting from the specified channel before connecting to AP. If the channel of AP is unknown, set it to 0.*/
|
||||
uint16_t listen_interval; /**< Listen interval for ESP32 station to receive beacon when WIFI_PS_MAX_MODEM is set. Units: AP beacon intervals. Defaults to 3 if set to 0. */
|
||||
wifi_sort_method_t sort_method; /**< sort the connect AP in the list by rssi or security mode */
|
||||
wifi_scan_threshold_t threshold; /**< When scan_method is set, only APs which have an auth mode that is more secure than the selected auth mode and a signal stronger than the minimum RSSI will be used. */
|
||||
} wifi_sta_config_t;
|
||||
|
||||
/** @brief Configuration data for ESP32 AP or STA.
|
||||
*
|
||||
* The usage of this union (for ap or sta configuration) is determined by the accompanying
|
||||
* interface argument passed to esp_wifi_set_config() or esp_wifi_get_config()
|
||||
*
|
||||
*/
|
||||
typedef union {
|
||||
wifi_ap_config_t ap; /**< configuration of AP */
|
||||
wifi_sta_config_t sta; /**< configuration of STA */
|
||||
} wifi_config_t;
|
||||
|
||||
/** @brief Description of STA associated with AP */
|
||||
typedef struct {
|
||||
uint8_t mac[6]; /**< mac address */
|
||||
int8_t rssi; /**< current average rssi of sta connected */
|
||||
uint32_t phy_11b:1; /**< bit: 0 flag to identify if 11b mode is enabled or not */
|
||||
uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */
|
||||
uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */
|
||||
uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */
|
||||
uint32_t reserved:28; /**< bit: 4..31 reserved */
|
||||
} wifi_sta_info_t;
|
||||
|
||||
#define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32 soft-AP */
|
||||
|
||||
/** @brief List of stations associated with the ESP32 Soft-AP */
|
||||
typedef struct {
|
||||
wifi_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< station list */
|
||||
int num; /**< number of stations in the list (other entries are invalid) */
|
||||
} wifi_sta_list_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_STORAGE_FLASH, /**< all configuration will store in both memory and flash */
|
||||
WIFI_STORAGE_RAM, /**< all configuration will only store in the memory */
|
||||
} wifi_storage_t;
|
||||
|
||||
/**
|
||||
* @brief Vendor Information Element type
|
||||
*
|
||||
* Determines the frame type that the IE will be associated with.
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_VND_IE_TYPE_BEACON,
|
||||
WIFI_VND_IE_TYPE_PROBE_REQ,
|
||||
WIFI_VND_IE_TYPE_PROBE_RESP,
|
||||
WIFI_VND_IE_TYPE_ASSOC_REQ,
|
||||
WIFI_VND_IE_TYPE_ASSOC_RESP,
|
||||
} wifi_vendor_ie_type_t;
|
||||
|
||||
/**
|
||||
* @brief Vendor Information Element index
|
||||
*
|
||||
* Each IE type can have up to two associated vendor ID elements.
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_VND_IE_ID_0,
|
||||
WIFI_VND_IE_ID_1,
|
||||
} wifi_vendor_ie_id_t;
|
||||
|
||||
#define WIFI_VENDOR_IE_ELEMENT_ID 0xDD
|
||||
|
||||
/**
|
||||
* @brief Vendor Information Element header
|
||||
*
|
||||
* The first bytes of the Information Element will match this header. Payload follows.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t element_id; /**< Should be set to WIFI_VENDOR_IE_ELEMENT_ID (0xDD) */
|
||||
uint8_t length; /**< Length of all bytes in the element data following this field. Minimum 4. */
|
||||
uint8_t vendor_oui[3]; /**< Vendor identifier (OUI). */
|
||||
uint8_t vendor_oui_type; /**< Vendor-specific OUI type. */
|
||||
uint8_t payload[0]; /**< Payload. Length is equal to value in 'length' field, minus 4. */
|
||||
} vendor_ie_data_t;
|
||||
|
||||
/** @brief Received packet radio metadata header, this is the common header at the beginning of all promiscuous mode RX callback buffers */
|
||||
typedef struct {
|
||||
signed rssi:8; /**< Received Signal Strength Indicator(RSSI) of packet. unit: dBm */
|
||||
unsigned rate:5; /**< PHY rate encoding of the packet. Only valid for non HT(11bg) packet */
|
||||
unsigned :1; /**< reserve */
|
||||
unsigned sig_mode:2; /**< 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */
|
||||
unsigned :16; /**< reserve */
|
||||
unsigned mcs:7; /**< Modulation Coding Scheme. If is HT(11n) packet, shows the modulation, range from 0 to 76(MSC0 ~ MCS76) */
|
||||
unsigned cwb:1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */
|
||||
unsigned :16; /**< reserve */
|
||||
unsigned smoothing:1; /**< reserve */
|
||||
unsigned not_sounding:1; /**< reserve */
|
||||
unsigned :1; /**< reserve */
|
||||
unsigned aggregation:1; /**< Aggregation. 0: MPDU packet; 1: AMPDU packet */
|
||||
unsigned stbc:2; /**< Space Time Block Code(STBC). 0: non STBC packet; 1: STBC packet */
|
||||
unsigned fec_coding:1; /**< Flag is set for 11n packets which are LDPC */
|
||||
unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */
|
||||
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: 0.25dBm*/
|
||||
unsigned ampdu_cnt:8; /**< ampdu cnt */
|
||||
unsigned channel:4; /**< primary channel on which this packet is received */
|
||||
unsigned secondary_channel:4; /**< secondary channel on which this packet is received. 0: none; 1: above; 2: below */
|
||||
unsigned :8; /**< reserve */
|
||||
unsigned timestamp:32; /**< timestamp. The local time when this packet is received. It is precise only if modem sleep or light sleep is not enabled. unit: microsecond */
|
||||
unsigned :32; /**< reserve */
|
||||
unsigned :31; /**< reserve */
|
||||
unsigned ant:1; /**< antenna number from which this packet is received. 0: WiFi antenna 0; 1: WiFi antenna 1 */
|
||||
unsigned sig_len:12; /**< length of packet including Frame Check Sequence(FCS) */
|
||||
unsigned :12; /**< reserve */
|
||||
unsigned rx_state:8; /**< state of the packet. 0: no error; others: error numbers which are not public */
|
||||
} wifi_pkt_rx_ctrl_t;
|
||||
|
||||
/** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback.
|
||||
*/
|
||||
typedef struct {
|
||||
wifi_pkt_rx_ctrl_t rx_ctrl; /**< metadata header */
|
||||
uint8_t payload[0]; /**< Data or management payload. Length of payload is described by rx_ctrl.sig_len. Type of content determined by packet type argument of callback. */
|
||||
} wifi_promiscuous_pkt_t;
|
||||
|
||||
/**
|
||||
* @brief Promiscuous frame type
|
||||
*
|
||||
* Passed to promiscuous mode RX callback to indicate the type of parameter in the buffer.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_PKT_MGMT, /**< Management frame, indicates 'buf' argument is wifi_promiscuous_pkt_t */
|
||||
WIFI_PKT_CTRL, /**< Control frame, indicates 'buf' argument is wifi_promiscuous_pkt_t */
|
||||
WIFI_PKT_DATA, /**< Data frame, indiciates 'buf' argument is wifi_promiscuous_pkt_t */
|
||||
WIFI_PKT_MISC, /**< Other type, such as MIMO etc. 'buf' argument is wifi_promiscuous_pkt_t but the payload is zero length. */
|
||||
} wifi_promiscuous_pkt_type_t;
|
||||
|
||||
|
||||
#define WIFI_PROMIS_FILTER_MASK_ALL (0xFFFFFFFF) /**< filter all packets */
|
||||
#define WIFI_PROMIS_FILTER_MASK_MGMT (1) /**< filter the packets with type of WIFI_PKT_MGMT */
|
||||
#define WIFI_PROMIS_FILTER_MASK_CTRL (1<<1) /**< filter the packets with type of WIFI_PKT_CTRL */
|
||||
#define WIFI_PROMIS_FILTER_MASK_DATA (1<<2) /**< filter the packets with type of WIFI_PKT_DATA */
|
||||
#define WIFI_PROMIS_FILTER_MASK_MISC (1<<3) /**< filter the packets with type of WIFI_PKT_MISC */
|
||||
#define WIFI_PROMIS_FILTER_MASK_DATA_MPDU (1<<4) /**< filter the MPDU which is a kind of WIFI_PKT_DATA */
|
||||
#define WIFI_PROMIS_FILTER_MASK_DATA_AMPDU (1<<5) /**< filter the AMPDU which is a kind of WIFI_PKT_DATA */
|
||||
|
||||
#define WIFI_PROMIS_CTRL_FILTER_MASK_ALL (0xFF800000) /**< filter all control packets */
|
||||
#define WIFI_PROMIS_CTRL_FILTER_MASK_WRAPPER (1<<23) /**< filter the control packets with subtype of Control Wrapper */
|
||||
#define WIFI_PROMIS_CTRL_FILTER_MASK_BAR (1<<24) /**< filter the control packets with subtype of Block Ack Request */
|
||||
#define WIFI_PROMIS_CTRL_FILTER_MASK_BA (1<<25) /**< filter the control packets with subtype of Block Ack */
|
||||
#define WIFI_PROMIS_CTRL_FILTER_MASK_PSPOLL (1<<26) /**< filter the control packets with subtype of PS-Poll */
|
||||
#define WIFI_PROMIS_CTRL_FILTER_MASK_RTS (1<<27) /**< filter the control packets with subtype of RTS */
|
||||
#define WIFI_PROMIS_CTRL_FILTER_MASK_CTS (1<<28) /**< filter the control packets with subtype of CTS */
|
||||
#define WIFI_PROMIS_CTRL_FILTER_MASK_ACK (1<<29) /**< filter the control packets with subtype of ACK */
|
||||
#define WIFI_PROMIS_CTRL_FILTER_MASK_CFEND (1<<30) /**< filter the control packets with subtype of CF-END */
|
||||
#define WIFI_PROMIS_CTRL_FILTER_MASK_CFENDACK (1<<31) /**< filter the control packets with subtype of CF-END+CF-ACK */
|
||||
|
||||
/** @brief Mask for filtering different packet types in promiscuous mode. */
|
||||
typedef struct {
|
||||
uint32_t filter_mask; /**< OR of one or more filter values WIFI_PROMIS_FILTER_* */
|
||||
} wifi_promiscuous_filter_t;
|
||||
|
||||
#define WIFI_EVENT_MASK_ALL (0xFFFFFFFF) /**< mask all WiFi events */
|
||||
#define WIFI_EVENT_MASK_NONE (0) /**< mask none of the WiFi events */
|
||||
#define WIFI_EVENT_MASK_AP_PROBEREQRECVED (BIT(0)) /**< mask SYSTEM_EVENT_AP_PROBEREQRECVED event */
|
||||
|
||||
/**
|
||||
* @brief Channel state information(CSI) configuration type
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
bool lltf_en; /**< enable to receive legacy long training field(lltf) data. Default enabled */
|
||||
bool htltf_en; /**< enable to receive HT long training field(htltf) data. Default enabled */
|
||||
bool stbc_htltf2_en; /**< enable to receive space time block code HT long training field(stbc-htltf2) data. Default enabled */
|
||||
bool ltf_merge_en; /**< enable to generate htlft data by averaging lltf and ht_ltf data when receiving HT packet. Otherwise, use ht_ltf data directly. Default enabled */
|
||||
bool channel_filter_en; /**< enable to turn on channel filter to smooth adjacent sub-carrier. Disable it to keep independence of adjacent sub-carrier. Default enabled */
|
||||
bool manu_scale; /**< manually scale the CSI data by left shifting or automatically scale the CSI data. If set true, please set the shift bits. false: automatically. true: manually. Default false */
|
||||
uint8_t shift; /**< manually left shift bits of the scale of the CSI data. The range of the left shift bits is 0~15 */
|
||||
} wifi_csi_config_t;
|
||||
|
||||
/**
|
||||
* @brief CSI data type
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
wifi_pkt_rx_ctrl_t rx_ctrl;/**< received packet radio metadata header of the CSI data */
|
||||
uint8_t mac[6]; /**< source MAC address of the CSI data */
|
||||
bool first_word_invalid; /**< first four bytes of the CSI data is invalid or not */
|
||||
int8_t *buf; /**< buffer of CSI data */
|
||||
uint16_t len; /**< length of CSI data */
|
||||
} wifi_csi_info_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi GPIO configuration for antenna selection
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t gpio_select: 1, /**< Whether this GPIO is connected to external antenna switch */
|
||||
gpio_num: 7; /**< The GPIO number that connects to external antenna switch */
|
||||
} wifi_ant_gpio_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi GPIOs configuration for antenna selection
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
wifi_ant_gpio_t gpio_cfg[4]; /**< The configurations of GPIOs that connect to external antenna switch */
|
||||
} wifi_ant_gpio_config_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi antenna mode
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_ANT_MODE_ANT0, /**< Enable WiFi antenna 0 only */
|
||||
WIFI_ANT_MODE_ANT1, /**< Enable WiFi antenna 1 only */
|
||||
WIFI_ANT_MODE_AUTO, /**< Enable WiFi antenna 0 and 1, automatically select an antenna */
|
||||
WIFI_ANT_MODE_MAX, /**< Invalid WiFi enabled antenna */
|
||||
} wifi_ant_mode_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi antenna configuration
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
wifi_ant_mode_t rx_ant_mode; /**< WiFi antenna mode for receiving */
|
||||
wifi_ant_t rx_ant_default; /**< Default antenna mode for receiving, it's ignored if rx_ant_mode is not WIFI_ANT_MODE_AUTO */
|
||||
wifi_ant_mode_t tx_ant_mode; /**< WiFi antenna mode for transmission, it can be set to WIFI_ANT_MODE_AUTO only if rx_ant_mode is set to WIFI_ANT_MODE_AUTO */
|
||||
uint8_t enabled_ant0: 4, /**< Index (in antenna GPIO configuration) of enabled WIFI_ANT_MODE_ANT0 */
|
||||
enabled_ant1: 4; /**< Index (in antenna GPIO configuration) of enabled WIFI_ANT_MODE_ANT1 */
|
||||
} wifi_ant_config_t;
|
||||
|
||||
/**
|
||||
* @brief WiFi PHY rate encodings
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
WIFI_PHY_RATE_1M_L = 0x00, /**< 1 Mbps with long preamble */
|
||||
WIFI_PHY_RATE_2M_L = 0x01, /**< 2 Mbps with long preamble */
|
||||
WIFI_PHY_RATE_5M_L = 0x02, /**< 5.5 Mbps with long preamble */
|
||||
WIFI_PHY_RATE_11M_L = 0x03, /**< 11 Mbps with long preamble */
|
||||
WIFI_PHY_RATE_2M_S = 0x05, /**< 2 Mbps with short preamble */
|
||||
WIFI_PHY_RATE_5M_S = 0x06, /**< 5.5 Mbps with short preamble */
|
||||
WIFI_PHY_RATE_11M_S = 0x07, /**< 11 Mbps with short preamble */
|
||||
WIFI_PHY_RATE_48M = 0x08, /**< 48 Mbps */
|
||||
WIFI_PHY_RATE_24M = 0x09, /**< 24 Mbps */
|
||||
WIFI_PHY_RATE_12M = 0x0A, /**< 12 Mbps */
|
||||
WIFI_PHY_RATE_6M = 0x0B, /**< 6 Mbps */
|
||||
WIFI_PHY_RATE_54M = 0x0C, /**< 54 Mbps */
|
||||
WIFI_PHY_RATE_36M = 0x0D, /**< 36 Mbps */
|
||||
WIFI_PHY_RATE_18M = 0x0E, /**< 18 Mbps */
|
||||
WIFI_PHY_RATE_9M = 0x0F, /**< 9 Mbps */
|
||||
WIFI_PHY_RATE_MCS0_LGI = 0x10, /**< MCS0 with long GI, 6.5 Mbps for 20MHz, 13.5 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS1_LGI = 0x11, /**< MCS1 with long GI, 13 Mbps for 20MHz, 27 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS2_LGI = 0x12, /**< MCS2 with long GI, 19.5 Mbps for 20MHz, 40.5 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS3_LGI = 0x13, /**< MCS3 with long GI, 26 Mbps for 20MHz, 54 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS4_LGI = 0x14, /**< MCS4 with long GI, 39 Mbps for 20MHz, 81 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS5_LGI = 0x15, /**< MCS5 with long GI, 52 Mbps for 20MHz, 108 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS6_LGI = 0x16, /**< MCS6 with long GI, 58.5 Mbps for 20MHz, 121.5 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS7_LGI = 0x17, /**< MCS7 with long GI, 65 Mbps for 20MHz, 135 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS0_SGI = 0x18, /**< MCS0 with short GI, 7.2 Mbps for 20MHz, 15 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS1_SGI = 0x19, /**< MCS1 with short GI, 14.4 Mbps for 20MHz, 30 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS2_SGI = 0x1A, /**< MCS2 with short GI, 21.7 Mbps for 20MHz, 45 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS3_SGI = 0x1B, /**< MCS3 with short GI, 28.9 Mbps for 20MHz, 60 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS4_SGI = 0x1C, /**< MCS4 with short GI, 43.3 Mbps for 20MHz, 90 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS5_SGI = 0x1D, /**< MCS5 with short GI, 57.8 Mbps for 20MHz, 120 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS6_SGI = 0x1E, /**< MCS6 with short GI, 65 Mbps for 20MHz, 135 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_MCS7_SGI = 0x1F, /**< MCS7 with short GI, 72.2 Mbps for 20MHz, 150 Mbps for 40MHz */
|
||||
WIFI_PHY_RATE_LORA_250K = 0x29, /**< 250 Kbps */
|
||||
WIFI_PHY_RATE_LORA_500K = 0x2A, /**< 500 Kbps */
|
||||
WIFI_PHY_RATE_MAX,
|
||||
} wifi_phy_rate_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_WIFI_TYPES_H__ */
|
||||
@@ -1,208 +0,0 @@
|
||||
// Hardware crypto support Copyright 2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef ESP_WPA2_H
|
||||
#define ESP_WPA2_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const wpa2_crypto_funcs_t g_wifi_default_wpa2_crypto_funcs;
|
||||
|
||||
typedef struct {
|
||||
const wpa2_crypto_funcs_t *crypto_funcs;
|
||||
}esp_wpa2_config_t;
|
||||
|
||||
#define WPA2_CONFIG_INIT_DEFAULT() { \
|
||||
.crypto_funcs = &g_wifi_default_wpa2_crypto_funcs \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable wpa2 enterprise authentication.
|
||||
*
|
||||
* @attention 1. wpa2 enterprise authentication can only be used when ESP32 station is enabled.
|
||||
* @attention 2. wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed.
|
||||
* - ESP_ERR_NO_MEM: fail(internal memory malloc fail)
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_enable(const esp_wpa2_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Disable wpa2 enterprise authentication.
|
||||
*
|
||||
* @attention 1. wpa2 enterprise authentication can only be used when ESP32 station is enabled.
|
||||
* @attention 2. wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed.
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Set identity for PEAP/TTLS method.
|
||||
*
|
||||
* @attention The API only passes the parameter identity to the global pointer variable in wpa2 enterprise module.
|
||||
*
|
||||
* @param identity: point to address where stores the identity;
|
||||
* @param len: length of identity, limited to 1~127
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_INVALID_ARG: fail(len <= 0 or len >= 128)
|
||||
* - ESP_ERR_NO_MEM: fail(internal memory malloc fail)
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_identity(const unsigned char *identity, int len);
|
||||
|
||||
/**
|
||||
* @brief Clear identity for PEAP/TTLS method.
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_identity(void);
|
||||
|
||||
/**
|
||||
* @brief Set username for PEAP/TTLS method.
|
||||
*
|
||||
* @attention The API only passes the parameter username to the global pointer variable in wpa2 enterprise module.
|
||||
*
|
||||
* @param username: point to address where stores the username;
|
||||
* @param len: length of username, limited to 1~127
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_INVALID_ARG: fail(len <= 0 or len >= 128)
|
||||
* - ESP_ERR_NO_MEM: fail(internal memory malloc fail)
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_username(const unsigned char *username, int len);
|
||||
|
||||
/**
|
||||
* @brief Clear username for PEAP/TTLS method.
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_username(void);
|
||||
|
||||
/**
|
||||
* @brief Set password for PEAP/TTLS method..
|
||||
*
|
||||
* @attention The API only passes the parameter password to the global pointer variable in wpa2 enterprise module.
|
||||
*
|
||||
* @param password: point to address where stores the password;
|
||||
* @param len: length of password(len > 0)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_INVALID_ARG: fail(len <= 0)
|
||||
* - ESP_ERR_NO_MEM: fail(internal memory malloc fail)
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_password(const unsigned char *password, int len);
|
||||
|
||||
/**
|
||||
* @brief Clear password for PEAP/TTLS method..
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_password(void);
|
||||
|
||||
/**
|
||||
* @brief Set new password for MSCHAPv2 method..
|
||||
*
|
||||
* @attention 1. The API only passes the parameter password to the global pointer variable in wpa2 enterprise module.
|
||||
* @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.
|
||||
*
|
||||
* @param new_password: point to address where stores the password;
|
||||
* @param len: length of password
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_INVALID_ARG: fail(len <= 0)
|
||||
* - ESP_ERR_NO_MEM: fail(internal memory malloc fail)
|
||||
*/
|
||||
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_new_password(const unsigned char *new_password, int len);
|
||||
|
||||
/**
|
||||
* @brief Clear new password for MSCHAPv2 method..
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_new_password(void);
|
||||
|
||||
/**
|
||||
* @brief Set CA certificate for PEAP/TTLS method.
|
||||
*
|
||||
* @attention 1. The API only passes the parameter ca_cert to the global pointer variable in wpa2 enterprise module.
|
||||
* @attention 2. The ca_cert should be zero terminated.
|
||||
*
|
||||
* @param ca_cert: point to address where stores the CA certificate;
|
||||
* @param ca_cert_len: length of ca_cert
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_ca_cert(const unsigned char *ca_cert, int ca_cert_len);
|
||||
|
||||
/**
|
||||
* @brief Clear CA certificate for PEAP/TTLS method.
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_ca_cert(void);
|
||||
|
||||
/**
|
||||
* @brief Set client certificate and key.
|
||||
*
|
||||
* @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.
|
||||
* @attention 2. The client_cert, private_key and private_key_passwd should be zero terminated.
|
||||
*
|
||||
* @param client_cert: point to address where stores the client certificate;
|
||||
* @param client_cert_len: length of client certificate;
|
||||
* @param private_key: point to address where stores the private key;
|
||||
* @param private_key_len: length of private key, limited to 1~2048;
|
||||
* @param private_key_password: point to address where stores the private key password;
|
||||
* @param private_key_password_len: length of private key password;
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Clear client certificate and key.
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_cert_key(void);
|
||||
|
||||
/**
|
||||
* @brief Set wpa2 enterprise certs time check(disable or not).
|
||||
*
|
||||
* @param true: disable wpa2 enterprise certs time check
|
||||
* @param false: enable wpa2 enterprise certs time check
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_disable_time_check(bool disable);
|
||||
|
||||
/**
|
||||
* @brief Get wpa2 enterprise certs time check(disable or not).
|
||||
*
|
||||
* @param disable: store disable value
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_get_disable_time_check(bool *disable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,144 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_WPS_H__
|
||||
#define __ESP_WPS_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup WiFi_APIs WiFi Related APIs
|
||||
* @brief WiFi APIs
|
||||
*/
|
||||
|
||||
/** @addtogroup WiFi_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \defgroup WPS_APIs WPS APIs
|
||||
* @brief ESP32 WPS APIs
|
||||
*
|
||||
* WPS can only be used when ESP32 station is enabled.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup WPS_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define ESP_ERR_WIFI_REGISTRAR (ESP_ERR_WIFI_BASE + 51) /*!< WPS registrar is not supported */
|
||||
#define ESP_ERR_WIFI_WPS_TYPE (ESP_ERR_WIFI_BASE + 52) /*!< WPS type error */
|
||||
#define ESP_ERR_WIFI_WPS_SM (ESP_ERR_WIFI_BASE + 53) /*!< WPS state machine is not initialized */
|
||||
|
||||
typedef enum wps_type {
|
||||
WPS_TYPE_DISABLE = 0,
|
||||
WPS_TYPE_PBC,
|
||||
WPS_TYPE_PIN,
|
||||
WPS_TYPE_MAX,
|
||||
} wps_type_t;
|
||||
|
||||
extern const wps_crypto_funcs_t g_wifi_default_wps_crypto_funcs;
|
||||
|
||||
#define WPS_MAX_MANUFACTURER_LEN 65
|
||||
#define WPS_MAX_MODEL_NUMBER_LEN 33
|
||||
#define WPS_MAX_MODEL_NAME_LEN 33
|
||||
#define WPS_MAX_DEVICE_NAME_LEN 33
|
||||
|
||||
typedef struct {
|
||||
char manufacturer[WPS_MAX_MANUFACTURER_LEN]; /*!< Manufacturer, null-terminated string. The default manufcturer is used if the string is empty */
|
||||
char model_number[WPS_MAX_MODEL_NUMBER_LEN]; /*!< Model number, null-terminated string. The default model number is used if the string is empty */
|
||||
char model_name[WPS_MAX_MODEL_NAME_LEN]; /*!< Model name, null-terminated string. The default model name is used if the string is empty */
|
||||
char device_name[WPS_MAX_DEVICE_NAME_LEN]; /*!< Device name, null-terminated string. The default device name is used if the string is empty */
|
||||
} wps_factory_information_t;
|
||||
|
||||
typedef struct {
|
||||
wps_type_t wps_type;
|
||||
const wps_crypto_funcs_t *crypto_funcs;
|
||||
wps_factory_information_t factory_info;
|
||||
} esp_wps_config_t;
|
||||
|
||||
#define WPS_CONFIG_INIT_DEFAULT(type) { \
|
||||
.wps_type = type, \
|
||||
.crypto_funcs = &g_wifi_default_wps_crypto_funcs, \
|
||||
.factory_info = { \
|
||||
.manufacturer = "ESPRESSIF", \
|
||||
.model_number = "ESP32", \
|
||||
.model_name = "ESPRESSIF IOT", \
|
||||
.device_name = "ESP STATION", \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable Wi-Fi WPS function.
|
||||
*
|
||||
* @attention WPS can only be used when ESP32 station is enabled.
|
||||
*
|
||||
* @param wps_type_t wps_type : WPS type, so far only WPS_TYPE_PBC and WPS_TYPE_PIN is supported
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid
|
||||
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
|
||||
* - ESP_FAIL : wps initialization fails
|
||||
*/
|
||||
esp_err_t esp_wifi_wps_enable(const esp_wps_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Disable Wi-Fi WPS function and release resource it taken.
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
|
||||
*/
|
||||
esp_err_t esp_wifi_wps_disable(void);
|
||||
|
||||
/**
|
||||
* @brief WPS starts to work.
|
||||
*
|
||||
* @attention WPS can only be used when ESP32 station is enabled.
|
||||
*
|
||||
* @param timeout_ms : maximum blocking time before API return.
|
||||
* - 0 : non-blocking
|
||||
* - 1~120000 : blocking time (not supported in IDF v1.0)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid
|
||||
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
|
||||
* - ESP_ERR_WIFI_WPS_SM : wps state machine is not initialized
|
||||
* - ESP_FAIL : wps initialization fails
|
||||
*/
|
||||
esp_err_t esp_wifi_wps_start(int timeout_ms);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_WPS_H__ */
|
||||
Submodule components/esp32/lib deleted from 064ebf1b04
@@ -1,139 +0,0 @@
|
||||
// Copyright 2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @file lib_printf.c
|
||||
*
|
||||
* This file contains library-specific printf functions
|
||||
* used by WiFi libraries in the `lib` directory.
|
||||
* These function are used to catch any output which gets printed
|
||||
* by libraries, and redirect it to ESP_LOG macros.
|
||||
*
|
||||
* Eventually WiFi libraries will use ESP_LOG functions internally
|
||||
* and these definitions will be removed.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "esp_log.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
#define VPRINTF_STACK_BUFFER_SIZE 80
|
||||
|
||||
static int lib_printf(const char* tag, const char* format, va_list arg)
|
||||
{
|
||||
char temp[VPRINTF_STACK_BUFFER_SIZE];
|
||||
int len = vsnprintf(temp, sizeof(temp) - 1, format, arg);
|
||||
temp[sizeof(temp) - 1] = 0;
|
||||
int i;
|
||||
for (i = len - 1; i >= 0; --i) {
|
||||
if (temp[i] != '\n' && temp[i] != '\r' && temp[i] != ' ') {
|
||||
break;
|
||||
}
|
||||
temp[i] = 0;
|
||||
}
|
||||
if (i > 0) {
|
||||
ESP_EARLY_LOGI(tag, "%s", temp);
|
||||
}
|
||||
va_end(arg);
|
||||
return len;
|
||||
}
|
||||
|
||||
int phy_printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
int res = lib_printf("phy", format, arg);
|
||||
va_end(arg);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int rtc_printf(const char* format, ...)
|
||||
{
|
||||
// librtc.a printf temporary disabled due to UART baud rate switching bug.
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wpa_printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
int res = lib_printf("wpa", format, arg);
|
||||
va_end(arg);
|
||||
return res;
|
||||
}
|
||||
|
||||
int wpa2_printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
int res = lib_printf("wpa2", format, arg);
|
||||
va_end(arg);
|
||||
return res;
|
||||
}
|
||||
|
||||
int wps_printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
int res = lib_printf("wps", format, arg);
|
||||
va_end(arg);
|
||||
return res;
|
||||
}
|
||||
|
||||
int pp_printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
int res = lib_printf("pp", format, arg);
|
||||
va_end(arg);
|
||||
return res;
|
||||
}
|
||||
|
||||
int sc_printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
int res = lib_printf("smartconfig", format, arg);
|
||||
va_end(arg);
|
||||
return res;
|
||||
}
|
||||
|
||||
int core_printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
int res = lib_printf("core", format, arg);
|
||||
va_end(arg);
|
||||
return res;
|
||||
}
|
||||
|
||||
int net80211_printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
int res = lib_printf("net80211", format, arg);
|
||||
va_end(arg);
|
||||
return res;
|
||||
}
|
||||
|
||||
int coexist_printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
int res = lib_printf("coexist", format, arg);
|
||||
va_end(arg);
|
||||
return res;
|
||||
}
|
||||
@@ -1,42 +1,19 @@
|
||||
[mapping]
|
||||
archive: libesp32.a
|
||||
entries:
|
||||
entries:
|
||||
panic (noflash)
|
||||
|
||||
[mapping]
|
||||
archive: libphy.a
|
||||
entries:
|
||||
* (noflash_data)
|
||||
|
||||
[mapping]
|
||||
archive: libhal.a
|
||||
entries:
|
||||
* (noflash_text)
|
||||
|
||||
[mapping]
|
||||
archive: librtc.a
|
||||
entries:
|
||||
entries:
|
||||
* (noflash_text)
|
||||
|
||||
[mapping]
|
||||
archive: libgcc.a
|
||||
entries:
|
||||
entries:
|
||||
lib2funcs (noflash_text)
|
||||
|
||||
[mapping]
|
||||
archive: libgcov.a
|
||||
entries:
|
||||
entries:
|
||||
* (noflash)
|
||||
|
||||
[mapping]
|
||||
archive: libpp.a
|
||||
entries:
|
||||
: ESP32_WIFI_IRAM_OPT = y
|
||||
* (wifi_iram)
|
||||
|
||||
[mapping]
|
||||
archive: libnet80211.a
|
||||
entries:
|
||||
: ESP32_WIFI_IRAM_OPT = y
|
||||
* (wifi_iram)
|
||||
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include "esp_phy_init.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_CAL_DATA_CHECK_FAIL 1
|
||||
|
||||
/**
|
||||
* @file phy.h
|
||||
* @brief Declarations for functions provided by libphy.a
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Return ROM function pointer table from PHY library.
|
||||
*/
|
||||
void phy_get_romfunc_addr(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize PHY module and do RF calibration
|
||||
* @param[in] init_data Initialization parameters to be used by the PHY
|
||||
* @param[inout] cal_data As input, calibration data previously obtained. As output, will contain new calibration data.
|
||||
* @param[in] cal_mode RF calibration mode
|
||||
* @return ESP_CAL_DATA_CHECK_FAIL if calibration data checksum fails, other values are reserved for future use
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Get the format version of calibration data used by PHY library.
|
||||
* @return Format version number, OR'ed with BIT(16) if PHY is in WIFI only mode.
|
||||
*/
|
||||
uint32_t phy_get_rf_cal_version();
|
||||
|
||||
/**
|
||||
* @brief Set RF/BB for only WIFI mode or coexist(WIFI & BT) mode
|
||||
* @param[in] true is for only WIFI mode, false is for coexist mode. default is 0.
|
||||
* @return NULL
|
||||
*/
|
||||
void phy_set_wifi_mode_only(bool wifi_only);
|
||||
|
||||
/**
|
||||
* @brief Set BT the highest priority in coexist mode.
|
||||
* @return NULL
|
||||
*/
|
||||
void coex_bt_high_prio(void);
|
||||
|
||||
/**
|
||||
* @brief Shutdown PHY and RF.
|
||||
*/
|
||||
void phy_close_rf(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,665 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <sys/lock.h>
|
||||
|
||||
#include "esp32/rom/ets_sys.h"
|
||||
#include "esp32/rom/rtc.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/portmacro.h"
|
||||
#include "phy.h"
|
||||
#include "phy_init_data.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "esp_wifi_internal.h"
|
||||
|
||||
extern wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb;
|
||||
|
||||
static const char* TAG = "phy_init";
|
||||
|
||||
static _lock_t s_phy_rf_init_lock;
|
||||
|
||||
/* Bit mask of modules needing to call phy_rf_init */
|
||||
static uint32_t s_module_phy_rf_init = 0;
|
||||
|
||||
/* Whether modem sleep is turned on */
|
||||
static volatile bool s_is_phy_rf_en = false;
|
||||
|
||||
/* Bit mask of modules needing to enter modem sleep mode */
|
||||
static uint32_t s_modem_sleep_module_enter = 0;
|
||||
|
||||
/* Bit mask of modules which might use RF, system can enter modem
|
||||
* sleep mode only when all modules registered require to enter
|
||||
* modem sleep*/
|
||||
static uint32_t s_modem_sleep_module_register = 0;
|
||||
|
||||
/* Whether modern sleep is turned on */
|
||||
static volatile bool s_is_modem_sleep_en = false;
|
||||
|
||||
static _lock_t s_modem_sleep_lock;
|
||||
|
||||
/* time stamp updated when the PHY/RF is turned on */
|
||||
static int64_t s_phy_rf_en_ts = 0;
|
||||
|
||||
uint32_t IRAM_ATTR phy_enter_critical(void)
|
||||
{
|
||||
return portENTER_CRITICAL_NESTED();
|
||||
}
|
||||
|
||||
void IRAM_ATTR phy_exit_critical(uint32_t level)
|
||||
{
|
||||
portEXIT_CRITICAL_NESTED(level);
|
||||
}
|
||||
|
||||
int64_t esp_phy_rf_get_on_ts(void)
|
||||
{
|
||||
return s_phy_rf_en_ts;
|
||||
}
|
||||
|
||||
static inline void phy_update_wifi_mac_time(bool en_clock_stopped, int64_t now)
|
||||
{
|
||||
static uint32_t s_common_clock_disable_time = 0;
|
||||
|
||||
if (en_clock_stopped) {
|
||||
s_common_clock_disable_time = (uint32_t)now;
|
||||
} else {
|
||||
if (s_common_clock_disable_time) {
|
||||
uint32_t diff = (uint64_t)now - s_common_clock_disable_time;
|
||||
|
||||
if (s_wifi_mac_time_update_cb) {
|
||||
s_wifi_mac_time_update_cb(diff);
|
||||
}
|
||||
s_common_clock_disable_time = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data, esp_phy_calibration_mode_t mode,
|
||||
esp_phy_calibration_data_t* calibration_data, phy_rf_module_t module)
|
||||
{
|
||||
/* 3 modules may call phy_init: Wi-Fi, BT, Modem Sleep */
|
||||
if (module >= PHY_MODULE_COUNT){
|
||||
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
|
||||
module count(%d)", __func__, module, PHY_MODULE_COUNT);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
_lock_acquire(&s_phy_rf_init_lock);
|
||||
uint32_t s_module_phy_rf_init_old = s_module_phy_rf_init;
|
||||
bool is_wifi_or_bt_enabled = !!(s_module_phy_rf_init_old & (BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE)));
|
||||
esp_err_t status = ESP_OK;
|
||||
s_module_phy_rf_init |= BIT(module);
|
||||
|
||||
if ((is_wifi_or_bt_enabled == false) && (module == PHY_MODEM_MODULE)){
|
||||
status = ESP_FAIL;
|
||||
}
|
||||
else if (s_is_phy_rf_en == true) {
|
||||
}
|
||||
else {
|
||||
/* If Wi-Fi, BT all disabled, modem sleep should not take effect;
|
||||
* If either Wi-Fi or BT is enabled, should allow modem sleep requires
|
||||
* to enter sleep;
|
||||
* If Wi-Fi, BT co-exist, it is disallowed that only one module
|
||||
* support modem sleep, E,g. BT support modem sleep but Wi-Fi not
|
||||
* support modem sleep;
|
||||
*/
|
||||
if (is_wifi_or_bt_enabled == false){
|
||||
if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
|
||||
s_is_phy_rf_en = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (module == PHY_MODEM_MODULE){
|
||||
s_is_phy_rf_en = true;
|
||||
}
|
||||
else if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
|
||||
/* New module (BT or Wi-Fi) can init RF according to modem_sleep_exit */
|
||||
}
|
||||
}
|
||||
if (s_is_phy_rf_en == true){
|
||||
// Update time stamp
|
||||
s_phy_rf_en_ts = esp_timer_get_time();
|
||||
// Update WiFi MAC time before WiFi/BT common clock is enabled
|
||||
phy_update_wifi_mac_time(false, s_phy_rf_en_ts);
|
||||
// Enable WiFi/BT common peripheral clock
|
||||
periph_module_enable(PERIPH_WIFI_BT_COMMON_MODULE);
|
||||
phy_set_wifi_mode_only(0);
|
||||
|
||||
if (ESP_CAL_DATA_CHECK_FAIL == register_chipv7_phy(init_data, calibration_data, mode)) {
|
||||
ESP_LOGW(TAG, "saving new calibration data because of checksum failure, mode(%d)", mode);
|
||||
#ifdef CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
|
||||
if (mode != PHY_RF_CAL_FULL) {
|
||||
esp_phy_store_cal_data_to_nvs(calibration_data);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
coex_bt_high_prio();
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
|
||||
uint32_t phy_bt_wifi_mask = BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE);
|
||||
if ((s_module_phy_rf_init & phy_bt_wifi_mask) == phy_bt_wifi_mask) { //both wifi & bt enabled
|
||||
coex_init();
|
||||
coex_preference_set(CONFIG_SW_COEXIST_PREFERENCE_VALUE);
|
||||
coex_resume();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_lock_release(&s_phy_rf_init_lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
esp_err_t esp_phy_rf_deinit(phy_rf_module_t module)
|
||||
{
|
||||
/* 3 modules may call phy_init: Wi-Fi, BT, Modem Sleep */
|
||||
if (module >= PHY_MODULE_COUNT){
|
||||
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
|
||||
module count(%d)", __func__, module, PHY_MODULE_COUNT);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
_lock_acquire(&s_phy_rf_init_lock);
|
||||
uint32_t s_module_phy_rf_init_old = s_module_phy_rf_init;
|
||||
uint32_t phy_bt_wifi_mask = BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE);
|
||||
bool is_wifi_or_bt_enabled = !!(s_module_phy_rf_init_old & phy_bt_wifi_mask);
|
||||
bool is_both_wifi_bt_enabled = ((s_module_phy_rf_init_old & phy_bt_wifi_mask) == phy_bt_wifi_mask);
|
||||
s_module_phy_rf_init &= ~BIT(module);
|
||||
esp_err_t status = ESP_OK;
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
|
||||
if (is_both_wifi_bt_enabled == true) {
|
||||
coex_deinit();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((is_wifi_or_bt_enabled == false) && (module == PHY_MODEM_MODULE)){
|
||||
/* Modem sleep should not take effect in this case */
|
||||
status = ESP_FAIL;
|
||||
}
|
||||
else if (s_is_phy_rf_en == false) {
|
||||
//do nothing
|
||||
}
|
||||
else {
|
||||
if (is_wifi_or_bt_enabled == false){
|
||||
if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
|
||||
s_is_phy_rf_en = false;
|
||||
ESP_LOGE(TAG, "%s, RF should not be in enabled state if both Wi-Fi and BT are disabled", __func__);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (module == PHY_MODEM_MODULE){
|
||||
s_is_phy_rf_en = false;
|
||||
}
|
||||
else if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
|
||||
s_is_phy_rf_en = is_both_wifi_bt_enabled ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_is_phy_rf_en == false) {
|
||||
// Disable PHY and RF.
|
||||
phy_close_rf();
|
||||
// Update WiFi MAC time before disalbe WiFi/BT common peripheral clock
|
||||
phy_update_wifi_mac_time(true, esp_timer_get_time());
|
||||
// Disable WiFi/BT common peripheral clock. Do not disable clock for hardware RNG
|
||||
periph_module_disable(PERIPH_WIFI_BT_COMMON_MODULE);
|
||||
}
|
||||
}
|
||||
|
||||
_lock_release(&s_phy_rf_init_lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
esp_err_t esp_modem_sleep_enter(modem_sleep_module_t module)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
uint32_t phy_bt_wifi_mask = BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE);
|
||||
#endif
|
||||
|
||||
if (module >= MODEM_MODULE_COUNT){
|
||||
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
|
||||
module count(%d)", __func__, module, MODEM_MODULE_COUNT);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
else if (!(s_modem_sleep_module_register & BIT(module))){
|
||||
ESP_LOGW(TAG, "%s, module (%d) has not been registered", __func__, module);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
else {
|
||||
_lock_acquire(&s_modem_sleep_lock);
|
||||
s_modem_sleep_module_enter |= BIT(module);
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
_lock_acquire(&s_phy_rf_init_lock);
|
||||
if (((s_module_phy_rf_init & phy_bt_wifi_mask) == phy_bt_wifi_mask) //both wifi & bt enabled
|
||||
&& (s_modem_sleep_module_enter & (MODEM_BT_MASK | MODEM_WIFI_MASK)) != 0){
|
||||
coex_pause();
|
||||
}
|
||||
_lock_release(&s_phy_rf_init_lock);
|
||||
#endif
|
||||
if (!s_is_modem_sleep_en && (s_modem_sleep_module_enter == s_modem_sleep_module_register)){
|
||||
esp_err_t status = esp_phy_rf_deinit(PHY_MODEM_MODULE);
|
||||
if (status == ESP_OK){
|
||||
s_is_modem_sleep_en = true;
|
||||
}
|
||||
}
|
||||
_lock_release(&s_modem_sleep_lock);
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_modem_sleep_exit(modem_sleep_module_t module)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
uint32_t phy_bt_wifi_mask = BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE);
|
||||
#endif
|
||||
|
||||
if (module >= MODEM_MODULE_COUNT){
|
||||
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
|
||||
module count(%d)", __func__, module, MODEM_MODULE_COUNT);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
else if (!(s_modem_sleep_module_register & BIT(module))){
|
||||
ESP_LOGW(TAG, "%s, module (%d) has not been registered", __func__, module);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
else {
|
||||
_lock_acquire(&s_modem_sleep_lock);
|
||||
s_modem_sleep_module_enter &= ~BIT(module);
|
||||
if (s_is_modem_sleep_en){
|
||||
esp_err_t status = esp_phy_rf_init(NULL,PHY_RF_CAL_NONE,NULL, PHY_MODEM_MODULE);
|
||||
if (status == ESP_OK){
|
||||
s_is_modem_sleep_en = false;
|
||||
}
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
_lock_acquire(&s_phy_rf_init_lock);
|
||||
if (((s_module_phy_rf_init & phy_bt_wifi_mask) == phy_bt_wifi_mask) //both wifi & bt enabled
|
||||
&& (s_modem_sleep_module_enter & (MODEM_BT_MASK | MODEM_WIFI_MASK)) == 0){
|
||||
coex_resume();
|
||||
}
|
||||
_lock_release(&s_phy_rf_init_lock);
|
||||
#endif
|
||||
_lock_release(&s_modem_sleep_lock);
|
||||
return ESP_OK;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_modem_sleep_register(modem_sleep_module_t module)
|
||||
{
|
||||
if (module >= MODEM_MODULE_COUNT){
|
||||
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
|
||||
module count(%d)", __func__, module, MODEM_MODULE_COUNT);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
else if (s_modem_sleep_module_register & BIT(module)){
|
||||
ESP_LOGI(TAG, "%s, multiple registration of module (%d)", __func__, module);
|
||||
return ESP_OK;
|
||||
}
|
||||
else{
|
||||
_lock_acquire(&s_modem_sleep_lock);
|
||||
s_modem_sleep_module_register |= BIT(module);
|
||||
/* The module is set to enter modem sleep by default, otherwise will prevent
|
||||
* other modules from entering sleep mode if this module never call enter sleep function
|
||||
* in the future */
|
||||
s_modem_sleep_module_enter |= BIT(module);
|
||||
_lock_release(&s_modem_sleep_lock);
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_modem_sleep_deregister(modem_sleep_module_t module)
|
||||
{
|
||||
if (module >= MODEM_MODULE_COUNT){
|
||||
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
|
||||
module count(%d)", __func__, module, MODEM_MODULE_COUNT);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
else if (!(s_modem_sleep_module_register & BIT(module))){
|
||||
ESP_LOGI(TAG, "%s, module (%d) has not been registered", __func__, module);
|
||||
return ESP_OK;
|
||||
}
|
||||
else{
|
||||
_lock_acquire(&s_modem_sleep_lock);
|
||||
s_modem_sleep_module_enter &= ~BIT(module);
|
||||
s_modem_sleep_module_register &= ~BIT(module);
|
||||
if (s_modem_sleep_module_register == 0){
|
||||
s_modem_sleep_module_enter = 0;
|
||||
/* Once all module are de-registered and current state
|
||||
* is modem sleep mode, we need to turn off modem sleep
|
||||
*/
|
||||
if (s_is_modem_sleep_en == true){
|
||||
s_is_modem_sleep_en = false;
|
||||
esp_phy_rf_init(NULL,PHY_RF_CAL_NONE,NULL, PHY_MODEM_MODULE);
|
||||
}
|
||||
}
|
||||
_lock_release(&s_modem_sleep_lock);
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// PHY init data handling functions
|
||||
#if CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION
|
||||
#include "esp_partition.h"
|
||||
|
||||
const esp_phy_init_data_t* esp_phy_get_init_data()
|
||||
{
|
||||
const esp_partition_t* partition = esp_partition_find_first(
|
||||
ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_PHY, NULL);
|
||||
if (partition == NULL) {
|
||||
ESP_LOGE(TAG, "PHY data partition not found");
|
||||
return NULL;
|
||||
}
|
||||
ESP_LOGD(TAG, "loading PHY init data from partition at offset 0x%x", partition->address);
|
||||
size_t init_data_store_length = sizeof(phy_init_magic_pre) +
|
||||
sizeof(esp_phy_init_data_t) + sizeof(phy_init_magic_post);
|
||||
uint8_t* init_data_store = (uint8_t*) malloc(init_data_store_length);
|
||||
if (init_data_store == NULL) {
|
||||
ESP_LOGE(TAG, "failed to allocate memory for PHY init data");
|
||||
return NULL;
|
||||
}
|
||||
esp_err_t err = esp_partition_read(partition, 0, init_data_store, init_data_store_length);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "failed to read PHY data partition (0x%x)", err);
|
||||
return NULL;
|
||||
}
|
||||
if (memcmp(init_data_store, PHY_INIT_MAGIC, sizeof(phy_init_magic_pre)) != 0 ||
|
||||
memcmp(init_data_store + init_data_store_length - sizeof(phy_init_magic_post),
|
||||
PHY_INIT_MAGIC, sizeof(phy_init_magic_post)) != 0) {
|
||||
ESP_LOGE(TAG, "failed to validate PHY data partition");
|
||||
return NULL;
|
||||
}
|
||||
ESP_LOGD(TAG, "PHY data partition validated");
|
||||
return (const esp_phy_init_data_t*) (init_data_store + sizeof(phy_init_magic_pre));
|
||||
}
|
||||
|
||||
void esp_phy_release_init_data(const esp_phy_init_data_t* init_data)
|
||||
{
|
||||
free((uint8_t*) init_data - sizeof(phy_init_magic_pre));
|
||||
}
|
||||
|
||||
#else // CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION
|
||||
|
||||
// phy_init_data.h will declare static 'phy_init_data' variable initialized with default init data
|
||||
|
||||
const esp_phy_init_data_t* esp_phy_get_init_data()
|
||||
{
|
||||
ESP_LOGD(TAG, "loading PHY init data from application binary");
|
||||
return &phy_init_data;
|
||||
}
|
||||
|
||||
void esp_phy_release_init_data(const esp_phy_init_data_t* init_data)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
#endif // CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION
|
||||
|
||||
|
||||
// PHY calibration data handling functions
|
||||
static const char* PHY_NAMESPACE = "phy";
|
||||
static const char* PHY_CAL_VERSION_KEY = "cal_version";
|
||||
static const char* PHY_CAL_MAC_KEY = "cal_mac";
|
||||
static const char* PHY_CAL_DATA_KEY = "cal_data";
|
||||
|
||||
static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
|
||||
esp_phy_calibration_data_t* out_cal_data);
|
||||
|
||||
static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
|
||||
const esp_phy_calibration_data_t* cal_data);
|
||||
|
||||
esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_data)
|
||||
{
|
||||
nvs_handle handle;
|
||||
esp_err_t err = nvs_open(PHY_NAMESPACE, NVS_READONLY, &handle);
|
||||
if (err == ESP_ERR_NVS_NOT_INITIALIZED) {
|
||||
ESP_LOGE(TAG, "%s: NVS has not been initialized. "
|
||||
"Call nvs_flash_init before starting WiFi/BT.", __func__);
|
||||
return err;
|
||||
} else if (err != ESP_OK) {
|
||||
ESP_LOGD(TAG, "%s: failed to open NVS namespace (0x%x)", __func__, err);
|
||||
return err;
|
||||
}
|
||||
err = load_cal_data_from_nvs_handle(handle, out_cal_data);
|
||||
nvs_close(handle);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_data)
|
||||
{
|
||||
nvs_handle handle;
|
||||
esp_err_t err = nvs_open(PHY_NAMESPACE, NVS_READWRITE, &handle);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGD(TAG, "%s: failed to open NVS namespace (0x%x)", __func__, err);
|
||||
return err;
|
||||
}
|
||||
else {
|
||||
err = store_cal_data_to_nvs_handle(handle, cal_data);
|
||||
nvs_close(handle);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_phy_erase_cal_data_in_nvs(void)
|
||||
{
|
||||
nvs_handle handle;
|
||||
esp_err_t err = nvs_open(PHY_NAMESPACE, NVS_READWRITE, &handle);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: failed to open NVS phy namespace (0x%x)", __func__, err);
|
||||
return err;
|
||||
}
|
||||
else {
|
||||
err = nvs_erase_all(handle);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: failed to erase NVS phy namespace (0x%x)", __func__, err);
|
||||
}
|
||||
else {
|
||||
err = nvs_commit(handle);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: failed to commit NVS phy namespace (0x%x)", __func__, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
nvs_close(handle);
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
|
||||
esp_phy_calibration_data_t* out_cal_data)
|
||||
{
|
||||
esp_err_t err;
|
||||
uint32_t cal_data_version;
|
||||
err = nvs_get_u32(handle, PHY_CAL_VERSION_KEY, &cal_data_version);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGD(TAG, "%s: failed to get cal_version (0x%x)", __func__, err);
|
||||
return err;
|
||||
}
|
||||
uint32_t cal_format_version = phy_get_rf_cal_version() & (~BIT(16));
|
||||
ESP_LOGV(TAG, "phy_get_rf_cal_version: %d\n", cal_format_version);
|
||||
if (cal_data_version != cal_format_version) {
|
||||
ESP_LOGD(TAG, "%s: expected calibration data format %d, found %d",
|
||||
__func__, cal_format_version, cal_data_version);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
uint8_t cal_data_mac[6];
|
||||
size_t length = sizeof(cal_data_mac);
|
||||
err = nvs_get_blob(handle, PHY_CAL_MAC_KEY, cal_data_mac, &length);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGD(TAG, "%s: failed to get cal_mac (0x%x)", __func__, err);
|
||||
return err;
|
||||
}
|
||||
if (length != sizeof(cal_data_mac)) {
|
||||
ESP_LOGD(TAG, "%s: invalid length of cal_mac (%d)", __func__, length);
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
uint8_t sta_mac[6];
|
||||
esp_efuse_mac_get_default(sta_mac);
|
||||
if (memcmp(sta_mac, cal_data_mac, sizeof(sta_mac)) != 0) {
|
||||
ESP_LOGE(TAG, "%s: calibration data MAC check failed: expected " \
|
||||
MACSTR ", found " MACSTR,
|
||||
__func__, MAC2STR(sta_mac), MAC2STR(cal_data_mac));
|
||||
return ESP_FAIL;
|
||||
}
|
||||
length = sizeof(*out_cal_data);
|
||||
err = nvs_get_blob(handle, PHY_CAL_DATA_KEY, out_cal_data, &length);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: failed to get cal_data(0x%x)", __func__, err);
|
||||
return err;
|
||||
}
|
||||
if (length != sizeof(*out_cal_data)) {
|
||||
ESP_LOGD(TAG, "%s: invalid length of cal_data (%d)", __func__, length);
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
|
||||
const esp_phy_calibration_data_t* cal_data)
|
||||
{
|
||||
esp_err_t err;
|
||||
|
||||
err = nvs_set_blob(handle, PHY_CAL_DATA_KEY, cal_data, sizeof(*cal_data));
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: store calibration data failed(0x%x)\n", __func__, err);
|
||||
return err;
|
||||
}
|
||||
|
||||
uint8_t sta_mac[6];
|
||||
esp_efuse_mac_get_default(sta_mac);
|
||||
err = nvs_set_blob(handle, PHY_CAL_MAC_KEY, sta_mac, sizeof(sta_mac));
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: store calibration mac failed(0x%x)\n", __func__, err);
|
||||
return err;
|
||||
}
|
||||
|
||||
uint32_t cal_format_version = phy_get_rf_cal_version() & (~BIT(16));
|
||||
ESP_LOGV(TAG, "phy_get_rf_cal_version: %d\n", cal_format_version);
|
||||
err = nvs_set_u32(handle, PHY_CAL_VERSION_KEY, cal_format_version);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: store calibration version failed(0x%x)\n", __func__, err);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = nvs_commit(handle);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: store calibration nvs commit failed(0x%x)\n", __func__, err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
#if CONFIG_REDUCE_PHY_TX_POWER
|
||||
static void esp_phy_reduce_tx_power(esp_phy_init_data_t* init_data)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < PHY_TX_POWER_NUM; i++) {
|
||||
// LOWEST_PHY_TX_POWER is the lowest tx power
|
||||
init_data->params[PHY_TX_POWER_OFFSET+i] = PHY_TX_POWER_LOWEST;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void esp_phy_load_cal_and_init(phy_rf_module_t module)
|
||||
{
|
||||
esp_phy_calibration_data_t* cal_data =
|
||||
(esp_phy_calibration_data_t*) calloc(sizeof(esp_phy_calibration_data_t), 1);
|
||||
if (cal_data == NULL) {
|
||||
ESP_LOGE(TAG, "failed to allocate memory for RF calibration data");
|
||||
abort();
|
||||
}
|
||||
|
||||
#if CONFIG_REDUCE_PHY_TX_POWER
|
||||
const esp_phy_init_data_t* phy_init_data = esp_phy_get_init_data();
|
||||
if (phy_init_data == NULL) {
|
||||
ESP_LOGE(TAG, "failed to obtain PHY init data");
|
||||
abort();
|
||||
}
|
||||
|
||||
esp_phy_init_data_t* init_data = (esp_phy_init_data_t*) malloc(sizeof(esp_phy_init_data_t));
|
||||
if (init_data == NULL) {
|
||||
ESP_LOGE(TAG, "failed to allocate memory for phy init data");
|
||||
abort();
|
||||
}
|
||||
|
||||
memcpy(init_data, phy_init_data, sizeof(esp_phy_init_data_t));
|
||||
if (esp_reset_reason() == ESP_RST_BROWNOUT) {
|
||||
esp_phy_reduce_tx_power(init_data);
|
||||
}
|
||||
#else
|
||||
const esp_phy_init_data_t* init_data = esp_phy_get_init_data();
|
||||
if (init_data == NULL) {
|
||||
ESP_LOGE(TAG, "failed to obtain PHY init data");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
|
||||
esp_phy_calibration_mode_t calibration_mode = PHY_RF_CAL_PARTIAL;
|
||||
uint8_t sta_mac[6];
|
||||
if (rtc_get_reset_reason(0) == DEEPSLEEP_RESET) {
|
||||
calibration_mode = PHY_RF_CAL_NONE;
|
||||
}
|
||||
esp_err_t err = esp_phy_load_cal_data_from_nvs(cal_data);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "failed to load RF calibration data (0x%x), falling back to full calibration", err);
|
||||
calibration_mode = PHY_RF_CAL_FULL;
|
||||
}
|
||||
|
||||
esp_efuse_mac_get_default(sta_mac);
|
||||
memcpy(cal_data->mac, sta_mac, 6);
|
||||
esp_phy_rf_init(init_data, calibration_mode, cal_data, module);
|
||||
|
||||
if (calibration_mode != PHY_RF_CAL_NONE && err != ESP_OK) {
|
||||
err = esp_phy_store_cal_data_to_nvs(cal_data);
|
||||
} else {
|
||||
err = ESP_OK;
|
||||
}
|
||||
#else
|
||||
esp_phy_rf_init(init_data, PHY_RF_CAL_FULL, cal_data, module);
|
||||
#endif
|
||||
|
||||
#if CONFIG_REDUCE_PHY_TX_POWER
|
||||
esp_phy_release_init_data(phy_init_data);
|
||||
free(init_data);
|
||||
#else
|
||||
esp_phy_release_init_data(init_data);
|
||||
#endif
|
||||
|
||||
free(cal_data); // PHY maintains a copy of calibration data, so we can free this
|
||||
}
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
// Copyright 2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef PHY_INIT_DATA_H
|
||||
#define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
|
||||
#include "esp_phy_init.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
// constrain a value between 'low' and 'high', inclusive
|
||||
#define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val)
|
||||
|
||||
#define PHY_INIT_MAGIC "PHYINIT"
|
||||
|
||||
// define the lowest tx power as LOWEST_PHY_TX_POWER
|
||||
#define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 52)
|
||||
#define PHY_TX_POWER_OFFSET 44
|
||||
#define PHY_TX_POWER_NUM 5
|
||||
|
||||
static const char phy_init_magic_pre[] = PHY_INIT_MAGIC;
|
||||
|
||||
/**
|
||||
* @brief Structure containing default recommended PHY initialization parameters.
|
||||
*/
|
||||
static const esp_phy_init_data_t phy_init_data= { {
|
||||
3,
|
||||
3,
|
||||
0x05,
|
||||
0x09,
|
||||
0x06,
|
||||
0x05,
|
||||
0x03,
|
||||
0x06,
|
||||
0x05,
|
||||
0x04,
|
||||
0x06,
|
||||
0x04,
|
||||
0x05,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x05,
|
||||
0x09,
|
||||
0x06,
|
||||
0x05,
|
||||
0x03,
|
||||
0x06,
|
||||
0x05,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0xfc,
|
||||
0xfc,
|
||||
0xfe,
|
||||
0xf0,
|
||||
0xf0,
|
||||
0xf0,
|
||||
0xe0,
|
||||
0xe0,
|
||||
0xe0,
|
||||
0x18,
|
||||
0x18,
|
||||
0x18,
|
||||
LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 78),
|
||||
LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 72),
|
||||
LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 66),
|
||||
LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 60),
|
||||
LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 56),
|
||||
LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 52),
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
} };
|
||||
|
||||
static const char phy_init_magic_post[] = PHY_INIT_MAGIC;
|
||||
|
||||
#endif /* PHY_INIT_DATA_H */
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright 2013-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "esp_system.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
/* This function is in a separate file from the reset of system APIs because
|
||||
* it causes link time dependency on WiFi stack.
|
||||
*/
|
||||
void system_restore(void)
|
||||
{
|
||||
esp_wifi_restore();
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "esp_system.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_wifi_internal.h"
|
||||
#include "esp_private/wifi.h"
|
||||
#include "esp_log.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp32/rom/efuse.h"
|
||||
|
||||
@@ -10,28 +10,6 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h"
|
||||
WORKING_DIRECTORY ${COMPONENT_PATH}
|
||||
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/logo.jpg")
|
||||
|
||||
# Calculate MD5 value of header file esp_wifi_os_adapter.h
|
||||
execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi_os_adapter.h
|
||||
COMMAND cut -c 1-7
|
||||
OUTPUT_VARIABLE WIFI_OS_ADAPTER_MD5
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Calculate MD5 value of header file esp_wifi_crypto_types.h
|
||||
execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi_crypto_types.h
|
||||
COMMAND cut -c 1-7
|
||||
OUTPUT_VARIABLE WIFI_CRYPTO_MD5
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Calculate MD5 value of header file esp_coexist_adapter.h
|
||||
execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_coexist_adapter.h
|
||||
COMMAND cut -c 1-7
|
||||
OUTPUT_VARIABLE COEX_ADAPTER_MD5
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
add_definitions(-DWIFI_OS_ADAPTER_MD5=\"${WIFI_OS_ADAPTER_MD5}\")
|
||||
add_definitions(-DWIFI_CRYPTO_MD5=\"${WIFI_CRYPTO_MD5}\")
|
||||
add_definitions(-DCOEX_ADAPTER_MD5=\"${COEX_ADAPTER_MD5}\")
|
||||
|
||||
add_custom_target(esp32_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h")
|
||||
|
||||
add_dependencies(${COMPONENT_TARGET} esp32_test_logo)
|
||||
|
||||
@@ -8,18 +8,6 @@ COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-a
|
||||
|
||||
COMPONENT_SRCDIRS := .
|
||||
|
||||
# Calculate MD5 value of header file esp_wifi_os_adapter.h
|
||||
WIFI_OS_ADAPTER_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_wifi_os_adapter.h | cut -c 1-7)\"
|
||||
CFLAGS+=-DWIFI_OS_ADAPTER_MD5=$(WIFI_OS_ADAPTER_MD5_VAL)
|
||||
|
||||
# Calculate MD5 value of header file esp_wifi_crypto_types.h
|
||||
WIFI_CRYPTO_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_wifi_crypto_types.h | cut -c 1-7)\"
|
||||
CFLAGS+=-DWIFI_CRYPTO_MD5=$(WIFI_CRYPTO_MD5_VAL)
|
||||
|
||||
# Calculate MD5 value of header file esp_coexist_adapter.h
|
||||
COEX_ADAPTER_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_coexist_adapter.h | cut -c 1-7)\"
|
||||
CFLAGS+=-DCOEX_ADAPTER_MD5=$(COEX_ADAPTER_MD5_VAL)
|
||||
|
||||
test_tjpgd.o: test_tjpgd_logo.h
|
||||
|
||||
test_tjpgd_logo.h: $(COMPONENT_PATH)/logo.jpg
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
Tests for the Wi-Fi
|
||||
*/
|
||||
#include "unity.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi_internal.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
|
||||
static const char* TAG = "test_header_files_md5";
|
||||
|
||||
TEST_CASE("wifi os adapter MD5","[wifi]")
|
||||
{
|
||||
const char *test_wifi_os_funcs_md5 = WIFI_OS_ADAPTER_MD5;
|
||||
|
||||
ESP_LOGI(TAG, "test wifi os adapter MD5...");
|
||||
TEST_ESP_OK(esp_wifi_internal_osi_funcs_md5_check(test_wifi_os_funcs_md5));
|
||||
|
||||
ESP_LOGI(TAG, "test passed...");
|
||||
}
|
||||
|
||||
TEST_CASE("wifi crypto types MD5","[wifi]")
|
||||
{
|
||||
const char *test_wifi_crypto_funcs_md5 = WIFI_CRYPTO_MD5;
|
||||
|
||||
ESP_LOGI(TAG, "test wifi crypto adapter MD5...");
|
||||
TEST_ESP_OK(esp_wifi_internal_crypto_funcs_md5_check(test_wifi_crypto_funcs_md5));
|
||||
|
||||
ESP_LOGI(TAG, "test passed...");
|
||||
}
|
||||
|
||||
TEST_CASE("coexist adapter MD5","[coex]")
|
||||
{
|
||||
const char *test_coex_adapter_funcs_md5 = COEX_ADAPTER_MD5;
|
||||
|
||||
ESP_LOGI(TAG, "test coexist adapter MD5...");
|
||||
TEST_ESP_OK(esp_coex_adapter_funcs_md5_check(test_coex_adapter_funcs_md5));
|
||||
|
||||
ESP_LOGI(TAG, "test passed...");
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
Tests for the Wi-Fi
|
||||
*/
|
||||
#include "string.h"
|
||||
#include "esp_system.h"
|
||||
#include "unity.h"
|
||||
#include "esp_log.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "test_utils.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include <freertos/semphr.h>
|
||||
|
||||
|
||||
//Function just extern, need not test
|
||||
extern void bt_bb_init_cmplx(void);
|
||||
extern void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu();
|
||||
extern void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu();
|
||||
|
||||
//Functions in librtc.a called by WIFI or Blutooth directly in ISR
|
||||
extern void bt_bb_init_cmplx_reg(void);
|
||||
extern void force_wifi_mode(int);
|
||||
extern void unforce_wifi_mode(void);
|
||||
extern void bt_track_pll_cap(void);
|
||||
|
||||
static const char* TAG = "test_phy_rtc";
|
||||
|
||||
static SemaphoreHandle_t semphr_done;
|
||||
|
||||
//Functions in libphy.a called by WIFI or Blutooth directly in ISR
|
||||
static void test_phy_rtc_init(void)
|
||||
{
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_LOGI(TAG, "no free pages or nvs version mismatch, erase..");
|
||||
TEST_ESP_OK(nvs_flash_erase());
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
TEST_ESP_OK(ret);
|
||||
|
||||
esp_phy_load_cal_and_init(PHY_BT_MODULE);
|
||||
esp_phy_load_cal_and_init(PHY_WIFI_MODULE);
|
||||
|
||||
//must run here, not blocking in above code
|
||||
TEST_ASSERT(1);
|
||||
}
|
||||
|
||||
static IRAM_ATTR void test_phy_rtc_cache_task(void *arg)
|
||||
{
|
||||
test_phy_rtc_init();
|
||||
|
||||
ESP_LOGI(TAG, "Test bt_bb_init_cmplx_reg()...");
|
||||
spi_flash_disable_interrupts_caches_and_other_cpu();
|
||||
bt_bb_init_cmplx_reg();
|
||||
spi_flash_enable_interrupts_caches_and_other_cpu();
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
ESP_LOGI(TAG, "Test force_wifi_mode(%d)...", i);
|
||||
spi_flash_disable_interrupts_caches_and_other_cpu();
|
||||
force_wifi_mode(i);
|
||||
spi_flash_enable_interrupts_caches_and_other_cpu();
|
||||
|
||||
ESP_LOGI(TAG, "Test unforce_wifi_mode()...");
|
||||
spi_flash_disable_interrupts_caches_and_other_cpu();
|
||||
unforce_wifi_mode();
|
||||
spi_flash_enable_interrupts_caches_and_other_cpu();
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Test bt_track_pll_cap()...");
|
||||
spi_flash_disable_interrupts_caches_and_other_cpu();
|
||||
bt_track_pll_cap();
|
||||
spi_flash_enable_interrupts_caches_and_other_cpu();
|
||||
|
||||
TEST_ASSERT( xSemaphoreGive(semphr_done) );
|
||||
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
TEST_CASE("Test PHY/RTC functions called when cache is disabled", "[phy_rtc][cache_disabled]")
|
||||
{
|
||||
semphr_done = xSemaphoreCreateCounting(1, 0);
|
||||
|
||||
xTaskCreatePinnedToCore(test_phy_rtc_cache_task, "phy_rtc_test_task", 2048,
|
||||
NULL, configMAX_PRIORITIES-1, NULL, 0);
|
||||
|
||||
TEST_ASSERT( xSemaphoreTake(semphr_done, portMAX_DELAY) );
|
||||
|
||||
vSemaphoreDelete(semphr_done);
|
||||
}
|
||||
@@ -1,314 +0,0 @@
|
||||
/*
|
||||
Tests for the Wi-Fi
|
||||
*/
|
||||
#include "string.h"
|
||||
#include "esp_system.h"
|
||||
#include "unity.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_event_loop.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_wifi_types.h"
|
||||
#include "esp_log.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "test_utils.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
|
||||
static const char* TAG = "test_wifi";
|
||||
|
||||
#define DEFAULT_SSID "TEST_SSID"
|
||||
#define DEFAULT_PWD "TEST_PASS"
|
||||
|
||||
#define GOT_IP_EVENT 0x00000001
|
||||
#define DISCONNECT_EVENT 0x00000002
|
||||
|
||||
#define EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT 0x00000001
|
||||
|
||||
static uint32_t wifi_event_handler_flag;
|
||||
|
||||
static EventGroupHandle_t wifi_events;
|
||||
|
||||
static esp_err_t event_handler(void *ctx, system_event_t *event)
|
||||
{
|
||||
printf("ev_handle_called.\n");
|
||||
switch(event->event_id) {
|
||||
case SYSTEM_EVENT_STA_START:
|
||||
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_START");
|
||||
//do not actually connect in test case
|
||||
//;
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_GOT_IP:
|
||||
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_GOT_IP");
|
||||
ESP_LOGI(TAG, "got ip:%s\n",
|
||||
ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip));
|
||||
if (wifi_events) {
|
||||
xEventGroupSetBits(wifi_events, GOT_IP_EVENT);
|
||||
}
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED");
|
||||
if (! (EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT & wifi_event_handler_flag) ) {
|
||||
TEST_ESP_OK(esp_wifi_connect());
|
||||
}
|
||||
if (wifi_events) {
|
||||
xEventGroupSetBits(wifi_events, DISCONNECT_EVENT);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#define EMPH_STR(s) "****** "s" ******"
|
||||
|
||||
static void test_wifi_init_deinit(wifi_init_config_t *cfg, wifi_config_t* wifi_config)
|
||||
{
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_deinit"));
|
||||
TEST_ESP_ERR(ESP_ERR_WIFI_NOT_INIT, esp_wifi_deinit());
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_get_mode"));
|
||||
wifi_mode_t mode_get;
|
||||
TEST_ESP_ERR(ESP_ERR_WIFI_NOT_INIT, esp_wifi_get_mode(&mode_get));
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_init"));
|
||||
TEST_ESP_OK(esp_wifi_init(cfg));
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_set_mode"));
|
||||
TEST_ESP_OK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_set_config"));
|
||||
TEST_ESP_OK(esp_wifi_set_config(ESP_IF_WIFI_STA, wifi_config));
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_deinit..."));
|
||||
TEST_ESP_OK(esp_wifi_deinit());
|
||||
}
|
||||
|
||||
static void test_wifi_start_stop(wifi_init_config_t *cfg, wifi_config_t* wifi_config)
|
||||
{
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_stop"));
|
||||
TEST_ESP_ERR(ESP_ERR_WIFI_NOT_INIT, esp_wifi_stop());
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_init"));
|
||||
TEST_ESP_OK(esp_wifi_init(cfg));
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_set_mode"));
|
||||
TEST_ESP_OK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_set_config"));
|
||||
TEST_ESP_OK(esp_wifi_set_config(ESP_IF_WIFI_STA, wifi_config));
|
||||
//now start wifi
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_start..."));
|
||||
TEST_ESP_OK(esp_wifi_start());
|
||||
//wifi stop
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_stop..."));
|
||||
TEST_ESP_OK( esp_wifi_stop() );
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_wifi_deinit..."));
|
||||
TEST_ESP_OK(esp_wifi_deinit());
|
||||
}
|
||||
|
||||
TEST_CASE("wifi stop and deinit","[wifi]")
|
||||
{
|
||||
test_case_uses_tcpip();
|
||||
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = DEFAULT_SSID,
|
||||
.password = DEFAULT_PWD
|
||||
},
|
||||
};
|
||||
|
||||
//init nvs
|
||||
ESP_LOGI(TAG, EMPH_STR("nvs_flash_init"));
|
||||
esp_err_t r = nvs_flash_init();
|
||||
if (r == ESP_ERR_NVS_NO_FREE_PAGES || r == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_LOGI(TAG, EMPH_STR("no free pages or nvs version mismatch, erase.."));
|
||||
TEST_ESP_OK(nvs_flash_erase());
|
||||
r = nvs_flash_init();
|
||||
}
|
||||
TEST_ESP_OK(r);
|
||||
//init tcpip
|
||||
ESP_LOGI(TAG, EMPH_STR("tcpip_adapter_init"));
|
||||
tcpip_adapter_init();
|
||||
//init event loop
|
||||
ESP_LOGI(TAG, EMPH_STR("esp_event_loop_init"));
|
||||
TEST_ESP_OK(esp_event_loop_init(event_handler, NULL));
|
||||
|
||||
ESP_LOGI(TAG, "test wifi init & deinit...");
|
||||
test_wifi_init_deinit(&cfg, &wifi_config);
|
||||
ESP_LOGI(TAG, "wifi init & deinit seem to be OK.");
|
||||
|
||||
ESP_LOGI(TAG, "test wifi start & stop...");
|
||||
test_wifi_start_stop(&cfg, &wifi_config);
|
||||
ESP_LOGI(TAG, "wifi start & stop seem to be OK.");
|
||||
|
||||
ESP_LOGI(TAG, EMPH_STR("nvs_flash_deinit..."));
|
||||
nvs_flash_deinit();
|
||||
ESP_LOGI(TAG, "test passed...");
|
||||
|
||||
TEST_IGNORE_MESSAGE("this test case is ignored due to the critical memory leak of tcpip_adapter and event_loop.");
|
||||
}
|
||||
|
||||
static void start_wifi_as_softap(void)
|
||||
{
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
cfg.nvs_enable = false;
|
||||
|
||||
wifi_config_t w_config = {
|
||||
.ap.ssid = DEFAULT_SSID,
|
||||
.ap.password = DEFAULT_PWD,
|
||||
.ap.ssid_len = 0,
|
||||
.ap.channel = 1,
|
||||
.ap.authmode = WIFI_AUTH_WPA2_PSK,
|
||||
.ap.ssid_hidden = false,
|
||||
.ap.max_connection = 4,
|
||||
.ap.beacon_interval = 100,
|
||||
};
|
||||
|
||||
TEST_ESP_OK(esp_event_loop_init(event_handler, NULL));
|
||||
|
||||
// can't deinit event loop, need to reset leak check
|
||||
unity_reset_leak_checks();
|
||||
|
||||
if (wifi_events == NULL) {
|
||||
wifi_events = xEventGroupCreate();
|
||||
}
|
||||
|
||||
TEST_ESP_OK(esp_wifi_init(&cfg));
|
||||
TEST_ESP_OK(esp_wifi_set_mode(WIFI_MODE_AP));
|
||||
TEST_ESP_OK(esp_wifi_set_config(WIFI_IF_AP, &w_config));
|
||||
TEST_ESP_OK(esp_wifi_start());
|
||||
}
|
||||
|
||||
static void start_wifi_as_sta(void)
|
||||
{
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
cfg.nvs_enable = false;
|
||||
|
||||
// do not auto connect
|
||||
wifi_event_handler_flag |= EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT;
|
||||
TEST_ESP_OK(esp_event_loop_init(event_handler, NULL));
|
||||
|
||||
// can't deinit event loop, need to reset leak check
|
||||
unity_reset_leak_checks();
|
||||
|
||||
if (wifi_events == NULL) {
|
||||
wifi_events = xEventGroupCreate();
|
||||
} else {
|
||||
xEventGroupClearBits(wifi_events, 0x00ffffff);
|
||||
}
|
||||
|
||||
TEST_ESP_OK(esp_wifi_init(&cfg));
|
||||
TEST_ESP_OK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
TEST_ESP_OK(esp_wifi_start());
|
||||
|
||||
}
|
||||
|
||||
static void stop_wifi(void)
|
||||
{
|
||||
printf("stop wifi\n");
|
||||
TEST_ESP_OK(esp_wifi_stop());
|
||||
TEST_ESP_OK(esp_wifi_deinit());
|
||||
if (wifi_events) {
|
||||
vEventGroupDelete(wifi_events);
|
||||
wifi_events = NULL;
|
||||
}
|
||||
vTaskDelay(1000/portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
static void receive_ds2ds_packet(void)
|
||||
{
|
||||
test_case_uses_tcpip();
|
||||
start_wifi_as_softap();
|
||||
unity_wait_for_signal("sender ready");
|
||||
unity_send_signal("receiver ready");
|
||||
|
||||
// wait for sender to send packets
|
||||
vTaskDelay(1000/portTICK_PERIOD_MS);
|
||||
stop_wifi();
|
||||
}
|
||||
|
||||
static const char ds2ds_pdu[] = {
|
||||
0x48, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xE8, 0x65, 0xD4, 0xCB, 0x74, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x60, 0x94, 0xE8, 0x65, 0xD4, 0xCB, 0x74, 0x1C, 0x26, 0xB9,
|
||||
0x0D, 0x02, 0x7D, 0x13, 0x00, 0x00, 0x01, 0xE8, 0x65, 0xD4, 0xCB, 0x74,
|
||||
0x1C, 0x00, 0x00, 0x26, 0xB9, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static void send_ds2ds_packet(void)
|
||||
{
|
||||
test_case_uses_tcpip();
|
||||
start_wifi_as_softap();
|
||||
unity_send_signal("sender ready");
|
||||
unity_wait_for_signal("receiver ready");
|
||||
|
||||
// send packet 20 times to make sure receiver will get this packet
|
||||
for (uint16_t i = 0; i < 20; i++) {
|
||||
esp_wifi_80211_tx(ESP_IF_WIFI_AP, ds2ds_pdu, sizeof(ds2ds_pdu), true);
|
||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
}
|
||||
stop_wifi();
|
||||
}
|
||||
|
||||
TEST_CASE_MULTIPLE_DEVICES("receive ds2ds packet without exception", "[wifi][test_env=UT_T2_1]", receive_ds2ds_packet, send_ds2ds_packet);
|
||||
|
||||
static void wifi_connect_by_bssid(uint8_t *bssid)
|
||||
{
|
||||
EventBits_t bits;
|
||||
|
||||
wifi_config_t w_config = {
|
||||
.sta.ssid = DEFAULT_SSID,
|
||||
.sta.password = DEFAULT_PWD,
|
||||
.sta.bssid_set = true,
|
||||
};
|
||||
|
||||
memcpy(w_config.sta.bssid, bssid, 6);
|
||||
|
||||
TEST_ESP_OK(esp_wifi_set_config(WIFI_IF_STA, &w_config));
|
||||
TEST_ESP_OK(esp_wifi_connect());
|
||||
bits = xEventGroupWaitBits(wifi_events, GOT_IP_EVENT, 1, 0, 5000/portTICK_RATE_MS);
|
||||
TEST_ASSERT(bits == GOT_IP_EVENT);
|
||||
}
|
||||
|
||||
static void test_wifi_connection_sta(void)
|
||||
{
|
||||
char mac_str[19];
|
||||
uint8_t mac[6];
|
||||
EventBits_t bits;
|
||||
|
||||
test_case_uses_tcpip();
|
||||
|
||||
start_wifi_as_sta();
|
||||
|
||||
unity_wait_for_signal_param("SoftAP mac", mac_str, 19);
|
||||
|
||||
TEST_ASSERT_TRUE(unity_util_convert_mac_from_string(mac_str, mac));
|
||||
|
||||
wifi_connect_by_bssid(mac);
|
||||
|
||||
unity_send_signal("STA connected");
|
||||
|
||||
bits = xEventGroupWaitBits(wifi_events, DISCONNECT_EVENT, 1, 0, 60000 / portTICK_RATE_MS);
|
||||
// disconnect event not triggered
|
||||
printf("wait finish\n");
|
||||
TEST_ASSERT(bits == 0);
|
||||
|
||||
stop_wifi();
|
||||
}
|
||||
|
||||
static void test_wifi_connection_softap(void)
|
||||
{
|
||||
char mac_str[19] = {0};
|
||||
uint8_t mac[6];
|
||||
|
||||
test_case_uses_tcpip();
|
||||
|
||||
start_wifi_as_softap();
|
||||
|
||||
TEST_ESP_OK(esp_wifi_get_mac(ESP_IF_WIFI_AP, mac));
|
||||
sprintf(mac_str, MACSTR, MAC2STR(mac));
|
||||
|
||||
unity_send_signal_param("SoftAP mac", mac_str);
|
||||
|
||||
unity_wait_for_signal("STA connected");
|
||||
|
||||
vTaskDelay(60000 / portTICK_PERIOD_MS);
|
||||
|
||||
stop_wifi();
|
||||
}
|
||||
|
||||
TEST_CASE_MULTIPLE_DEVICES("test wifi retain connection for 60s", "[wifi][test_env=UT_T2_1][timeout=90]", test_wifi_connection_sta, test_wifi_connection_softap);
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
Tests for the Wi-Fi
|
||||
*/
|
||||
#include "unity.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi_internal.h"
|
||||
|
||||
TEST_CASE("wifi lib git commit id","[wifi]")
|
||||
{
|
||||
TEST_ESP_OK( esp_wifi_internal_git_commit_id_check() );
|
||||
}
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <esp_event.h>
|
||||
#include <esp_wifi.h>
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi_internal.h"
|
||||
#include "esp_pm.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "esp_mesh.h"
|
||||
|
||||
/* mesh event callback handler */
|
||||
mesh_event_cb_t g_mesh_event_cb = NULL;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static esp_pm_lock_handle_t s_wifi_modem_sleep_lock;
|
||||
#endif
|
||||
|
||||
/* Callback function to update WiFi MAC time */
|
||||
wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb = NULL;
|
||||
|
||||
static void __attribute__((constructor)) s_set_default_wifi_log_level()
|
||||
{
|
||||
/* WiFi libraries aren't compiled to know CONFIG_LOG_DEFAULT_LEVEL,
|
||||
so set it at runtime startup. Done here not in esp_wifi_init() to allow
|
||||
the user to set the level again before esp_wifi_init() is called.
|
||||
*/
|
||||
esp_log_level_set("wifi", CONFIG_LOG_DEFAULT_LEVEL);
|
||||
esp_log_level_set("mesh", CONFIG_LOG_DEFAULT_LEVEL);
|
||||
}
|
||||
|
||||
static void esp_wifi_set_debug_log()
|
||||
{
|
||||
/* set WiFi log level and module */
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE
|
||||
uint32_t g_wifi_log_level = WIFI_LOG_INFO;
|
||||
uint32_t g_wifi_log_module = 0;
|
||||
uint32_t g_wifi_log_submodule = 0;
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_DEBUG
|
||||
g_wifi_log_level = WIFI_LOG_DEBUG;
|
||||
#endif
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_VERBOSE
|
||||
g_wifi_log_level = WIFI_LOG_VERBOSE;
|
||||
#endif
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_ALL
|
||||
g_wifi_log_module = WIFI_LOG_MODULE_ALL;
|
||||
#endif
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_WIFI
|
||||
g_wifi_log_module = WIFI_LOG_MODULE_WIFI;
|
||||
#endif
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_COEX
|
||||
g_wifi_log_module = WIFI_LOG_MODULE_COEX;
|
||||
#endif
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_MESH
|
||||
g_wifi_log_module = WIFI_LOG_MODULE_MESH;
|
||||
#endif
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE_ALL
|
||||
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_ALL;
|
||||
#endif
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE_INIT
|
||||
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_INIT;
|
||||
#endif
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE_IOCTL
|
||||
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_IOCTL;
|
||||
#endif
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE_CONN
|
||||
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_CONN;
|
||||
#endif
|
||||
#if CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE_SCAN
|
||||
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_SCAN;
|
||||
#endif
|
||||
esp_wifi_internal_set_log_level(g_wifi_log_level);
|
||||
esp_wifi_internal_set_log_mod(g_wifi_log_module, g_wifi_log_submodule, true);
|
||||
|
||||
#endif /* CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE*/
|
||||
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_init(const wifi_init_config_t *config)
|
||||
{
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_wifi_modem_sleep_lock == NULL) {
|
||||
esp_err_t err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "wifi",
|
||||
&s_wifi_modem_sleep_lock);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
esp_event_set_default_wifi_handlers();
|
||||
esp_err_t result = esp_wifi_init_internal(config);
|
||||
if (result == ESP_OK) {
|
||||
esp_wifi_set_debug_log();
|
||||
s_wifi_mac_time_update_cb = esp_wifi_internal_update_mac_time;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
void wifi_apb80m_request(void)
|
||||
{
|
||||
assert(s_wifi_modem_sleep_lock);
|
||||
esp_pm_lock_acquire(s_wifi_modem_sleep_lock);
|
||||
if (rtc_clk_apb_freq_get() != APB_CLK_FREQ) {
|
||||
ESP_LOGE(__func__, "WiFi needs 80MHz APB frequency to work, but got %dHz", rtc_clk_apb_freq_get());
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_apb80m_release(void)
|
||||
{
|
||||
assert(s_wifi_modem_sleep_lock);
|
||||
esp_pm_lock_release(s_wifi_modem_sleep_lock);
|
||||
}
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
Reference in New Issue
Block a user