|
|
@ -165,7 +165,8 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long |
|
|
|
|
|
|
|
|
|
|
|
// Activate the AP mode with configured softAP and start the access point.
|
|
|
|
// Activate the AP mode with configured softAP and start the access point.
|
|
|
|
WiFi.mode(WIFI_AP_STA); |
|
|
|
WiFi.mode(WIFI_AP_STA); |
|
|
|
while (WiFi.getMode() != WIFI_AP_STA) { |
|
|
|
|
|
|
|
|
|
|
|
while (WiFi.getMode() != WIFI_AP_STA && !_apConfig.contuineOnDisconnect) { |
|
|
|
delay(1); |
|
|
|
delay(1); |
|
|
|
yield(); |
|
|
|
yield(); |
|
|
|
} |
|
|
|
} |
|
|
@ -177,20 +178,26 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
WiFi.softAP(_apConfig.apid.c_str(), _apConfig.psk.c_str(), _apConfig.channel, _apConfig.hidden); |
|
|
|
WiFi.softAP(_apConfig.apid.c_str(), _apConfig.psk.c_str(), _apConfig.channel, _apConfig.hidden); |
|
|
|
do { |
|
|
|
if(!_apConfig.contuineOnDisconnect) |
|
|
|
delay(100); |
|
|
|
{ |
|
|
|
yield(); |
|
|
|
do { |
|
|
|
} while (WiFi.softAPIP() == IPAddress(0, 0, 0, 0)); |
|
|
|
delay(100); |
|
|
|
|
|
|
|
yield(); |
|
|
|
|
|
|
|
} while (WiFi.softAPIP() == IPAddress(0, 0, 0, 0)); |
|
|
|
|
|
|
|
} |
|
|
|
#if defined(ARDUINO_ARCH_ESP32) |
|
|
|
#if defined(ARDUINO_ARCH_ESP32) |
|
|
|
if (!(_apConfig.apip == IPAddress(0, 0, 0, 0) || _apConfig.gateway == IPAddress(0, 0, 0, 0) || _apConfig.netmask == IPAddress(0, 0, 0, 0))) { |
|
|
|
if (!(_apConfig.apip == IPAddress(0, 0, 0, 0) || _apConfig.gateway == IPAddress(0, 0, 0, 0) || _apConfig.netmask == IPAddress(0, 0, 0, 0))) { |
|
|
|
_config(); |
|
|
|
_config(); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (_apConfig.apip != IPAddress(0, 0, 0, 0)) { |
|
|
|
if(!_apConfig.contuineOnDisconnect) |
|
|
|
do { |
|
|
|
{ |
|
|
|
delay(100); |
|
|
|
if (_apConfig.apip != IPAddress(0, 0, 0, 0)) { |
|
|
|
yield(); |
|
|
|
do { |
|
|
|
} while (WiFi.softAPIP() != _apConfig.apip); |
|
|
|
delay(100); |
|
|
|
|
|
|
|
yield(); |
|
|
|
|
|
|
|
} while (WiFi.softAPIP() != _apConfig.apip); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
_currentHostIP = WiFi.softAPIP(); |
|
|
|
_currentHostIP = WiFi.softAPIP(); |
|
|
|
AC_DBG("SoftAP %s/%s Ch(%d) IP:%s %s\n", _apConfig.apid.c_str(), _apConfig.psk.c_str(), _apConfig.channel, _currentHostIP.toString().c_str(), _apConfig.hidden ? "hidden" : ""); |
|
|
|
AC_DBG("SoftAP %s/%s Ch(%d) IP:%s %s\n", _apConfig.apid.c_str(), _apConfig.psk.c_str(), _apConfig.channel, _currentHostIP.toString().c_str(), _apConfig.hidden ? "hidden" : ""); |
|
|
@ -210,15 +217,17 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long |
|
|
|
// Start the captive portal to make a new connection
|
|
|
|
// Start the captive portal to make a new connection
|
|
|
|
bool hasTimeout = false; |
|
|
|
bool hasTimeout = false; |
|
|
|
_portalAccessPeriod = millis(); |
|
|
|
_portalAccessPeriod = millis(); |
|
|
|
while (WiFi.status() != WL_CONNECTED && !_rfReset) { |
|
|
|
if(!_apConfig.contuineOnDisconnect) |
|
|
|
handleClient(); |
|
|
|
{ |
|
|
|
// Force execution of queued processes.
|
|
|
|
while (WiFi.status() != WL_CONNECTED && !_rfReset) { |
|
|
|
yield(); |
|
|
|
handleClient(); |
|
|
|
// Check timeout
|
|
|
|
// Force execution of queued processes.
|
|
|
|
if ((hasTimeout = _hasTimeout(_apConfig.portalTimeout))) { |
|
|
|
yield(); |
|
|
|
AC_DBG("CP timeout exceeded:%ld\n", millis() - _portalAccessPeriod); |
|
|
|
// Check timeout
|
|
|
|
break; |
|
|
|
if ((hasTimeout = _hasTimeout(_apConfig.portalTimeout))) { |
|
|
|
} |
|
|
|
AC_DBG("CP timeout exceeded:%ld\n", millis() - _portalAccessPeriod); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cs = WiFi.status() == WL_CONNECTED; |
|
|
|
cs = WiFi.status() == WL_CONNECTED; |
|
|
|
|
|
|
|
|
|
|
|