Reason code

ml8923
Posts: 3
Joined: Tue Jan 14, 2020 3:13 pm

Reason code

Postby ml8923 » Tue Jan 14, 2020 4:00 pm

How do I get the reason code with the non legacy event loop?
ie: static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data)

I understand with the legacy eventloop:
esp_err_t event_handler(void *ctx, system_event_t *event)

I can get the info:
system_event_sta_disconnected_t *disconnected = &event->event_info.disconnected;

I haven't seen examples anywhere of getting this information with the esp_event Library Event Loop though.

Thanks

ml8923
Posts: 3
Joined: Tue Jan 14, 2020 3:13 pm

Re: Reason code

Postby ml8923 » Tue Jan 14, 2020 4:20 pm

I've got it figured out. Thanks

wifi_event_sta_disconnected_t* event = (wifi_event_sta_disconnected_t*) event_data;
ESP_LOGI(TAG, "%d", event->reason);

ml8923
Posts: 3
Joined: Tue Jan 14, 2020 3:13 pm

Re: Reason code

Postby ml8923 » Tue Jan 14, 2020 5:35 pm

With the new handler:

wifi_event_sta_disconnected_t* event = (wifi_event_sta_disconnected_t*) event_data;

if(WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT == event->reason || WIFI_REASON_AUTH_FAIL == event->reason)
{
g_fatal_error = true;
ESP_LOGI(TAG,"Incorrect WiFi Credentials");
}

Who is online

Users browsing this forum: No registered users and 38 guests