diff --git a/.travis.yml b/.travis.yml index 9e787cc..7d8bbbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ env: global: - IDE_VERSION=1.8.6 matrix: - - BOARD="esp8266:esp8266:nodemcuv2:CpuFrequency=160,FlashSize=4M3M" + - BOARD="esp8266:esp8266:generic:xtal=80,eesz=1M,FlashMode=qio,FlashFreq=80" - BOARD="esp32:esp32:esp32:FlashFreq=80,FlashSize=4M" before_install: - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16" @@ -20,7 +20,7 @@ before_install: - if [[ "$BOARD" =~ "esp32:esp32:" ]]; then arduino --install-boards esp32:esp32; fi - - arduino --install-library PubSubClient,ArduinoJson:5.13.3,PageBuilder:1.2.0 + - arduino --install-library PubSubClient,ArduinoJson:5.13.3,PageBuilder:1.2.1 - buildExampleSketch() { arduino --verbose-build --verify --board $BOARD $PWD/examples/$1/$1.ino; } install: - mkdir -p ~/Arduino/libraries diff --git a/library.json b/library.json index 1a8d7c7..78f8ca4 100644 --- a/library.json +++ b/library.json @@ -12,7 +12,7 @@ [ { "name": "PageBuilder", - "version": ">=1.2.0" + "version": ">=1.2.1" } ], "frameworks": "arduino", diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp index b1aacc9..b6d4187 100644 --- a/src/AutoConnect.cpp +++ b/src/AutoConnect.cpp @@ -89,7 +89,7 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long _portalTimeout = timeout; // Start WiFi connection with station mode. - WiFi.softAPdisconnect(true); +// WiFi.softAPdisconnect(true); WiFi.enableAP(false); WiFi.mode(WIFI_STA); delay(100); @@ -153,7 +153,12 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long // Change WiFi working mode, Enable AP with STA WiFi.setAutoConnect(false); - _disconnectWiFi(true); + _disconnectWiFi(false); + + // Activate the AP mode with configured softAP and start the access point. + WiFi.mode(WIFI_AP_STA); + while (WiFi.getMode() != WIFI_AP_STA) + yield(); // Connection unsuccessful, launch the captive portal. if (!(_apConfig.apip == IPAddress(0, 0, 0, 0) || _apConfig.gateway == IPAddress(0, 0, 0, 0) || _apConfig.netmask == IPAddress(0, 0, 0, 0))) { @@ -170,11 +175,6 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long // Fork to the exit routine that starts captive portal. cs = _onDetectExit ? _onDetectExit(_currentHostIP) : true; - // Activate the AP mode with configured softAP and start the access point. - WiFi.mode(WIFI_AP_STA); - while (WiFi.getMode() != WIFI_AP_STA) - yield(); - // Start Web server when TCP connection is enabled. _startWebServer(); @@ -410,6 +410,12 @@ void AutoConnect::handleRequest() { else { _currentHostIP = WiFi.softAPIP(); _redirectURI = String(AUTOCONNECT_URI_FAIL); + _rsConnect = WiFi.status(); + WiFi.disconnect(); + while (WiFi.status() != WL_IDLE_STATUS) { + delay(100); + yield(); + } } _rfConnect = false; } @@ -426,7 +432,11 @@ void AutoConnect::handleRequest() { if (_rfDisconnect) { // Disconnect from the current AP. _stopPortal(); - _disconnectWiFi(true); + _disconnectWiFi(false); + while (WiFi.status() == WL_CONNECTED) { + delay(100); + yield(); + } AC_DBG("Disconnected\n"); // Reset disconnection request _rfDisconnect = false; diff --git a/src/AutoConnect.h b/src/AutoConnect.h index 620b48a..b4c1fc2 100644 --- a/src/AutoConnect.h +++ b/src/AutoConnect.h @@ -242,6 +242,7 @@ class AutoConnect { bool _rfConnect; /**< URI /connect requested */ bool _rfDisconnect; /**< URI /disc requested */ bool _rfReset; /**< URI /reset requested */ + wl_status_t _rsConnect; /**< connection result */ /** HTTP header information of the currently requested page. */ String _uri; /**< Requested URI */ diff --git a/src/AutoConnectPage.cpp b/src/AutoConnectPage.cpp index fe4fe0d..9402900 100644 --- a/src/AutoConnectPage.cpp +++ b/src/AutoConnectPage.cpp @@ -763,7 +763,9 @@ const char AutoConnect::_PAGE_DISCONN[] PROGMEM = { "" "
" "