Browse Source

fixes #89 and some other changes after review (#90)

* move code into src directory

* add gitignore file

* bump version

* fixes: comparison of integer expressions of different signedness

* fixes warning when using ESP8266

* removed unused variable

* reviewed code comments for consistency

* moved to flash a few more debug messages

* applied code formatting

* bump version to 0.27

* reviewed for consistency on variable type

* completely removed unsed handle204 leftovers

* removed unused code

* bump version to 0.28

* fixes build failure

* bump version to 0.29
Hernán Rossetto 3 years ago
parent
commit
9da266ae72
6 changed files with 141 additions and 111 deletions
  1. 1 0
      .gitignore
  2. 0 2
      keywords.txt
  3. 1 1
      library.json
  4. 1 1
      library.properties
  5. 104 90
      src/ESPAsyncWiFiManager.cpp
  6. 34 17
      src/ESPAsyncWiFiManager.h

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
+include
 .pio
 .vscode
 platformio.ini

+ 0 - 2
keywords.txt

@@ -14,8 +14,6 @@ AsyncWiFiManagerParameter KEYWORD1
 # Methods and Functions (KEYWORD2)
 #######################################
 autoConnect	KEYWORD2
-getSSID	KEYWORD2
-getPassword	KEYWORD2
 getConfigPortalSSID KEYWORD2
 resetSettings	KEYWORD2
 setConfigPortalTimeout	KEYWORD2

+ 1 - 1
library.json

@@ -9,5 +9,5 @@
   },
   "frameworks": "arduino",
   "platforms": ["espressif8266", "espressif32"],
-  "version": "0.27"
+  "version": "0.29"
 }

+ 1 - 1
library.properties

@@ -1,5 +1,5 @@
 name=ESP Async WiFi Manager
-version=0.27
+version=0.29
 author=alanswx
 maintainer=alanswx
 sentence=ESP8266 and ESP32 Async WiFi Connection manager with fallback web configuration portal

+ 104 - 90
src/ESPAsyncWiFiManager.cpp

@@ -23,23 +23,35 @@ AsyncWiFiManagerParameter::AsyncWiFiManagerParameter(const char *custom)
   _customHTML = custom;
 }
 
-AsyncWiFiManagerParameter::AsyncWiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length)
+AsyncWiFiManagerParameter::AsyncWiFiManagerParameter(const char *id,
+                                                     const char *placeholder,
+                                                     const char *defaultValue,
+                                                     unsigned int length)
 {
   init(id, placeholder, defaultValue, length, "");
 }
 
-AsyncWiFiManagerParameter::AsyncWiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom)
+AsyncWiFiManagerParameter::AsyncWiFiManagerParameter(const char *id,
+                                                     const char *placeholder,
+                                                     const char *defaultValue,
+                                                     unsigned int length,
+                                                     const char *custom)
 {
   init(id, placeholder, defaultValue, length, custom);
 }
 
-void AsyncWiFiManagerParameter::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom)
+void AsyncWiFiManagerParameter::init(const char *id,
+                                     const char *placeholder,
+                                     const char *defaultValue,
+                                     unsigned int length,
+                                     const char *custom)
 {
   _id = id;
   _placeholder = placeholder;
   _length = length;
   _value = new char[length + 1];
-  for (int i = 0; i < length; i++)
+
+  for (unsigned int i = 0; i < length; i++)
   {
     _value[i] = 0;
   }
@@ -63,7 +75,7 @@ const char *AsyncWiFiManagerParameter::getPlaceholder()
 {
   return _placeholder;
 }
-int AsyncWiFiManagerParameter::getValueLength()
+unsigned int AsyncWiFiManagerParameter::getValueLength()
 {
   return _length;
 }
@@ -73,10 +85,12 @@ const char *AsyncWiFiManagerParameter::getCustomHTML()
 }
 
 #ifdef USE_EADNS
