Skip to content

Commit 566bcbe

Browse files
committed
attempt to fix not connecting issues and endless loops
1 parent b994877 commit 566bcbe

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

WiFiManager.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
151151

152152
boolean WiFiManager::startConfigPortal(char const *apName, char const *apPassword) {
153153
//setup AP
154-
WiFi.mode(WIFI_AP);
155-
DEBUG_WM("SET AP");
154+
WiFi.mode(WIFI_AP_STA);
155+
DEBUG_WM("SET AP STA");
156156

157157
_apName = apName;
158158
_apPassword = apPassword;
@@ -229,8 +229,17 @@ int WiFiManager::connectWifi(String ssid, String pass) {
229229
if (ssid != "") {
230230
WiFi.begin(ssid.c_str(), pass.c_str());
231231
} else {
232-
DEBUG_WM("Using last saved values, should be faster");
233-
WiFi.begin();
232+
if(WiFi.SSID()) {
233+
DEBUG_WM("Using last saved values, should be faster");
234+
//trying to fix connection in progress hanging
235+
ETS_UART_INTR_DISABLE();
236+
wifi_station_disconnect();
237+
ETS_UART_INTR_ENABLE();
238+
239+
WiFi.begin();
240+
} else {
241+
DEBUG_WM("No saved credentials");
242+
}
234243
}
235244

236245
int connRes = waitForConnectResult();

WiFiManager.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#undef min
2121
#undef max
2222
#include <algorithm>
23-
23+
extern "C" {
24+
#include "user_interface.h"
25+
}
2426

2527
const char HTTP_200[] PROGMEM = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
2628
const char HTTP_HEAD[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/><title>{v}</title>";

0 commit comments

Comments
 (0)