Skip to content

Commit

Permalink
Merge branch 'bugfix/modify_wifi_scan_return_value' into 'master'
Browse files Browse the repository at this point in the history
esp_wifi: modify wifi scan return value

Closes WIFI-4734, IDFGH-8236, IDFGH-8250, IDFGH-8436, DOC-3115, DOC-3134, IDFGH-5762, WIFI-4522, and WIFI-4523

See merge request espressif/esp-idf!20021
  • Loading branch information
jack0c committed Nov 9, 2022
2 parents 9be5145 + c4644dd commit e6c57c0
Show file tree
Hide file tree
Showing 5 changed files with 349 additions and 42 deletions.
3 changes: 3 additions & 0 deletions components/esp_wifi/include/esp_wifi.h
Expand Up @@ -580,6 +580,8 @@ esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw);
* @attention 2. When ESP32 is in STA mode, this API should not be called when STA is scanning or connecting to an external AP
* @attention 3. When ESP32 is in softAP mode, this API should not be called when softAP has connected to external STAs
* @attention 4. When ESP32 is in STA+softAP mode, this API should not be called when in the scenarios described above
* @attention 5. The channel info set by this API will not be stored in NVS. So If you want to remeber the channel used before wifi stop,
* you need to call this API again after wifi start, or you can call `esp_wifi_set_config()` to store the channel info in NVS.
*
* @param primary for HT20, primary is the channel number, for HT40, primary is the primary channel
* @param second for HT20, second is ignored, for HT40, second is the second channel
Expand Down Expand Up @@ -789,6 +791,7 @@ esp_err_t esp_wifi_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter
* @attention 2. For station configuration, bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.
* @attention 3. ESP32 is limited to only one channel, so when in the soft-AP+station mode, the soft-AP will adjust its channel automatically to be the same as
* the channel of the ESP32 station.
* @attention 4. The configuration will be stored in NVS
*
* @param interface interface
* @param conf station or soft-AP configuration
Expand Down
91 changes: 56 additions & 35 deletions components/esp_wifi/include/esp_wifi_types.h
Expand Up @@ -64,41 +64,62 @@ typedef enum {
} 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_BSS_TRANSITION_DISASSOC = 12,
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_INVALID_PMKID = 53,

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_REASON_AP_TSF_RESET = 206,
WIFI_REASON_ROAMING = 207,
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_BSS_TRANSITION_DISASSOC = 12,
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_TDLS_PEER_UNREACHABLE = 25,
WIFI_REASON_TDLS_UNSPECIFIED = 26,
WIFI_REASON_SSP_REQUESTED_DISASSOC = 27,
WIFI_REASON_NO_SSP_ROAMING_AGREEMENT = 28,
WIFI_REASON_BAD_CIPHER_OR_AKM = 29,
WIFI_REASON_NOT_AUTHORIZED_THIS_LOCATION = 30,
WIFI_REASON_SERVICE_CHANGE_PERCLUDES_TS = 31,
WIFI_REASON_UNSPECIFIED_QOS = 32,
WIFI_REASON_NOT_ENOUGH_BANDWIDTH = 33,
WIFI_REASON_MISSING_ACKS = 34,
WIFI_REASON_EXCEEDED_TXOP = 35,
WIFI_REASON_STA_LEAVING = 36,
WIFI_REASON_END_BA = 37,
WIFI_REASON_UNKNOWN_BA = 38,
WIFI_REASON_TIMEOUT = 39,
WIFI_REASON_PEER_INITIATED = 46,
WIFI_REASON_AP_INITIATED = 47,
WIFI_REASON_INVALID_FT_ACTION_FRAME_COUNT = 48,
WIFI_REASON_INVALID_PMKID = 49,
WIFI_REASON_INVALID_MDE = 50,
WIFI_REASON_INVALID_FTE = 51,
WIFI_REASON_TRANSMISSION_LINK_ESTABLISH_FAILED = 67,
WIFI_REASON_ALTERATIVE_CHANNEL_OCCUPIED = 68,

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_REASON_AP_TSF_RESET = 206,
WIFI_REASON_ROAMING = 207,
} wifi_err_reason_t;

