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

kalok_2022
Posts: 28
Joined: Mon Nov 21, 2022 8:42 am

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

Postby kalok_2022 » Thu Sep 14, 2023 2:21 am

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

BMNLiLi
Posts: 5
Joined: Fri Mar 06, 2020 9:30 am

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

Postby BMNLiLi » 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);
}

kalok_2022
Posts: 28
Joined: Mon Nov 21, 2022 8:42 am

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

Postby kalok_2022 » 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);
}
这部分程序在哪里调用比较好??

asdfg1426
Posts: 86
Joined: Tue Jul 11, 2023 2:35 am

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

Postby asdfg1426 » Mon Sep 18, 2023 8:08 am

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的句柄里面去用

Who is online

Users browsing this forum: weddawd and 26 guests