diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 21997d424..fd4467ba1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1237,6 +1237,12 @@ UT_001_41: - ESP32_IDF - UT_T1_1 +UT_001_42: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_1 + UT_002_01: <<: *unit_test_template tags: diff --git a/components/esp32/esp_err_to_name.c b/components/esp32/esp_err_to_name.c index dd1b81614..4182d3630 100644 --- a/components/esp32/esp_err_to_name.c +++ b/components/esp32/esp_err_to_name.c @@ -285,6 +285,15 @@ static const esp_err_msg_t esp_err_msg_table[] = { # endif # ifdef ESP_ERR_WIFI_NOT_CONNECT ERR_TBL_IT(ESP_ERR_WIFI_NOT_CONNECT), /* 12303 0x300f Station still in disconnect status */ +# endif +# ifdef ESP_ERR_WIFI_POST + ERR_TBL_IT(ESP_ERR_WIFI_POST), /* 12306 0x3012 Failed to post the event to WiFi task */ +# endif +# ifdef ESP_ERR_WIFI_INIT_STATE + ERR_TBL_IT(ESP_ERR_WIFI_INIT_STATE), /* 12307 0x3013 Invalod WiFi state when init/deinit is called */ +# endif +# ifdef ESP_ERR_WIFI_STOP_STATE + ERR_TBL_IT(ESP_ERR_WIFI_STOP_STATE), /* 12308 0x3014 Returned when WiFi is stopping */ # endif // components/esp32/include/esp_wps.h # ifdef ESP_ERR_WIFI_REGISTRAR diff --git a/components/esp32/event_default_handlers.c b/components/esp32/event_default_handlers.c index 8a397a345..10c4616d9 100644 --- a/components/esp32/event_default_handlers.c +++ b/components/esp32/event_default_handlers.c @@ -314,6 +314,10 @@ static esp_err_t esp_system_event_debug(system_event_t *event) ESP_LOGD(TAG, "SYSTEM_EVENT_STA_WPS_ER_PIN"); break; } + case SYSTEM_EVENT_STA_WPS_ER_PBC_OVERLAP: { + ESP_LOGD(TAG, "SYSTEM_EVENT_STA_WPS_ER_PBC_OVERLAP"); + break; + } case SYSTEM_EVENT_AP_START: { ESP_LOGD(TAG, "SYSTEM_EVENT_AP_START"); break; diff --git a/components/esp32/include/esp_event_legacy.h b/components/esp32/include/esp_event_legacy.h index 3bb2a77b9..a25188418 100644 --- a/components/esp32/include/esp_event_legacy.h +++ b/components/esp32/include/esp_event_legacy.h @@ -40,6 +40,7 @@ typedef enum { SYSTEM_EVENT_STA_WPS_ER_FAILED, /**< ESP32 station wps fails in enrollee mode */ SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, /**< ESP32 station wps timeout in enrollee mode */ SYSTEM_EVENT_STA_WPS_ER_PIN, /**< ESP32 station wps pin code in enrollee mode */ + SYSTEM_EVENT_STA_WPS_ER_PBC_OVERLAP, /*!< ESP32 station wps overlap in enrollee mode */ SYSTEM_EVENT_AP_START, /**< ESP32 soft-AP start */ SYSTEM_EVENT_AP_STOP, /**< ESP32 soft-AP stop */ SYSTEM_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */ diff --git a/components/esp32/include/esp_private/esp_wifi_private.h b/components/esp32/include/esp_private/esp_wifi_private.h new file mode 100644 index 000000000..fcdebb6ba --- /dev/null +++ b/components/esp32/include/esp_private/esp_wifi_private.h @@ -0,0 +1,24 @@ +// Copyright 2015-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_WIFI_PRIVATE_H +#define _ESP_WIFI_PRIVATE_H + +#include "freertos/FreeRTOS.h" +#include "freertos/queue.h" +#include "rom/queue.h" +#include "sdkconfig.h" +#include "esp_wifi_crypto_types.h" +#include "esp_wifi_os_adapter.h" + +#endif /* _ESP_WIFI_PRIVATE_H */ diff --git a/components/esp32/include/esp_private/esp_wifi_types_private.h b/components/esp32/include/esp_private/esp_wifi_types_private.h new file mode 100644 index 000000000..dd56e0fde --- /dev/null +++ b/components/esp32/include/esp_private/esp_wifi_types_private.h @@ -0,0 +1,21 @@ +// Copyright 2015-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_WIFI_TYPES_PRIVATE_H +#define _ESP_WIFI_TYPES_PRIVATE_H + +#include "rom/queue.h" +#include "esp_interface.h" + +#endif diff --git a/components/esp32/include/esp_wifi.h b/components/esp32/include/esp_wifi.h index e67f4606b..57014b8d9 100644 --- a/components/esp32/include/esp_wifi.h +++ b/components/esp32/include/esp_wifi.h @@ -59,15 +59,10 @@ #include #include -#include "freertos/FreeRTOS.h" -#include "freertos/queue.h" -#include "rom/queue.h" -#include "sdkconfig.h" #include "esp_err.h" #include "esp_wifi_types.h" -#include "esp_wifi_crypto_types.h" #include "esp_event.h" -#include "esp_wifi_os_adapter.h" +#include "esp_private/esp_wifi_private.h" #ifdef __cplusplus extern "C" { @@ -89,6 +84,10 @@ extern "C" { #define ESP_ERR_WIFI_WOULD_BLOCK (ESP_ERR_WIFI_BASE + 14) /*!< The caller would block */ #define ESP_ERR_WIFI_NOT_CONNECT (ESP_ERR_WIFI_BASE + 15) /*!< Station still in disconnect status */ +#define ESP_ERR_WIFI_POST (ESP_ERR_WIFI_BASE + 18) /*!< Failed to post the event to WiFi task */ +#define ESP_ERR_WIFI_INIT_STATE (ESP_ERR_WIFI_BASE + 19) /*!< Invalod WiFi state when init/deinit is called */ +#define ESP_ERR_WIFI_STOP_STATE (ESP_ERR_WIFI_BASE + 20) /*!< Returned when WiFi is stopping */ + /** * @brief WiFi stack configuration parameters passed to esp_wifi_init call. */ @@ -581,7 +580,7 @@ esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second); * and the country info of the AP to which the station is connected is {.cc="JP", .schan=1, .nchan=14} * then the country info that will be used is {.cc="JP", .schan=1, .nchan=14}. If the station disconnected * from the AP the country info is set back back to the country info of the station automatically, - * {.cc="USA", .schan=1, .nchan=11} in the example. + * {.cc="US", .schan=1, .nchan=11} in the example. * @attention 3. When the country policy is WIFI_COUNTRY_POLICY_MANUAL, always use the configured country info. * @attention 4. When the country info is changed because of configuration or because the station connects to a different * external AP, the country IE in probe response/beacon of the soft-AP is changed also. @@ -840,6 +839,16 @@ esp_err_t esp_wifi_set_auto_connect(bool en) __attribute__ ((deprecated)); */ esp_err_t esp_wifi_get_auto_connect(bool *en) __attribute__ ((deprecated)); +/** + * @brief Function signature for received Vendor-Specific Information Element callback. + * @param ctx Context argument, as passed to esp_wifi_set_vendor_ie_cb() when registering callback. + * @param type Information element type, based on frame type received. + * @param sa Source 802.11 address. + * @param vnd_ie Pointer to the vendor specific element data received. + * @param rssi Received signal strength indication. + */ +typedef void (*esp_vendor_ie_cb_t) (void *ctx, wifi_vendor_ie_type_t type, const uint8_t sa[6], const vendor_ie_data_t *vnd_ie, int rssi); + /** * @brief Set 802.11 Vendor-Specific Information Element * @@ -858,16 +867,6 @@ esp_err_t esp_wifi_get_auto_connect(bool *en) __attribute__ ((deprecated)); */ esp_err_t esp_wifi_set_vendor_ie(bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie); -/** - * @brief Function signature for received Vendor-Specific Information Element callback. - * @param ctx Context argument, as passed to esp_wifi_set_vendor_ie_cb() when registering callback. - * @param type Information element type, based on frame type received. - * @param sa Source 802.11 address. - * @param vnd_ie Pointer to the vendor specific element data received. - * @param rssi Received signal strength indication. - */ -typedef void (*esp_vendor_ie_cb_t) (void *ctx, wifi_vendor_ie_type_t type, const uint8_t sa[6], const vendor_ie_data_t *vnd_ie, int rssi); - /** * @brief Register Vendor-Specific Information Element monitoring callback. * @@ -881,60 +880,22 @@ typedef void (*esp_vendor_ie_cb_t) (void *ctx, wifi_vendor_ie_type_t type, const esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx); /** - * @brief Set maximum WiFi transmiting power + * @brief Set maximum WiFi transmitting power * - * @attention WiFi transmiting power is divided to six levels in phy init data. - * Level0 represents highest transmiting power and level5 represents lowest - * transmiting power. Packets of different rates are transmitted in - * different powers according to the configuration in phy init data. - * This API only sets maximum WiFi transmiting power. If this API is called, - * the transmiting power of every packet will be less than or equal to the - * value set by this API. If this API is not called, the value of maximum - * transmitting power set in phy_init_data.bin or menuconfig (depend on - * whether to use phy init data in partition or not) will be used. Default - * value is level0. Values passed in power are mapped to transmit power - * levels as follows: - * - [78, 127]: level0 - * - [76, 77]: level1 - * - [74, 75]: level2 - * - [68, 73]: level3 - * - [60, 67]: level4 - * - [52, 59]: level5 - * - [44, 51]: level5 - 2dBm - * - [34, 43]: level5 - 4.5dBm - * - [28, 33]: level5 - 6dBm - * - [20, 27]: level5 - 8dBm - * - [8, 19]: level5 - 11dBm - * - [-128, 7]: level5 - 14dBm - * - * @param power Maximum WiFi transmiting power. + * @param power Maximum WiFi transmitting power, unit is 0.25dBm, range is [40, 82] corresponding to 10dBm - 20.5dBm here. * * @return * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start + * - ESP_ERR_WIFI_NOT_ARG: invalid argument */ esp_err_t esp_wifi_set_max_tx_power(int8_t power); /** * @brief Get maximum WiFi transmiting power * - * @attention This API gets maximum WiFi transmiting power. Values got - * from power are mapped to transmit power levels as follows: - * - 78: 19.5dBm - * - 76: 19dBm - * - 74: 18.5dBm - * - 68: 17dBm - * - 60: 15dBm - * - 52: 13dBm - * - 44: 11dBm - * - 34: 8.5dBm - * - 28: 7dBm - * - 20: 5dBm - * - 8: 2dBm - * - -4: -1dBm - * - * @param power Maximum WiFi transmiting power. + * @param power Maximum WiFi transmitting power, unit is 0.25dBm. * * @return * - ESP_OK: succeed @@ -1102,19 +1063,6 @@ esp_err_t esp_wifi_set_ant(const wifi_ant_config_t *config); */ esp_err_t esp_wifi_get_ant(wifi_ant_config_t *config); -/** - * @brief A general API to set/get WiFi internal configuration, it's for debug only - * - * @param cmd : ioctl command type - * @param cfg : configuration for the command - * - * @return - * - ESP_OK: succeed - * - others: failed - */ -esp_err_t esp_wifi_internal_ioctl(int cmd, wifi_ioctl_config_t *cfg); - - #ifdef __cplusplus } #endif diff --git a/components/esp32/include/esp_wifi_internal.h b/components/esp32/include/esp_wifi_internal.h index 252f5a27c..7bec24864 100644 --- a/components/esp32/include/esp_wifi_internal.h +++ b/components/esp32/include/esp_wifi_internal.h @@ -170,15 +170,26 @@ esp_err_t esp_wifi_internal_osi_funcs_md5_check(const char *md5); esp_err_t esp_wifi_internal_crypto_funcs_md5_check(const char *md5); /** - * @brief Check the git commit id of WiFi library + * @brief Check the MD5 values of the esp_wifi_types.h in IDF and WiFi library * - * @attention 1. It is used for internal CI WiFi library check + * @attention 1. It is used for internal CI version check * * @return * - ESP_OK : succeed - * - ESP_FAIL : fail + * - ESP_WIFI_INVALID_ARG : MD5 check fail */ -esp_err_t esp_wifi_internal_git_commit_id_check(void); +esp_err_t esp_wifi_internal_wifi_type_md5_check(const char *md5); + +/** + * @brief Check the MD5 values of the esp_wifi.h 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_esp_wifi_md5_check(const char *md5); /** * @brief Allocate a chunk of memory for WiFi driver diff --git a/components/esp32/include/esp_wifi_types.h b/components/esp32/include/esp_wifi_types.h index cfe45ac6c..3f6eccde0 100644 --- a/components/esp32/include/esp_wifi_types.h +++ b/components/esp32/include/esp_wifi_types.h @@ -18,9 +18,8 @@ #include #include -#include "rom/queue.h" #include "esp_err.h" -#include "esp_interface.h" +#include "esp_private/esp_wifi_types_private.h" #ifdef __cplusplus extern "C" { @@ -49,7 +48,7 @@ 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 */ + int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */ wifi_country_policy_t policy; /**< country policy */ } wifi_country_t; diff --git a/components/esp32/lib b/components/esp32/lib index 2234fe822..222fa5b24 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit 2234fe822782ec9b69c2dd704d7ada7e621bafad +Subproject commit 222fa5b24fa8bf698c6afd494272e8e5aeffbfe8 diff --git a/components/esp32/test/CMakeLists.txt b/components/esp32/test/CMakeLists.txt index f62b94687..0beee4041 100644 --- a/components/esp32/test/CMakeLists.txt +++ b/components/esp32/test/CMakeLists.txt @@ -28,10 +28,24 @@ execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_coexist_ OUTPUT_VARIABLE COEX_ADAPTER_MD5 OUTPUT_STRIP_TRAILING_WHITESPACE) +# Calculate MD5 value of header file esp_wifi_types.h +execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi_types.h + COMMAND cut -c 1-7 + OUTPUT_VARIABLE WIFI_TYPE_MD5 + OUTPUT_STRIP_TRAILING_WHITESPACE) + +# Calculate MD5 value of header file esp_wifi.h +execute_process(COMMAND md5sum ${IDF_PATH}/components/esp32/include/esp_wifi.h + COMMAND cut -c 1-7 + OUTPUT_VARIABLE WIFI_ESP_WIFI_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_definitions(-DWIFI_TYPE_MD5=\"${WIFI_TYPE_MD5}\") +add_definitions(-DWIFI_ESP_WIFI_MD5=\"${WIFI_ESP_WIFI_MD5}\") add_custom_target(esp32_test_logo DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h") -add_dependencies(${COMPONENT_NAME} esp32_test_logo) \ No newline at end of file +add_dependencies(${COMPONENT_NAME} esp32_test_logo) diff --git a/components/esp32/test/component.mk b/components/esp32/test/component.mk index f2deeb555..c35427b3f 100644 --- a/components/esp32/test/component.mk +++ b/components/esp32/test/component.mk @@ -20,6 +20,16 @@ CFLAGS+=-DWIFI_CRYPTO_MD5=$(WIFI_CRYPTO_MD5_VAL) 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) +# Calculate MD5 value of header file esp_wifi_types.h +WIFI_TYPE_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_wifi_types.h | cut -c 1-7)\" +CFLAGS+=-DWIFI_TYPE_MD5=$(WIFI_TYPE_MD5_VAL) + + +# Calculate MD5 value of header file esp_wifi.h +WIFI_ESP_WIFI_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_wifi.h | cut -c 1-7)\" +CFLAGS+=-DWIFI_ESP_WIFI_MD5=$(WIFI_ESP_WIFI_MD5_VAL) + + test_tjpgd.o: test_tjpgd_logo.h test_tjpgd_logo.h: $(COMPONENT_PATH)/logo.jpg diff --git a/components/esp32/test/test_header_files_md5.c b/components/esp32/test/test_header_files_md5.c index c2d80350a..a958e049c 100644 --- a/components/esp32/test/test_header_files_md5.c +++ b/components/esp32/test/test_header_files_md5.c @@ -12,7 +12,7 @@ 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..."); + ESP_LOGI(TAG, "test eps_wifi_os_adapter.h MD5..."); TEST_ESP_OK(esp_wifi_internal_osi_funcs_md5_check(test_wifi_os_funcs_md5)); ESP_LOGI(TAG, "test passed..."); @@ -22,13 +22,13 @@ 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..."); + ESP_LOGI(TAG, "test esp_wifi_crypto_adapter.h 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]") +TEST_CASE("coexist esp_coexist_adapter.h MD5","[coex]") { const char *test_coex_adapter_funcs_md5 = COEX_ADAPTER_MD5; @@ -37,3 +37,23 @@ TEST_CASE("coexist adapter MD5","[coex]") ESP_LOGI(TAG, "test passed..."); } + +TEST_CASE("wifi type MD5","[wifi]") +{ + const char *test_wifi_type_md5 = WIFI_TYPE_MD5; + + ESP_LOGI(TAG, "test esp_wifi_types.h MD5..."); + TEST_ESP_OK(esp_wifi_internal_wifi_type_md5_check(test_wifi_type_md5)); + + ESP_LOGI(TAG, "test passed..."); +} + +TEST_CASE("esp wifi MD5","[wifi]") +{ + const char *test_esp_wifi_md5 = WIFI_ESP_WIFI_MD5; + + ESP_LOGI(TAG, "test esp_wifi.h MD5..."); + TEST_ESP_OK(esp_wifi_internal_esp_wifi_md5_check(test_esp_wifi_md5)); + + ESP_LOGI(TAG, "test passed..."); +} diff --git a/components/esp32/test/test_wifi_lib_git_commit.c b/components/esp32/test/test_wifi_lib_git_commit.c deleted file mode 100644 index 8b5633f9b..000000000 --- a/components/esp32/test/test_wifi_lib_git_commit.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - Tests for the Wi-Fi -*/ -#include "unity.h" -#include "esp_log.h" -#include "esp_wifi_internal.h" - -static const char* TAG = "test_wifi_lib_git_commit_id"; - -TEST_CASE("wifi lib git commit id","[wifi]") -{ - TEST_ESP_OK( esp_wifi_internal_git_commit_id_check() ); -} - diff --git a/components/wpa_supplicant/include/wpa2/eap_peer/eap_i.h b/components/wpa_supplicant/include/wpa2/eap_peer/eap_i.h index 6204f4653..6adf5ec7e 100644 --- a/components/wpa_supplicant/include/wpa2/eap_peer/eap_i.h +++ b/components/wpa_supplicant/include/wpa2/eap_peer/eap_i.h @@ -98,6 +98,13 @@ struct eap_method { #define BLOB_NAME_LEN 3 #define BLOB_NUM 3 +enum SIG_WPA2 { + SIG_WPA2_START = 0, + SIG_WPA2_RX, + SIG_WPA2_TASK_DEL, + SIG_WPA2_MAX, +}; + /** * struct eap_sm - EAP state machine data */ @@ -114,8 +121,7 @@ struct eap_sm { u8 current_identifier; u8 ownaddr[ETH_ALEN]; #ifdef USE_WPA2_TASK -#define SIG_WPA2_NUM 2 - u8 wpa2_sig_cnt[SIG_WPA2_NUM]; + u8 wpa2_sig_cnt[SIG_WPA2_MAX]; #endif u8 finish_state; diff --git a/components/wpa_supplicant/include/wps/wps.h b/components/wpa_supplicant/include/wps/wps.h index b731b9b95..31092cbb8 100644 --- a/components/wpa_supplicant/include/wps/wps.h +++ b/components/wpa_supplicant/include/wps/wps.h @@ -1009,9 +1009,9 @@ enum wps_cb_status { typedef void (*wps_st_cb_t)(int status); #ifdef USE_WPS_TASK -#define SIG_WPS_START 0 -#define SIG_WPS_RX 1 -#define SIG_WPS_NUM 2 +#define SIG_WPS_START 2 +#define SIG_WPS_RX 3 +#define SIG_WPS_NUM 9 #endif #define WPS_EAP_EXT_VENDOR_TYPE "WFA-SimpleConfig-Enrollee-1-0"