typedef enum {
Expand Down
147 changes: 144 additions & 3 deletions docs/en/api-guides/wifi.rst
Expand Up @@ -767,7 +767,7 @@ Four-way Handshake Phase
Wi-Fi Reason Code
+++++++++++++++++++++

The table below shows the reason code defined in {IDF_TARGET_NAME}. The first column is the macro name defined in esp_wifi_types.h. The common prefix *WIFI_REASON* is removed, which means that *UNSPECIFIED* actually stands for *WIFI_REASON_UNSPECIFIED* and so on. The second column is the value of the reason. The third column is the standard value to which this reason is mapped in section 8.4.1.7 of IEEE 802.11-2012 (For more information, refer to the standard mentioned above). The last column describes the reason.
The table below shows the reason-code defined in {IDF_TARGET_NAME}. The first column is the macro name defined in esp_wifi_types.h. The common prefix *WIFI_REASON* is removed, which means that *UNSPECIFIED* actually stands for *WIFI_REASON_UNSPECIFIED* and so on. The second column is the value of the reason. The third column is the standard value to which this reason is mapped in section 9.4.1.7 of IEEE 802.11-2020. (For more information, refer to the standard mentioned above.) The last column describes the reason.

.. list-table::
:header-rows: 1
Expand Down Expand Up @@ -996,6 +996,102 @@ The table below shows the reason code defined in {IDF_TARGET_NAME}. The first co
For the ESP station, this reason is reported when:
- it is received from the AP.
* - TDLS_PEER_UNREACHABLE
- 25
- 25
- TDLS direct-link teardown due to TDLS peer STA unreachable via the TDLS direct link.
* - TDLS_UNSPECIFIED
- 26
- 26
- TDLS direct-link teardown for unspecified reason.
* - SSP_REQUESTED_DISASSOC
- 27
- 27
- Disassociated because session terminated by SSP request.
* - NO_SSP_ROAMING_AGREEMENT
- 28
- 28
- Disassociated because of lack of SSP roaming agreement.
* - BAD_CIPHER_OR_AKM
- 29
- 29
- Requested service rejected because of SSP cipher suite or AKM requirement.
* - NOT_AUTHORIZED_THIS_LOCATION
- 30
- 30
- Requested service not authorized in this location.
* - SERVICE_CHANGE_PRECLUDES_TS
- 31
- 31
- TS deleted because QoS AP lacks sufficient bandwidth for this QoS STA due to a change in BSS service characteristics or operational mode (e.g., an HT BSS change from 40 MHz channel to 20 MHz channel).
* - UNSPECIFIED_QOS
- 32
- 32
- Disassociated for unspecified, QoS-related reason.
* - NOT_ENOUGH_BANDWIDTH
- 33
- 33
- Disassociated because QoS AP lacks sufficient bandwidth for this QoS STA.
* - MISSING_ACKS
- 34
- 34
- Disassociated because excessive number of frames need to be acknowledged, but are not acknowledged due to AP transmissions and/or poor channel conditions.
* - EXCEEDED_TXOP
- 35
- 35
- Disassociated because STA is transmitting outside the limits of its TXOPs.
* - STA_LEAVING
- 36
- 36
- Requesting STA is leaving the BSS (or resetting).
* - END_BA
- 37
- 37
- Requesting STA is no longer using the stream or session.
* - UNKNOWN_BA
- 38
- 38
- Requesting STA received frames using a mechanism for which a setup has not been completed.
* - TIMEOUT
- 39
- 39
- Requested from peer STA due to timeout
* - Reserved
- 40 ~ 45
- 40 ~ 45
-
* - PEER_INITIATED
- 46
- 46
- In a Disassociation frame: Disassociated because authorized access limit reached.
* - AP_INITIATED
- 47
- 47
- In a Disassociation frame: Disassociated due to external service requirements.
* - INVALID_FT_ACTION_FRAME_COUNT
- 48
- 48
- Invalid FT Action frame count.
* - INVALID_PMKID
- 49
- 49
- Invalid pairwise master key identifier (PMKID).
* - INVALID_MDE
- 50
- 50
- Invalid MDE.
* - INVALID_FTE
- 51
- 51
- Invalid FTE
* - TRANSMISSION_LINK_ESTABLISHMENT_FAILED
- 67
- 67
- Transmission link establishment in alternative channel failed.
* - ALTERATIVE_CHANNEL_OCCUPIED
- 68
- 68
- The alternative channel is occupied.
* - BEACON_TIMEOUT
- 200
- reserved
Expand All @@ -1022,6 +1118,51 @@ The table below shows the reason code defined in {IDF_TARGET_NAME}. The first co
- Espressif-specific Wi-Fi reason code: the connection to the AP has failed.
Wi-Fi Reason code related to wrong password
++++++++++++++++++++++++++++++++++++++++++++++
The table below shows the Wi-Fi reason-code may related to wrong password.
.. list-table::
:header-rows: 1
:widths: 5 10 40
* - Reason code
- Value
- Description
* - 4WAY_HANDSHAKE_TIMEOUT
- 15
- Four-way handshake times out. Setting wrong password when STA connecting to an encrpyted AP.
* - NO_AP_FOUND
- 201
- This may related to wrong password in the two scenarios:
- Setting password when STA connecting to an unencrypted AP.
- Doesn't setting password when STA connecting to an encrypted AP.
* - HANDSHAKE_TIMEOUT
- 204
- Four-way handshake fails.
Wi-Fi Reason code related to low RSSI
++++++++++++++++++++++++++++++++++++++++++++++
The table below shows the Wi-Fi reason-code may related to low RSSI.
.. list-table::
:header-rows: 1
:widths: 5 10 40
* - Reason code
- Value
- Description
* - NO_AP_FOUND
- 201
- The station fails to scan the target AP due to low RSSI
* - HANDSHAKE_TIMEOUT
- 204
- Four-way handshake fails.
{IDF_TARGET_NAME} Wi-Fi Station Connecting When Multiple APs Are Found
----------------------------------------------------------------------
Expand Down Expand Up @@ -1076,7 +1217,7 @@ Call :cpp:func:`esp_wifi_set_mode()` to set the Wi-Fi mode.
Station Basic Configuration
+++++++++++++++++++++++++++++++++++++

API esp_wifi_set_config() can be used to configure the station. The table below describes the fields in detail.
API :cpp:func:`esp_wifi_set_config()` can be used to configure the station. And the configuration will be stored in NVS. The table below describes the fields in detail.

.. list-table::
:header-rows: 1
Expand Down Expand Up @@ -1115,7 +1256,7 @@ API esp_wifi_set_config() can be used to configure the station. The table below
AP Basic Configuration
+++++++++++++++++++++++++++++++++++++

API esp_wifi_set_config() can be used to configure the AP. The table below describes the fields in detail.
API :cpp:func:`esp_wifi_set_config()` can be used to configure the AP. And the configuration will be stored in NVS. The table below describes the fields in detail.

.. only:: esp32 or esp32s2 or esp32c3 or esp32s3

Expand Down

0 comments on commit e6c57c0

Please sign in to comment.