[Solved] Meaning of reason codes in system_event_sta_disconnected_t?
[Solved] Meaning of reason codes in system_event_sta_disconnected_t?
One of the WiFi events that we can receive is SYSTEM_EVENT_STA_DISCONNECT which indicates that the ESP32 has been disconnected from an access point when acting as a station. In the corresponding data type (system_event_sta_disconnected_t) there is a field called "reason" that is an 8 bit flag that indicates the reason for the disconnection. What I am looking for is a description of the potential codes that can be returned. Do we have those?
Last edited by kolban on Tue Oct 18, 2016 3:26 am, edited 1 time in total.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: Meaning of reason codes in system_event_sta_disconnected_t?
There is an anonymous enum in esp_wifi_types.h with members called WIFI_REASON_xxx. These are disconnect reasons. Will update event structure to use this enum.
'
'
Re: Meaning of reason codes in system_event_sta_disconnected_t?
Perfect, exactly what I was looking for. For others who may search, here are the code as they are today from the header file:
Code: Select all
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,
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 44
- Joined: Mon Nov 07, 2016 5:04 pm
Re: [Solved] Meaning of reason codes in system_event_sta_disconnected_t?
@ESP_igrr
>>Will update event structure to use this enum
Did you get a chance to do this? It looks like it's still an unnamed enum that can't be accessed.
>>Will update event structure to use this enum
Did you get a chance to do this? It looks like it's still an unnamed enum that can't be accessed.
- gunar.kroeger
- Posts: 143
- Joined: Fri Jul 27, 2018 6:48 pm
Re: [Solved] Meaning of reason codes in system_event_sta_disconnected_t?
@ESP_igrr
>>Will update event structure to use this enum
Did you get a chance to do this? It looks like it's still an unnamed enum that can't be accessed.
>>Will update event structure to use this enum
Did you get a chance to do this? It looks like it's still an unnamed enum that can't be accessed.
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."
Re: [Solved] Meaning of reason codes in system_event_sta_disconnected_t?
It is no longer an anonymous enum; it is typedef'ed wifi_err_reason_t.
- gunar.kroeger
- Posts: 143
- Joined: Fri Jul 27, 2018 6:48 pm
Re: [Solved] Meaning of reason codes in system_event_sta_disconnected_t?
From "esp_event_legacy.h":
Is this struct redefined elsewhere?
Code: Select all
typedef struct {
uint8_t ssid[32]; /**< SSID of disconnected AP */
uint8_t ssid_len; /**< SSID length of disconnected AP */
uint8_t bssid[6]; /**< BSSID of disconnected AP */
uint8_t reason; /**< reason of disconnection */
} system_event_sta_disconnected_t;
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."
Re: [Solved] Meaning of reason codes in system_event_sta_disconnected_t?
I think the uint8_t has been kept in the event struct for compatibility reasons, however the reason codes themselves are now part of the typedefed enum. So you can directly assign/compare them (in C) or cast (in C++).
Who is online
Users browsing this forum: Bing [Bot], Marcosss and 90 guests