-AsyncWiFiManager::AsyncWiFiManager(AsyncWebServer *server, AsyncDNSServer *dns) : server(server), dnsServer(dns)
+AsyncWiFiManager::AsyncWiFiManager(AsyncWebServer *server,
+                                   AsyncDNSServer *dns) : server(server), dnsServer(dns)
 {
 #else
-AsyncWiFiManager::AsyncWiFiManager(AsyncWebServer *server, DNSServer *dns) : server(server), dnsServer(dns)
+AsyncWiFiManager::AsyncWiFiManager(AsyncWebServer *server,
+                                   DNSServer *dns) : server(server), dnsServer(dns)
 {
 #endif
   wifiSSIDs = NULL;
@@ -89,7 +103,7 @@ void AsyncWiFiManager::addParameter(AsyncWiFiManagerParameter *p)
 {
   _params[_paramsCount] = p;
   _paramsCount++;
-  DEBUG_WM("Adding parameter");
+  DEBUG_WM(F("Adding parameter"));
   DEBUG_WM(p->getID());
 }
 
@@ -124,7 +138,7 @@ void AsyncWiFiManager::setupConfigPortal()
 
   if (_apPassword != NULL)
   {
-    WiFi.softAP(_apName, _apPassword); //password option
+    WiFi.softAP(_apName, _apPassword); // password option
   }
   else
   {
@@ -149,16 +163,29 @@ void AsyncWiFiManager::setupConfigPortal()
   setInfo();
 
   // setup web pages: root, wifi config pages, SO captive portal detectors and not found
-  server->on("/", std::bind(&AsyncWiFiManager::handleRoot, this, std::placeholders::_1)).setFilter(ON_AP_FILTER);
-  server->on("/wifi", std::bind(&AsyncWiFiManager::handleWifi, this, std::placeholders::_1, true)).setFilter(ON_AP_FILTER);
-  server->on("/0wifi", std::bind(&AsyncWiFiManager::handleWifi, this, std::placeholders::_1, false)).setFilter(ON_AP_FILTER);
-  server->on("/wifisave", std::bind(&AsyncWiFiManager::handleWifiSave, this, std::placeholders::_1)).setFilter(ON_AP_FILTER);
-  server->on("/i", std::bind(&AsyncWiFiManager::handleInfo, this, std::placeholders::_1)).setFilter(ON_AP_FILTER);
-  server->on("/r", std::bind(&AsyncWiFiManager::handleReset, this, std::placeholders::_1)).setFilter(ON_AP_FILTER);
-  //server->on("/generate_204", std::bind(&AsyncWiFiManager::handle204, this));  //Android/Chrome OS captive portal check.
-  server->on("/fwlink", std::bind(&AsyncWiFiManager::handleRoot, this, std::placeholders::_1)).setFilter(ON_AP_FILTER); //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
+  server->on("/",
+             std::bind(&AsyncWiFiManager::handleRoot, this, std::placeholders::_1))
+      .setFilter(ON_AP_FILTER);
+  server->on("/wifi",
+             std::bind(&AsyncWiFiManager::handleWifi, this, std::placeholders::_1, true))
+      .setFilter(ON_AP_FILTER);
+  server->on("/0wifi",
+             std::bind(&AsyncWiFiManager::handleWifi, this, std::placeholders::_1, false))
+      .setFilter(ON_AP_FILTER);
+  server->on("/wifisave",
+             std::bind(&AsyncWiFiManager::handleWifiSave, this, std::placeholders::_1))
+      .setFilter(ON_AP_FILTER);
+  server->on("/i",
+             std::bind(&AsyncWiFiManager::handleInfo, this, std::placeholders::_1))
+      .setFilter(ON_AP_FILTER);
+  server->on("/r",
+             std::bind(&AsyncWiFiManager::handleReset, this, std::placeholders::_1))
+      .setFilter(ON_AP_FILTER);
+  server->on("/fwlink",
+             std::bind(&AsyncWiFiManager::handleRoot, this, std::placeholders::_1))
+      .setFilter(ON_AP_FILTER); // Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
   server->onNotFound(std::bind(&AsyncWiFiManager::handleNotFound, this, std::placeholders::_1));
-  server->begin(); // Web server start
+  server->begin(); // web server start
   DEBUG_WM(F("HTTP server started"));
 }
 
@@ -194,7 +221,7 @@ String getESP32ChipID()
 {
   uint64_t chipid;
   chipid = ESP.getEfuseMac(); // the chip ID is essentially its MAC address (length: 6 bytes)
-  int chipid_size = 6;
+  uint8_t chipid_size = 6;
   uint8_t chipid_arr[chipid_size];
   for (uint8_t i = 0; i < chipid_size; i++)
   {
@@ -204,7 +231,8 @@ String getESP32ChipID()
 }
 #endif
 
-boolean AsyncWiFiManager::autoConnect(unsigned long maxConnectRetries, unsigned long retryDelayMs)
+boolean AsyncWiFiManager::autoConnect(unsigned long maxConnectRetries,
+                                      unsigned long retryDelayMs)
 {
   String ssid = "ESP";
 #if defined(ESP8266)
@@ -215,14 +243,13 @@ boolean AsyncWiFiManager::autoConnect(unsigned long maxConnectRetries, unsigned
   return autoConnect(ssid.c_str(), NULL);
 }
 
-boolean AsyncWiFiManager::autoConnect(char const *apName, char const *apPassword, unsigned long maxConnectRetries, unsigned long retryDelayMs)
+boolean AsyncWiFiManager::autoConnect(char const *apName,
+                                      char const *apPassword,
+                                      unsigned long maxConnectRetries,
+                                      unsigned long retryDelayMs)
 {
   DEBUG_WM(F(""));
 
-  // read eeprom for ssid and pass
-  //String ssid = getSSID();
-  //String pass = getPassword();
-
   // attempt to connect; should it fail, fall back to AP
   WiFi.mode(WIFI_STA);
 
@@ -241,7 +268,6 @@ boolean AsyncWiFiManager::autoConnect(char const *apName, char const *apPassword
 
     if (tryNumber + 1 < maxConnectRetries)
     {
-
       // we might connect during the delay
       unsigned long restDelayMs = retryDelayMs;
       while (restDelayMs != 0)
@@ -269,10 +295,12 @@ String AsyncWiFiManager::networkListAsString()
   for (int i = 0; i < wifiSSIDCount; i++)
   {
     if (wifiSSIDs[i].duplicate == true)
+    {
       continue; // skip dups
-    int quality = getRSSIasQuality(wifiSSIDs[i].RSSI);
+    }
+    unsigned int quality = getRSSIasQuality(wifiSSIDs[i].RSSI);
 
-    if (_minimumQuality == -1 || _minimumQuality < quality)
+    if (_minimumQuality == 0 || _minimumQuality < quality)
     {
       String item = FPSTR(HTTP_ITEM);
       String rssiQ;
@@ -313,7 +341,9 @@ String AsyncWiFiManager::scanModal()
 void AsyncWiFiManager::scan(boolean async)
 {
   if (!shouldscan)
+  {
     return;
+  }
   DEBUG_WM(F("About to scan()"));
   if (wifiSSIDscan)
   {
@@ -350,21 +380,35 @@ void AsyncWiFiManager::copySSIDInfo(wifi_ssid_count_t n)
   {
     // WE SHOULD MOVE THIS IN PLACE ATOMICALLY
     if (wifiSSIDs)
+    {
       delete[] wifiSSIDs;
+    }
     wifiSSIDs = new WiFiResult[n];
     wifiSSIDCount = n;
 
     if (n > 0)
+    {
       shouldscan = false;
-
+    }
     for (wifi_ssid_count_t i = 0; i < n; i++)
     {
       wifiSSIDs[i].duplicate = false;
 
 #if defined(ESP8266)
-      WiFi.getNetworkInfo(i, wifiSSIDs[i].SSID, wifiSSIDs[i].encryptionType, wifiSSIDs[i].RSSI, wifiSSIDs[i].BSSID, wifiSSIDs[i].channel, wifiSSIDs[i].isHidden);
+      WiFi.getNetworkInfo(i,
+                          wifiSSIDs[i].SSID,
+                          wifiSSIDs[i].encryptionType,
+                          wifiSSIDs[i].RSSI,
+                          wifiSSIDs[i].BSSID,
+                          wifiSSIDs[i].channel,
+                          wifiSSIDs[i].isHidden);
 #else
-      WiFi.getNetworkInfo(i, wifiSSIDs[i].SSID, wifiSSIDs[i].encryptionType, wifiSSIDs[i].RSSI, wifiSSIDs[i].BSSID, wifiSSIDs[i].channel);
+      WiFi.getNetworkInfo(i,
+                          wifiSSIDs[i].SSID,
+                          wifiSSIDs[i].encryptionType,
+                          wifiSSIDs[i].RSSI,
+                          wifiSSIDs[i].BSSID,
+                          wifiSSIDs[i].channel);
 #endif
     }
 
@@ -389,7 +433,9 @@ void AsyncWiFiManager::copySSIDInfo(wifi_ssid_count_t n)
       for (int i = 0; i < n; i++)
       {
         if (wifiSSIDs[i].duplicate == true)
+        {
           continue;
+        }
         cssid = wifiSSIDs[i].SSID;
         for (int j = i + 1; j < n; j++)
         {
@@ -406,14 +452,12 @@ void AsyncWiFiManager::copySSIDInfo(wifi_ssid_count_t n)
 
 void AsyncWiFiManager::startConfigPortalModeless(char const *apName, char const *apPassword)
 {
-
   _modeless = true;
   _apName = apName;
   _apPassword = apPassword;
 
   /*
   AJS - do we want this?
-
   */
 
   // setup AP
@@ -551,7 +595,6 @@ boolean AsyncWiFiManager::startConfigPortal(char const *apName, char const *apPa
 #ifndef USE_EADNS
     dnsServer->processNextRequest();
 #endif
-
     //
     //  we should do a scan every so often here and
     //  try to reconnect to AP while we are at it
@@ -570,7 +613,9 @@ boolean AsyncWiFiManager::startConfigPortal(char const *apName, char const *apPa
 #endif
       scanModal();
       if (_tryConnectDuringConfigPortal)
+      {
         WiFi.begin(); // try to reconnect to AP
+      }
       scannow = millis();
     }
 
@@ -633,7 +678,7 @@ boolean AsyncWiFiManager::startConfigPortal(char const *apName, char const *apPa
   return WiFi.status() == WL_CONNECTED;
 }
 
-int AsyncWiFiManager::connectWifi(String ssid, String pass)
+uint8_t AsyncWiFiManager::connectWifi(String ssid, String pass)
 {
   DEBUG_WM(F("Connecting as wifi client..."));
 
@@ -660,12 +705,10 @@ int AsyncWiFiManager::connectWifi(String ssid, String pass)
 #else
     WiFi.disconnect(false);
 #endif
-
     WiFi.begin(ssid.c_str(), pass.c_str());
   }
   else
   {
-
     if (WiFi.SSID().length() > 0)
     {
       DEBUG_WM(F("Using last saved values, should be faster"));
@@ -677,7 +720,6 @@ int AsyncWiFiManager::connectWifi(String ssid, String pass)
 #else
       WiFi.disconnect(false);
 #endif
-
       WiFi.begin();
     }
     else
@@ -687,7 +729,7 @@ int AsyncWiFiManager::connectWifi(String ssid, String pass)
     }
   }
 
-  int connRes = waitForConnectResult();
+  uint8_t connRes = waitForConnectResult();
   DEBUG_WM(F("Connection result: "));
   DEBUG_WM(connRes);
   // not connected, WPS enabled, no pass - first attempt
@@ -755,29 +797,6 @@ void AsyncWiFiManager::startWPS()
   DEBUG_WM(F("END WPS"));
 }
 #endif
-
-/*
-String AsyncWiFiManager::getSSID() {
-if (_ssid == "") {
-DEBUG_WM(F("Reading SSID"));
-_ssid = WiFi.SSID();
-DEBUG_WM(F("SSID: "));
-DEBUG_WM(_ssid);
-}
-return _ssid;
-}
-
-String AsyncWiFiManager::getPassword() {
-if (_pass == "") {
-DEBUG_WM(F("Reading Password"));
-_pass = WiFi.psk();
-DEBUG_WM(F("Password: ") + _pass);
-//DEBUG_WM(_pass);
-}
-return _pass;
-}
-*/
-
 String AsyncWiFiManager::getConfigPortalSSID()
 {
   return _apName;
@@ -824,14 +843,20 @@ void AsyncWiFiManager::setDebugOutput(boolean debug)
   _debug = debug;
 }
 
-void AsyncWiFiManager::setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn)
+void AsyncWiFiManager::setAPStaticIPConfig(IPAddress ip,
+                                           IPAddress gw,
+                                           IPAddress sn)
 {
   _ap_static_ip = ip;
   _ap_static_gw = gw;
   _ap_static_sn = sn;
 }
 
-void AsyncWiFiManager::setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn, IPAddress dns1, IPAddress dns2)
+void AsyncWiFiManager::setSTAStaticIPConfig(IPAddress ip,
+                                            IPAddress gw,
+                                            IPAddress sn,
+                                            IPAddress dns1,
+                                            IPAddress dns2)
 {
   _sta_static_ip = ip;
   _sta_static_gw = gw;
@@ -840,7 +865,7 @@ void AsyncWiFiManager::setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddres
   _sta_static_dns2 = dns2;
 }
 
-void AsyncWiFiManager::setMinimumSignalQuality(int quality)
+void AsyncWiFiManager::setMinimumSignalQuality(unsigned int quality)
 {
   _minimumQuality = quality;
 }
@@ -855,11 +880,14 @@ void AsyncWiFiManager::handleRoot(AsyncWebServerRequest *request)
 {
   // AJS - maybe we should set a scan when we get to the root???
   // and only scan on demand? timer + on demand? plus a link to make it happen?
+
   shouldscan = true;
   scannow = 0;
   DEBUG_WM(F("Handle root"));
+
   if (captivePortal(request))
-  { // If captive portal redirect instead of displaying the page.
+  {
+    // if captive portal redirect instead of displaying the page
     return;
   }
 
@@ -910,10 +938,8 @@ void AsyncWiFiManager::handleWifi(AsyncWebServerRequest *request, boolean scan)
     }
     else
     {
-
       // display networks in page
       String pager = networkListAsString();
-
       page += pager;
       page += "<br/>";
     }
@@ -922,8 +948,9 @@ void AsyncWiFiManager::handleWifi(AsyncWebServerRequest *request, boolean scan)
 
   page += FPSTR(HTTP_FORM_START);
   char parLength[2];
+
   // add the extra parameters to the form
-  for (int i = 0; i < _paramsCount; i++)
+  for (unsigned int i = 0; i < _paramsCount; i++)
   {
     if (_params[i] == NULL)
     {
@@ -952,10 +979,8 @@ void AsyncWiFiManager::handleWifi(AsyncWebServerRequest *request, boolean scan)
   {
     page += "<br/>";
   }
-
   if (_sta_static_ip)
   {
-
     String item = FPSTR(HTTP_FORM_PARAM);
     item.replace("{i}", "ip");
     item.replace("{n}", "ip");
@@ -1000,13 +1025,10 @@ void AsyncWiFiManager::handleWifi(AsyncWebServerRequest *request, boolean scan)
     item.replace("{v}", _sta_static_dns2.toString());
 
     page += item;
-
     page += "<br/>";
   }
-
   page += FPSTR(HTTP_FORM_END);
   page += FPSTR(HTTP_SCAN_LINK);
-
   page += FPSTR(HTTP_END);
 
   request->send(200, "text/html", page);
@@ -1025,7 +1047,7 @@ void AsyncWiFiManager::handleWifiSave(AsyncWebServerRequest *request)
   _pass = request->arg("p").c_str();
 
   // parameters
-  for (int i = 0; i < _paramsCount; i++)
+  for (unsigned int i = 0; i < _paramsCount; i++)
   {
     if (_params[i] == NULL)
     {
@@ -1035,6 +1057,7 @@ void AsyncWiFiManager::handleWifiSave(AsyncWebServerRequest *request)
     String value = request->arg(_params[i]->getID()).c_str();
     // store it in array
     value.toCharArray(_params[i]->_value, _params[i]->_length);
+
     DEBUG_WM(F("Parameter"));
     DEBUG_WM(_params[i]->getID());
     DEBUG_WM(value);
@@ -1151,7 +1174,9 @@ void AsyncWiFiManager::handleInfo(AsyncWebServerRequest *request)
   page += FPSTR(HTTP_STYLE);
   page += _customHeadElement;
   if (connect == true)
+  {
     page += F("<meta http-equiv=\"refresh\" content=\"5; url=/i\">");
+  }
   page += FPSTR(HTTP_HEAD_END);
   page += F("<dl>");
   if (connect == true)
@@ -1160,7 +1185,6 @@ void AsyncWiFiManager::handleInfo(AsyncWebServerRequest *request)
     page += wifiStatus;
     page += F("</dd>");
   }
-
   page += pager;
   page += FPSTR(HTTP_END);
 
@@ -1194,17 +1218,6 @@ void AsyncWiFiManager::handleReset(AsyncWebServerRequest *request)
   delay(2000);
 }
 
-// removed as mentioned here https://github.com/tzapu/AsyncWiFiManager/issues/114
-/*
-void AsyncWiFiManager::handle204(AsyncWebServerRequest *request) {
-DEBUG_WM(F("204 No Response"));
-request->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
-request->sendHeader("Pragma", "no-cache");
-request->sendHeader("Expires", "-1");
-request->send ( 204, "text/plain", "");
-}
-*/
-
 void AsyncWiFiManager::handleNotFound(AsyncWebServerRequest *request)
 {
   DEBUG_WM(F("Handle not found"));
@@ -1213,6 +1226,7 @@ void AsyncWiFiManager::handleNotFound(AsyncWebServerRequest *request)
     // if captive portal redirect instead of displaying the error page
     return;
   }
+
   String message = "File Not Found\n\n";
   message += "URI: ";
   message += request->url();
@@ -1222,7 +1236,7 @@ void AsyncWiFiManager::handleNotFound(AsyncWebServerRequest *request)
   message += request->args();
   message += "\n";
 
-  for (uint8_t i = 0; i < request->args(); i++)
+  for (unsigned int i = 0; i < request->args(); i++)
   {
     message += " " + request->argName(i) + ": " + request->arg(i) + "\n";
   }
@@ -1288,9 +1302,9 @@ void AsyncWiFiManager::DEBUG_WM(Generic text)
   }
 }
 
-int AsyncWiFiManager::getRSSIasQuality(int RSSI)
+unsigned int AsyncWiFiManager::getRSSIasQuality(int RSSI)
 {
-  int quality = 0;
+  unsigned int quality = 0;
 
   if (RSSI <= -100)
   {

+ 34 - 17
src/ESPAsyncWiFiManager.h

@@ -67,23 +67,34 @@ class AsyncWiFiManagerParameter
 {
 public:
   AsyncWiFiManagerParameter(const char *custom);
-  AsyncWiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length);
-  AsyncWiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom);
+  AsyncWiFiManagerParameter(const char *id,
+                            const char *placeholder,
+                            const char *defaultValue,
+                            unsigned int length);
+  AsyncWiFiManagerParameter(const char *id,
+                            const char *placeholder,
+                            const char *defaultValue,
+                            unsigned int length,
+                            const char *custom);
 
   const char *getID();
   const char *getValue();
   const char *getPlaceholder();
-  int getValueLength();
+  unsigned int getValueLength();
   const char *getCustomHTML();
 
 private:
   const char *_id;
   const char *_placeholder;
   char *_value;
-  int _length;
+  unsigned int _length;
   const char *_customHTML;
 
-  void init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom);
+  void init(const char *id,
+            const char *placeholder,
+            const char *defaultValue,
+            unsigned int length,
+            const char *custom);
 
   friend class AsyncWiFiManager;
 };
@@ -120,8 +131,12 @@ public:
   void criticalLoop();
   String infoAsString();
 
-  boolean autoConnect(unsigned long maxConnectRetries = 1, unsigned long retryDelayMs = 1000);
-  boolean autoConnect(char const *apName, char const *apPassword = NULL, unsigned long maxConnectRetries = 1, unsigned long retryDelayMs = 1000);
+  boolean autoConnect(unsigned long maxConnectRetries = 1,
+                      unsigned long retryDelayMs = 1000);
+  boolean autoConnect(char const *apName,
+                      char const *apPassword = NULL,
+                      unsigned long maxConnectRetries = 1,
+                      unsigned long retryDelayMs = 1000);
 
   // if you want to always start the config portal, without trying to connect first
   boolean startConfigPortal(char const *apName, char const *apPassword = NULL);
@@ -147,11 +162,15 @@ public:
 
   void setDebugOutput(boolean debug);
   // defaults to not showing anything under 8% signal quality if called
-  void setMinimumSignalQuality(int quality = 8);
+  void setMinimumSignalQuality(unsigned int quality = 8);
   // sets a custom ip /gateway /subnet configuration
   void setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
   // sets config for a static IP
-  void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
+  void setSTAStaticIPConfig(IPAddress ip,
+                            IPAddress gw,
+                            IPAddress sn,
+                            IPAddress dns1 = (uint32_t)0x00000000,
+                            IPAddress dns2 = (uint32_t)0x00000000);
   // called when AP mode and config portal is started
   void setAPCallback(void (*func)(AsyncWiFiManager *));
   // called when settings have been changed and connection was successful
@@ -179,12 +198,11 @@ private:
 
   boolean _modeless;
   unsigned long scannow;
-  int shouldscan;
+  boolean shouldscan = true;
   boolean needInfo = true;
 
   //const int     WM_DONE                 = 0;
   //const int     WM_WAIT                 = 10;
-
   //const String  HTTP_HEAD = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/><title>{v}</title>";
 
   void setupConfigPortal();
@@ -210,8 +228,8 @@ private:
   IPAddress _sta_static_dns1 = (uint32_t)0x00000000;
   IPAddress _sta_static_dns2 = (uint32_t)0x00000000;
 
-  int _paramsCount = 0;
-  int _minimumQuality = -1;
+  unsigned int _paramsCount = 0;
+  unsigned int _minimumQuality = 0;
   boolean _removeDuplicateAPs = true;
   boolean _shouldBreakAfterConfig = false;
 #ifdef NO_EXTRA_4K_HEAP
@@ -223,8 +241,8 @@ private:
   //String        getEEPROMString(int start, int len);
   //void          setEEPROMString(int start, int len, String string);
 
-  int status = WL_IDLE_STATUS;
-  int connectWifi(String ssid, String pass);
+  uint8_t status = WL_IDLE_STATUS;
+  uint8_t connectWifi(String ssid, String pass);
   uint8_t waitForConnectResult();
   void setInfo();
   void copySSIDInfo(wifi_ssid_count_t n);
@@ -236,14 +254,13 @@ private:
   void handleInfo(AsyncWebServerRequest *);
   void handleReset(AsyncWebServerRequest *);
   void handleNotFound(AsyncWebServerRequest *);
-  void handle204(AsyncWebServerRequest *);
   boolean captivePortal(AsyncWebServerRequest *);
 
   // DNS server
   const byte DNS_PORT = 53;
 
   // helpers
-  int getRSSIasQuality(int RSSI);
+  unsigned int getRSSIasQuality(int RSSI);
   boolean isIp(String str);
   String toStringIp(IPAddress ip);