未验证 提交 52575d63 编写于 作者: P P-R-O-C-H-Y 提交者: GitHub

Fixed wifiBegin to fail wfile connecting to same AP without previous disconnecting (#6359)

上级 d1f0d6c0
......@@ -835,6 +835,8 @@ const char * system_event_reasons[] = { "UNSPECIFIED", "AUTH_EXPIRE", "AUTH_LEAV
#endif
esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
{
static bool first_connect = true;
if(event->event_id < ARDUINO_EVENT_MAX) {
log_d("Arduino Event: %d - %s", event->event_id, arduino_event_names[event->event_id]);
}
......@@ -860,7 +862,7 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
log_w("Reason: %u - %s", reason, reason2str(reason));
if(reason == WIFI_REASON_NO_AP_FOUND) {
WiFiSTAClass::_setStatus(WL_NO_SSID_AVAIL);
} else if(reason == WIFI_REASON_AUTH_FAIL) {
} else if((reason == WIFI_REASON_AUTH_FAIL) && !first_connect){
WiFiSTAClass::_setStatus(WL_CONNECT_FAILED);
} else if(reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) {
WiFiSTAClass::_setStatus(WL_CONNECTION_LOST);
......@@ -870,7 +872,15 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
WiFiSTAClass::_setStatus(WL_DISCONNECTED);
}
clearStatusBits(STA_CONNECTED_BIT | STA_HAS_IP_BIT | STA_HAS_IP6_BIT);
if(WiFi.getAutoReconnect()){
if(first_connect && ((reason == WIFI_REASON_AUTH_EXPIRE) ||
(reason >= WIFI_REASON_BEACON_TIMEOUT)))
{
log_d("WiFi Reconnect Running");
WiFi.disconnect();
WiFi.begin();
first_connect = false;
}
else if(WiFi.getAutoReconnect()){
if((reason == WIFI_REASON_AUTH_EXPIRE) ||
(reason >= WIFI_REASON_BEACON_TIMEOUT && reason != WIFI_REASON_AUTH_FAIL))
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册