Merge branch 'bugfix/fix_some_wifi_bugs_1019_v4.2' into 'release/v4.2'

esp_wifi: fix some wifi bugs(Backport v4.2)

See merge request espressif/esp-idf!20729
This commit is contained in:
Jiang Jiang Jian 2022-10-24 12:25:27 +08:00
commit 509e708a96
5 changed files with 117 additions and 108 deletions

View File

@ -641,6 +641,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._dport_access_stall_other_cpu_end_wrap = esp_empty_wrapper,
._phy_disable = esp_phy_disable,
._phy_enable = esp_phy_enable,
._phy_common_clock_enable = esp_phy_common_clock_enable,
._phy_common_clock_disable = esp_phy_common_clock_disable,
._phy_update_country_info = esp_phy_update_country_info,
._read_mac = esp_read_mac,
._timer_arm = timer_arm_wrapper,

View File

@ -80,7 +80,7 @@ typedef struct {
void (* _dport_access_stall_other_cpu_end_wrap)(void);
void (* _phy_disable)(void);
void (* _phy_enable)(void);
#if CONFIG_IDF_TARGET_ESP32
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
void (* _phy_common_clock_enable)(void);
void (* _phy_common_clock_disable)(void);
#endif

View File

@ -329,7 +329,7 @@ esp_err_t esp_wifi_restore(void);
*
* @attention 1. This API only impact WIFI_MODE_STA or WIFI_MODE_APSTA mode
* @attention 2. If the ESP32 is connected to an AP, call esp_wifi_disconnect to disconnect.
* @attention 3. The scanning triggered by esp_wifi_start_scan() will not be effective until connection between ESP32 and the AP is established.
* @attention 3. The scanning triggered by esp_wifi_scan_start() will not be effective until connection between ESP32 and the AP is established.
* If ESP32 is scanning and connecting at the same time, ESP32 will abort scanning and return a warning message and error
* number ESP_ERR_WIFI_STATE.
* If you want to do reconnection after ESP32 received disconnect event, remember to add the maximum retry time, otherwise the called
@ -587,20 +587,21 @@ esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second);
/**
* @brief configure country info
*
* @attention 1. The default country is {.cc="CN", .schan=1, .nchan=13, policy=WIFI_COUNTRY_POLICY_AUTO}
* @attention 2. When the country policy is WIFI_COUNTRY_POLICY_AUTO, the country info of the AP to which
* the station is connected is used. E.g. if the configured country info is {.cc="USA", .schan=1, .nchan=11}
* @attention 1. The default country is CHINA {.cc="CN", .schan=1, .nchan=13, .policy=WIFI_COUNTRY_POLICY_AUTO}.
* @attention 2. The third octect of country code string is one of the following: ' ', 'O', 'I', 'X', otherwise it is considered as ' '.
* @attention 3. When the country policy is WIFI_COUNTRY_POLICY_AUTO, the country info of the AP to which
* the station is connected is used. E.g. if the configured country info is {.cc="US", .schan=1, .nchan=11}
* 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,
* from the AP the country info is set back to the country info of the station automatically,
* {.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.
* @attention 5. The country configuration is stored into flash.
* @attention 6. This API doesn't validate the per-country rules, it's up to the user to fill in all fields according to
* @attention 4. When the country policy is WIFI_COUNTRY_POLICY_MANUAL, then the configured country info is used always.
* @attention 5. 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 also changed.
* @attention 6. The country configuration is stored into flash.
* @attention 7. This API doesn't validate the per-country rules, it's up to the user to fill in all fields according to
* local regulations.
* @attention 7. When this API is called, the PHY init data will switch to the PHY init data type corresponding to the
* @attention 8. When this API is called, the PHY init data will switch to the PHY init data type corresponding to the
* country info.
*
* @param country the configured country info
@ -898,7 +899,7 @@ esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx);
* @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_STARTED: WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_ARG: invalid argument, e.g. parameter is out of range
*/
esp_err_t esp_wifi_set_max_tx_power(int8_t power);
@ -911,7 +912,7 @@ esp_err_t esp_wifi_set_max_tx_power(int8_t power);
* @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_STARTED: WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_ARG: invalid argument
*/
esp_err_t esp_wifi_get_max_tx_power(int8_t *power);
@ -1007,7 +1008,7 @@ esp_err_t esp_wifi_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx);
* 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 or promiscuous mode is not enabled
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled
* - ESP_ERR_INVALID_ARG: invalid argument
*/
esp_err_t esp_wifi_set_csi_config(const wifi_csi_config_t *config);
@ -1020,7 +1021,7 @@ esp_err_t esp_wifi_set_csi_config(const wifi_csi_config_t *config);
* 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 or promiscuous mode is not enabled
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled
* - ESP_ERR_INVALID_ARG: invalid argument
*/
esp_err_t esp_wifi_set_csi(bool en);

