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
Reason code
Re: Reason code
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);
wifi_event_sta_disconnected_t* event = (wifi_event_sta_disconnected_t*) event_data;
ESP_LOGI(TAG, "%d", event->reason);
Re: Reason code
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");
}
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");
}
Re: Reason code
Just as a note, don't use WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT to determine whether or not the password is correct. I made this mistake in some custom firmware and there are a TON of cases where customers have weak wifi signals and even though wrong password can sometimes return as WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT, it can be a false positive. Even sometimes when reconnecting to wifi it will return WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT but we know the password is correct. Changing to only use WIFI_REASON_AUTH_FAIL is the only way to determine a wrong password.
Who is online
Users browsing this forum: No registered users and 375 guests