[Solved] Meaning of reason codes in system_event_sta_disconnected_t?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

[Solved] Meaning of reason codes in system_event_sta_disconnected_t?

Postby kolban » Tue Oct 18, 2016 1:12 am

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

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: Meaning of reason codes in system_event_sta_disconnected_t?

Postby ESP_igrr » Tue Oct 18, 2016 2:23 am

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.
'

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Meaning of reason codes in system_event_sta_disconnected_t?

Postby kolban » Tue Oct 18, 2016 3:26 am

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

mgleason_3
Posts: 44
Joined: Mon Nov 07, 2016 5:04 pm

Re: [Solved] Meaning of reason codes in system_event_sta_disconnected_t?

Postby mgleason_3 » Mon Jul 17, 2017 10:34 pm

@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.

User avatar
gunar.kroeger
Posts: 143
Joined: Fri Jul 27, 2018 6:48 pm

Re: [Solved] Meaning of reason codes in system_event_sta_disconnected_t?

Postby gunar.kroeger » Mon Nov 05, 2018 2:10 pm

@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.
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: [Solved] Meaning of reason codes in system_event_sta_disconnected_t?

Postby ESP_igrr » Tue Nov 06, 2018 1:39 am

It is no longer an anonymous enum; it is typedef'ed wifi_err_reason_t.

User avatar
gunar.kroeger
Posts: 143
Joined: Fri Jul 27, 2018 6:48 pm

Re: [Solved] Meaning of reason codes in system_event_sta_disconnected_t?

Postby gunar.kroeger » Tue Nov 06, 2018 1:32 pm

From "esp_event_legacy.h":

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;
Is this struct redefined elsewhere?
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: [Solved] Meaning of reason codes in system_event_sta_disconnected_t?

Postby ESP_igrr » Tue Nov 06, 2018 2:26 pm

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: Baidu [Spider], Bing [Bot] and 133 guests