From 8697cab0ae9d1402904a781edc2ab680e4de9fe0 Mon Sep 17 00:00:00 2001 From: Shawn A Date: Tue, 30 Jan 2018 14:02:01 -0600 Subject: [PATCH] clean up .h file --- WiFiManager.h | 83 ++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/WiFiManager.h b/WiFiManager.h index 40977e3..ebe9410 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -167,38 +167,26 @@ class WiFiManager std::unique_ptr dnsServer; std::unique_ptr server; - //const int WM_DONE = 0; - //const int WM_WAIT = 10; - - //const String HTTP_HEAD = "{v}"; - - void setupConfigPortal(); - void startWPS(); - bool startAP(); - - // typedef enum WiFiMode - // { - // WIFI_OFF = 0, WIFI_STA = 1, WIFI_AP = 2, WIFI_AP_STA = 3 - // } WiFiMode_t; - - String _apName = "no-net"; - String _apPassword = ""; - String _ssid = ""; - String _pass = ""; - unsigned long _configPortalTimeout = 0; - unsigned long _connectTimeout = 0; - unsigned long _configPortalStart = 0; - boolean _userpersistent = true; - WiFiMode_t _usermode = WIFI_OFF; - boolean _enableCaptivePortal = true; - + // ip configs IPAddress _ap_static_ip; IPAddress _ap_static_gw; IPAddress _ap_static_sn; IPAddress _sta_static_ip; IPAddress _sta_static_gw; IPAddress _sta_static_sn; - boolean _sta_show_static_fields = false; + + // defaults + const byte DNS_PORT = 53; + String _apName = "no-net"; + String _apPassword = ""; + String _ssid = ""; + String _pass = ""; + + // options flags + unsigned long _configPortalTimeout = 0; + unsigned long _connectTimeout = 0; + unsigned long _configPortalStart = 0; + WiFiMode_t _usermode = WIFI_OFF; // option parameters int _minimumQuality = -1; @@ -206,18 +194,22 @@ class WiFiManager boolean _shouldBreakAfterConfig = false; boolean _tryWPS = false; boolean _configPortalIsBlocking = true; + boolean _sta_show_static_fields = false; + boolean _enableCaptivePortal = true; + boolean _userpersistent = true; const char* _customHeadElement = ""; - //String getEEPROMString(int start, int len); - //void setEEPROMString(int start, int len, String string); + void setupConfigPortal(); + void startWPS(); + bool startAP(); int status = WL_IDLE_STATUS; int connectWifi(String ssid, String pass); uint8_t waitForConnectResult(); uint8_t waitForConnectResult(uint16_t timeout); - String getWLStatusString(uint8_t status); + // webserver handlers void handleRoot(); void handleWifi(boolean scan); void handleWifiSave(); @@ -231,6 +223,8 @@ class WiFiManager boolean configPortalHasTimeout(); boolean stopConfigPortal(); uint8_t handleConfigPortal(); + + // wifi platform abstractions bool WiFi_Mode(WiFiMode_t m); bool WiFi_Mode(WiFiMode_t m,bool persistent); bool WiFi_Disconnect(); @@ -239,14 +233,13 @@ class WiFiManager bool WiFi_eraseConfig(); void debugSoftAPConfig(); + // output helpers String getParamOut(); String getScanItemOut(); String getStaticOut(); - // DNS server - const byte DNS_PORT = 53; - //helpers + String getWLStatusString(uint8_t status); int getRSSIasQuality(int RSSI); boolean isIp(String str); String toStringIp(IPAddress ip); @@ -255,31 +248,33 @@ class WiFiManager void reportStatus(String &page); void debugPlatformInfo(); + // flags boolean connect; boolean abort; - boolean reset = false; + boolean reset = false; boolean configPortalActive = false; boolean webPortalActive = false; - boolean _debug = true; boolean portalTimeoutResult = false; boolean portalAbortResult = false; boolean storeSTAmode = true; // option store persistent STA mode in connectwifi int timer = 0; - - void (*_apcallback)(WiFiManager*) = NULL; - void (*_savecallback)(void) = NULL; - - Stream& _debugPort; // debug output stream ref - //WiFiManagerParameter - int _paramsCount = 0; - int _max_params; + // WiFiManagerParameter + int _paramsCount = 0; + int _max_params; WiFiManagerParameter** _params; + // debugging + boolean _debug = true; + Stream& _debugPort; // debug output stream ref template - void DEBUG_WM(Generic text); + void DEBUG_WM(Generic text); template - void DEBUG_WM(Generic text,Genericb textb); + void DEBUG_WM(Generic text,Genericb textb); + + // callbacks + void (*_apcallback)(WiFiManager*) = NULL; + void (*_savecallback)(void) = NULL; template auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {