Page 1 of 1

esp32 哪个函数返回wifi连接失败原因

Posted: Thu Sep 14, 2023 2:21 am
by kalok_2022
esp32 哪个函数返回wifi连接失败原因,我尝试过特意输错密码,打印esp_wifi_connect的返回值,但是返回的是0,意思就是连接成功的,有没有相关例子,是不是我哪里写错了。

Re: esp32 哪个函数返回wifi连接失败原因

Posted: Fri Sep 15, 2023 8:53 am
by BMNLiLi
https://docs.espressif.com/projects/esp ... sp32-wi-fi

if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
wifi_event_sta_disconnected_t *sta_disconnect_evt = (wifi_event_sta_disconnected_t*)event_data;
ESP_LOGI(TAG, "wifi disconnect reason:%d", sta_disconnect_evt->reason);
esp_wifi_connect();
xEventGroupClearBits(s_wifi_event_group, CONNECTED_BIT);
}

Re: esp32 哪个函数返回wifi连接失败原因

Posted: Mon Sep 18, 2023 6:00 am
by kalok_2022
BMNLiLi wrote:
Fri Sep 15, 2023 8:53 am
https://docs.espressif.com/projects/esp ... sp32-wi-fi

if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
wifi_event_sta_disconnected_t *sta_disconnect_evt = (wifi_event_sta_disconnected_t*)event_data;
ESP_LOGI(TAG, "wifi disconnect reason:%d", sta_disconnect_evt->reason);
esp_wifi_connect();
xEventGroupClearBits(s_wifi_event_group, CONNECTED_BIT);
}
这部分程序在哪里调用比较好??

Re: esp32 哪个函数返回wifi连接失败原因

Posted: Mon Sep 18, 2023 8:08 am
by asdfg1426
kalok_2022 wrote:
Mon Sep 18, 2023 6:00 am
BMNLiLi wrote:
Fri Sep 15, 2023 8:53 am
https://docs.espressif.com/projects/esp ... sp32-wi-fi

if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
wifi_event_sta_disconnected_t *sta_disconnect_evt = (wifi_event_sta_disconnected_t*)event_data;
ESP_LOGI(TAG, "wifi disconnect reason:%d", sta_disconnect_evt->reason);
esp_wifi_connect();
xEventGroupClearBits(s_wifi_event_group, CONNECTED_BIT);
}
这部分程序在哪里调用比较好??
这段函数就是可以在wifi的句柄里面去用