pull/91/merge
Scott H 6 years ago committed by GitHub
commit f3b91b3132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/AutoConnect.cpp
  2. 4
      src/AutoConnect.h

@ -184,7 +184,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();
} }
@ -196,21 +197,27 @@ 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);
if(!_apConfig.contuineOnDisconnect)
{
do { do {
delay(100); delay(100);
yield(); yield();
} while (WiFi.softAPIP() == IPAddress(0, 0, 0, 0)); } 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.contuineOnDisconnect)
{
if (_apConfig.apip != IPAddress(0, 0, 0, 0)) { if (_apConfig.apip != IPAddress(0, 0, 0, 0)) {
do { do {
delay(100); delay(100);
yield(); yield();
} while (WiFi.softAPIP() != _apConfig.apip); } 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" : "");
@ -233,6 +240,8 @@ 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();
if(!_apConfig.contuineOnDisconnect)
{
while (WiFi.status() != WL_CONNECTED && !_rfReset) { while (WiFi.status() != WL_CONNECTED && !_rfReset) {
handleClient(); handleClient();
// Force execution of queued processes. // Force execution of queued processes.

@ -74,6 +74,7 @@ class AutoConnectConfig {
autoReconnect(false), autoReconnect(false),
immediateStart(false), immediateStart(false),
retainPortal(false), retainPortal(false),
contuineOnDisconnect(false),
portalTimeout(AUTOCONNECT_CAPTIVEPORTAL_TIMEOUT), portalTimeout(AUTOCONNECT_CAPTIVEPORTAL_TIMEOUT),
ticker(false), ticker(false),
tickerPort(AUTOCONNECT_TICKER_PORT), tickerPort(AUTOCONNECT_TICKER_PORT),
@ -106,6 +107,7 @@ class AutoConnectConfig {
autoReconnect(false), autoReconnect(false),
immediateStart(false), immediateStart(false),
retainPortal(false), retainPortal(false),
contuineOnDisconnect(false),
portalTimeout(portalTimeout), portalTimeout(portalTimeout),
ticker(false), ticker(false),
tickerPort(AUTOCONNECT_TICKER_PORT), tickerPort(AUTOCONNECT_TICKER_PORT),
@ -138,6 +140,7 @@ class AutoConnectConfig {
autoReconnect = o.autoReconnect; autoReconnect = o.autoReconnect;
immediateStart = o.immediateStart; immediateStart = o.immediateStart;
retainPortal = o.retainPortal; retainPortal = o.retainPortal;
contuineOnDisconnect = o.contuineOnDisconnect;
portalTimeout = o.portalTimeout; portalTimeout = o.portalTimeout;
ticker = o.ticker; ticker = o.ticker;
tickerPort = o.tickerPort; tickerPort = o.tickerPort;
@ -169,6 +172,7 @@ class AutoConnectConfig {
bool autoReconnect; /**< Automatic reconnect with past SSID */ bool autoReconnect; /**< Automatic reconnect with past SSID */
bool immediateStart; /**< Skips WiFi.begin(), start portal immediately */ bool immediateStart; /**< Skips WiFi.begin(), start portal immediately */
bool retainPortal; /**< Even if the captive portal times out, it maintains the portal state. */ bool retainPortal; /**< Even if the captive portal times out, it maintains the portal state. */
bool contuineOnDisconnect; /**< Dont stop setup method on when WIFI is Disconnected. */
unsigned long portalTimeout; /**< Timeout value for stay in the captive portal */ unsigned long portalTimeout; /**< Timeout value for stay in the captive portal */
bool ticker; /**< Drives LED flicker according to WiFi connection status. */ bool ticker; /**< Drives LED flicker according to WiFi connection status. */
uint8_t tickerPort; /**< GPIO for flicker */ uint8_t tickerPort; /**< GPIO for flicker */

Loading…
Cancel
Save