@ -1 +1 @@
Subproject commit 92930748f57dfd8facd49fd50730efa6fd40e55d
Subproject commit e4b797d71045cf0c582f91eb7314869443fd98fa

View File

@ -1290,105 +1290,111 @@ When to Use LR
*************************
The general conditions for using LR are:
- Both the AP and station are devices.
- Long distance WiFi connection and data transmission is required.
- Both the AP and station are Espressif devices.
- Long distance Wi-Fi connection and data transmission is required.
- Data throughput requirements are very small, such as remote device control, etc.
Wi-Fi Country Code
+++++++++++++++++++++++++
Call esp_wifi_set_country() to set the country info.
The table below describes the fields in detail, please consult local 2.4GHz RF operating regulations before configuring these fields.
Call :cpp:func:`esp_wifi_set_country()` to set the country info. The table below describes the fields in detail, please consult local 2.4 GHz RF operating regulations before configuring these fields.
+------------------+-----------------------------------------------------------------------------------+
| Field | Description |
+==================+===================================================================================+
| cc[3] | Country code string, this attributes identify the country or noncountry entity |
| | in which the station/AP is operating. If it's a country, the first two |
| | octets of this string is the two character country info as described in document |
| | ISO/IEC3166-1. The third octect is one of the following: |
| | |
| | - an ASCII space character, if the regulations under which the station/AP is |
| | operating encompass all environments for the current frequency band in the |
| | country |
| | - an ASCII 'O' character if the regulations under which the station/AP is |
| | operating are for an outdoor environment only, or |
| | - an ASCII 'I' character if the regulations under which the station/AP is |
| | operating are for an indoor environment only. |
| | - an ASCII 'X' character if the station/AP is operating under a noncountry |
| | entity. The first two octets of the noncountry entity is two ASSCII 'XX' |
| | characters. |
| | - the binary representation of the Operating Class table number currently in use.|
| | Refer 802.11-2012 Annex E. |
| | |
+------------------+-----------------------------------------------------------------------------------+
| schan | Start channel, it's the minimum channel number of the regulations under which the |
| | station/AP can operate. |
| | |
+------------------+-----------------------------------------------------------------------------------+
| snum | Total channel number of the regulations, e.g. if the schan=1, nchan=13, it means |
| | the station/AP can send data from channel 1 to 13. |
| | |
+------------------+-----------------------------------------------------------------------------------+
| policy | Country policy, this field control which country info will be used if the |
| | configured country info is conflict with the connected AP's. More description |
| | about policy is provided in following section. |
| | |
+------------------+-----------------------------------------------------------------------------------+
.. list-table::
:header-rows: 1
:widths: 15 55
The default country info is {.cc="CN", .schan=1, .nchan=13, policy=WIFI_COUNTRY_POLICY_AUTO}, if the WiFi Mode is station/AP coexist mode, they share the same configured country info. Sometimes, the country info of AP, to which the station is connected, is different from the country info of configured. For example, the configured station has country info {.cc="JP", .schan=1, .nchan=14, policy=WIFI_COUNTRY_POLICY_AUTO}, but the connected AP has country info {.cc="CN", .schan=1, .nchan=13}, then country info of connected AP's is used.
Following table depicts which country info is used in different WiFi Mode and different country policy, also describe the impact to active scan.
* - Field
- Description
* - cc[3]
- Country code string, this attributes identify the country or noncountry entity in which the station/AP is operating. If its a country, the first two octets of this string is the two character country info as described in document ISO/IEC3166-1. The third octect is one of the following:
- an ASCII space character, if the regulations under which the station/AP is operating encompass all environments for the current frequency band in the country.
- an ASCII O character if the regulations under which the station/AP is operating are for an outdoor environment only.
- an ASCII I character if the regulations under which the station/AP is operating are for an indoor environment only.
- an ASCII X character if the station/AP is operating under a noncountry entity. The first two octets of the noncountry entity is two ASCII XX characters.
- the binary representation of the Operating Class table number currently in use. Refer to Annex E, IEEE Std 802.11-2020.
* - schan
- Start channel, its the minimum channel number of the regulations under which the station/AP can operate.
* - nchan
- Total number of channels as per the regulations, e.g. if the schan=1, nchan=13, it means the station/AP can send data from channel 1 to 13.
* - policy
- Country policy, this field control which country info will be used if the configured country info is conflict with the connected APs. More description about policy is provided in following section.
The default country info is::
wifi_country_t config = {
.cc = "CN",
.schan = 1,
.nchan = 13,
.policy = WIFI_COUNTRY_POLICY_AUTO,
};
If the Wi-Fi Mode is station/AP coexist mode, they share the same configured country info. Sometimes, the country info of AP, to which the station is connected, is different from the country info of configured. For example, the configured station has country info::
wifi_country_t config = {
.cc = "JP",
.schan = 1,
.nchan = 14,
.policy = WIFI_COUNTRY_POLICY_AUTO,
};
but the connected AP has country info::
wifi_country_t config = {
.cc = "CN",
.schan = 1,
.nchan = 13,
};
then country info of connected AP's is used.
Following table depicts which country info is used in different Wi-Fi Mode and different country policy, also describe the impact to active scan.
.. list-table::
:header-rows: 1
:widths: 15 15 35
* - Wi-Fi Mode
- Policy
- Description
* - Station
- WIFI_COUNTRY_POLICY_AUTO
- If the connected AP has country IE in its beacon, the country info equals to the country info in beacon. Otherwise, use the default country info.
For scan:
Use active scan from 1 to 11 and use passive scan from 12 to 14.
Always keep in mind that if an AP with hidden SSID and station is set to a passive scan channel, the passive scan will not find it. In other words, if the application hopes to find the AP with hidden SSID in every channel, the policy of country info should be configured to WIFI_COUNTRY_POLICY_MANUAL.
* - Station
- WIFI_COUNTRY_POLICY_MANUAL
- Always use the configured country info.
For scan:
Use active scan from schan to schan+nchan-1.
* - AP
- WIFI_COUNTRY_POLICY_AUTO
- Always use the configured country info.
* - AP
- WIFI_COUNTRY_POLICY_MANUAL
- Always use the configured country info.
* - Station/AP-coexistence
- WIFI_COUNTRY_POLICY_AUTO
- Station: Same as station mode with policy WIFI_COUNTRY_POLICY_AUTO.
AP: If the station does not connect to any external AP, the AP uses the configured country info. If the station connects to an external AP, the AP has the same country info as the station.
* - Station/AP-coexistence
- WIFI_COUNTRY_POLICY_MANUAL
- Station: Same as station mode with policy WIFI_COUNTRY_POLICY_MANUAL.
AP: Same as AP mode with policy WIFI_COUNTRY_POLICY_MANUAL.
+-----------+----------------------------+----------------------------------------------------------------+
| WiFi Mode | Policy | Description |
+===========+============================+================================================================+
| Station | WIFI_COUNTRY_POLICY_AUTO | If the connected AP has country IE in its beacon, the country |
| | | info equals to the country info in beacon, otherwise, use |
| | | default country info. |
| | | |
| | | For scan: |
| | | |
| | | - before the station connects to the AP, scans channel |
| | | "schan" to "min(11, schan+nchan-1)" with active scan and |
| | | channel min(12, schan+nchan)" to 14 with passive scan. |
| | | E.g. if the used country info is |
| | | {.cc="CN", .schan=1, .nchan=6} then 1 to 6 is active scan |
| | | and 7 to 14 is passive scan |
| | | If the used country info is |
| | | {.cc="CN", .schan=1, .nchan=12} then 1 to 11 is active scan |
| | | and 12 to 14 is passive scan |
| | | |
| | | - after the station connects to the AP, scans channel |
| | | "schan" to "schan+nchan-1" with active scan and channel |
| | | "schan+nchan" to 14 with passive scan |
| | | |
| | | Always keep in mind that if if a AP with with hidden SSID |
| | | is set to a passive scan channel, the passive scan will not |
| | | find it. In other words, if the application hopes to find the |
| | | AP with hidden SSID in every channel, the policy of |
| | | country info should be configured to |
| | | WIFI_COUNTRY_POLICY_MANUAL. |
| | | |
+-----------+----------------------------+----------------------------------------------------------------+
| Station | WIFI_COUNTRY_POLICY_MANUAL | Always use the configured country info |
| | | |
| | | For scan, scans channel "schan" to "schan+nchan-1" with active |
| | | scan |
| | | |
+-----------+----------------------------+----------------------------------------------------------------+
| AP | WIFI_COUNTRY_POLICY_AUTO | Always use the configured country info |
| | | |
+-----------+----------------------------+----------------------------------------------------------------+
| AP | WIFI_COUNTRY_POLICY_MANUAL | Always use the configured country info |
| | | |
+-----------+----------------------------+----------------------------------------------------------------+
| Station/AP| WIFI_COUNTRY_POLICY_AUTO | If the station doesn't connects to any AP, the AP use the |
| | | configured country info. |
| coexit | | If the station connects to an AP, the AP has the same |
| | | country info as the station. |
| | | |
| | | Same as station mode with policy WIFI_COUNTRY_POLICY_AUTO |
+-----------+----------------------------+----------------------------------------------------------------+
Home Channel
*************************