From a23c02873078e84e8d484aa6d9fe734b5b70160f Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Wed, 5 Dec 2018 02:51:37 +0900 Subject: [PATCH] Supports AutoConnectAux --- src/AutoConnect.cpp | 8 ++------ src/AutoConnectDefs.h | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp index 9862304..5757afd 100644 --- a/src/AutoConnect.cpp +++ b/src/AutoConnect.cpp @@ -92,7 +92,6 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long WiFi.softAPdisconnect(true); WiFi.enableAP(false); _disconnectWiFi(false); - WiFi.setAutoReconnect(false); WiFi.mode(WIFI_STA); delay(100); @@ -103,7 +102,7 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long String staNetmask_s = _apConfig.staNetmask.toString(); String dns1_s = _apConfig.dns1.toString(); String dns2_s = _apConfig.dns2.toString(); - AC_DBG("WiFi.config(IP=%s, Gateway=%s, Subnetmask=%s, DNS1=%s, DNS2=%s) ", staip_s.c_str(), staGateway_s.c_str(), staNetmask_s.c_str(), dns1_s.c_str(), dns2_s.c_str()); + AC_DBG("WiFi.config(IP=%s, Gateway=%s, Subnetmask=%s, DNS1=%s, DNS2=%s)\n", staip_s.c_str(), staGateway_s.c_str(), staNetmask_s.c_str(), dns1_s.c_str(), dns2_s.c_str()); #endif if (!WiFi.config(_apConfig.staip, _apConfig.staGateway, _apConfig.staNetmask, _apConfig.dns1, _apConfig.dns2)) { AC_DBG("failed\n"); @@ -165,7 +164,7 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long while (WiFi.softAPIP() == IPAddress(0, 0, 0, 0)) yield(); _currentHostIP = WiFi.softAPIP(); - AC_DBG("SoftAP %s/%s CH(%d) H(%d) IP:%s\n", _apConfig.apid.c_str(), _apConfig.psk.c_str(), _apConfig.channel, _apConfig.hidden, WiFi.softAPIP().toString().c_str()); + AC_DBG("SoftAP %s/%s CH(%d) H(%d) IP:%s\n", _apConfig.apid.c_str(), _apConfig.psk.c_str(), _apConfig.channel, _apConfig.hidden, _currentHostIP.toString().c_str()); // Fork to the exit routine that starts captive portal. cs = _onDetectExit ? _onDetectExit(_currentHostIP) : true; @@ -373,7 +372,6 @@ void AutoConnect::handleRequest() { // An attempt to establish a new AP. AC_DBG("Request for %s\n", (const char*)_credential.ssid); -// WiFi.begin((const char*)_credential.ssid, (const char*)_credential.password); WiFi.begin((const char*)_credential.ssid, (const char*)_credential.password, _apConfig.channel); if (_waitForConnect(_portalTimeout) == WL_CONNECTED) { if (WiFi.BSSID() != NULL) { @@ -711,8 +709,6 @@ wl_status_t AutoConnect::_waitForConnect(unsigned long timeout) { */ void AutoConnect::_disconnectWiFi(bool wifiOff) { #if defined(ARDUINO_ARCH_ESP8266) - if (wifiOff) - ESP.eraseConfig(); WiFi.disconnect(wifiOff); #elif defined(ARDUINO_ARCH_ESP32) WiFi.disconnect(wifiOff, true); diff --git a/src/AutoConnectDefs.h b/src/AutoConnectDefs.h index a05e596..390d8f5 100644 --- a/src/AutoConnectDefs.h +++ b/src/AutoConnectDefs.h @@ -87,7 +87,7 @@ // Advance wait time #ifndef AUTOCONNECT_STARTUPTIME -#define AUTOCONNECT_STARTUPTIME 10 +#define AUTOCONNECT_STARTUPTIME (AUTOCONNECT_TIMEOUT/1000) #endif // !AUTOCONNECT_STARTUPTIME // Default HTTP port