mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
cleaning up .h
This commit is contained in:
+68
-11
@@ -163,8 +163,10 @@ class WiFiManager
|
||||
|
||||
//manually start the web portal, autoconnect does this automatically on connect failure
|
||||
void startWebPortal();
|
||||
|
||||
//manually stop the web portal if started manually
|
||||
void stopWebPortal();
|
||||
|
||||
// Run webserver processing, if setConfigPortalBlocking(false)
|
||||
boolean process();
|
||||
|
||||
@@ -174,34 +176,43 @@ class WiFiManager
|
||||
|
||||
// erase wifi credentials
|
||||
void resetSettings();
|
||||
|
||||
// reboot esp
|
||||
void reboot();
|
||||
|
||||
// disconnect wifi, without persistent saving or erasing
|
||||
bool disconnect();
|
||||
|
||||
// erase esp
|
||||
bool erase();
|
||||
bool erase(bool opt);
|
||||
|
||||
//adds a custom parameter, returns false on failure
|
||||
bool addParameter(WiFiManagerParameter *p);
|
||||
|
||||
//returns the list of Parameters
|
||||
WiFiManagerParameter** getParameters();
|
||||
|
||||
// returns the Parameters Count
|
||||
int getParametersCount();
|
||||
|
||||
|
||||
// SET CALLBACKS
|
||||
|
||||
//called after AP mode and config portal has started
|
||||
void setAPCallback( std::function<void(WiFiManager*)> func );
|
||||
|
||||
//called after webserver has started
|
||||
void setWebServerCallback( std::function<void()> func );
|
||||
|
||||
//called when settings reset have been triggered
|
||||
void setConfigResetCallback( std::function<void()> func );
|
||||
|
||||
//called when wifi settings have been changed and connection was successful ( or setBreakAfterConfig(true) )
|
||||
void setSaveConfigCallback( std::function<void()> func );
|
||||
|
||||
//called when settings have been changed and connection was successful
|
||||
void setSaveParamsCallback( std::function<void()> func );
|
||||
|
||||
//called when settings before have been changed and connection was successful
|
||||
void setPreSaveConfigCallback( std::function<void()> func );
|
||||
|
||||
@@ -214,61 +225,86 @@ class WiFiManager
|
||||
|
||||
//sets timeout for which to attempt connecting, useful if you get a lot of failed connects
|
||||
void setConnectTimeout(unsigned long seconds);
|
||||
|
||||
//sets timeout for which to attempt connecting on saves, useful if there are bugs in esp waitforconnectloop
|
||||
void setSaveConnectTimeout(unsigned long seconds);
|
||||
|
||||
// toggle debug output
|
||||
void setDebugOutput(boolean debug);
|
||||
|
||||
//set min quality percentage to include in scan, defaults to 8% if not specified
|
||||
void setMinimumSignalQuality(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);
|
||||
|
||||
//sets config for a static IP with DNS
|
||||
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn, IPAddress dns);
|
||||
|
||||
//if this is set, it will exit after config, even if connection is unsuccessful.
|
||||
void setBreakAfterConfig(boolean shouldBreak);
|
||||
|
||||
// if this is set, portal will be blocking and wait until save or exit,
|
||||
// is false user must manually `process()` to handle config portal,
|
||||
// setConfigPortalTimeout is ignored in this mode, user is responsible for closing configportal
|
||||
void setConfigPortalBlocking(boolean shouldBlock);
|
||||
|
||||
//if this is set, customise style
|
||||
void setCustomHeadElement(const char* element);
|
||||
|
||||
//if this is true, remove duplicated Access Points - defaut true
|
||||
void setRemoveDuplicateAPs(boolean removeDuplicates);
|
||||
|
||||
//setter for ESP wifi.persistent so we can remember it and restore user preference, as WIFi._persistent is protected
|
||||
void setRestorePersistent(boolean persistent);
|
||||
|
||||
//if true, always show static net inputs, IP, subnet, gateway, else only show if set via setSTAStaticIPConfig
|
||||
void setShowStaticFields(boolean alwaysShow);
|
||||
|
||||
//if true, always show static dns, esle only show if set via setSTAStaticIPConfig
|
||||
void setShowDnsFields(boolean alwaysShow);
|
||||
|
||||
// toggle showing the saved wifi password in wifi form, could be a security issue.
|
||||
void setShowPassword(boolean show);
|
||||
|
||||
//if false, disable captive portal redirection
|
||||
void setCaptivePortalEnable(boolean enabled);
|
||||
|
||||
//if false, timeout captive portal even if a STA client connected to softAP (false), suggest disabling if captiveportal is open
|
||||
void setAPClientCheck(boolean enabled);
|
||||
|
||||
//if true, reset timeout when webclient connects (true), suggest disabling if captiveportal is open
|
||||
void setWebPortalClientCheck(boolean enabled);
|
||||
|
||||
// if true, enable autoreconnecting
|
||||
void setWiFiAutoReconnect(boolean enabled);
|
||||
|
||||
// if true, wifiscan will show percentage instead of quality icons, until we have better templating
|
||||
void setScanDispPerc(boolean enabled);
|
||||
|
||||
// if true (default) then start the config portal from autoConnect if connection failed
|
||||
void setEnableConfigPortal(boolean enable);
|
||||
|
||||
// set a custom hostname, sets sta and ap dhcp client id for esp32, and sta for esp8266
|
||||
bool setHostname(const char * hostname);
|
||||
|
||||
// show erase wifi onfig button on info page, true
|
||||
void setShowInfoErase(boolean enabled);
|
||||
|
||||
// set ap channel
|
||||
void setWiFiAPChannel(int32_t channel);
|
||||
|
||||
// set ap hidden
|
||||
void setWiFiAPHidden(bool hidden); // default false
|
||||
|
||||
// clean connect, always disconnect before connecting
|
||||
void setCleanConnect(bool enable); // default false
|
||||
|
||||
// set custom menu
|
||||
// set custom menu items and order
|
||||
// set custom menu items and order, vector or arr
|
||||
// see _menutokens for ids
|
||||
void setMenu(std::vector<const char*>& menu);
|
||||
void setMenu(const char* menu[], uint8_t size);
|
||||
|
||||
@@ -277,30 +313,41 @@ class WiFiManager
|
||||
|
||||
// get last connection result, includes autoconnect and wifisave
|
||||
uint8_t getLastConxResult();
|
||||
|
||||
// get a status as string
|
||||
String getWLStatusString(uint8_t status);
|
||||
|
||||
// get wifi mode as string
|
||||
String getModeString(uint8_t mode);
|
||||
|
||||
// check if the module has a saved ap to connect to
|
||||
bool getWiFiIsSaved();
|
||||
|
||||
// helper to get saved ssid, if persistent get stored, else get current if connected
|
||||
String getWiFiPass(bool persistent = false);
|
||||
|
||||
// helper to get saved password, if persistent get stored, else get current if connected
|
||||
String getWiFiSSID(bool persistent = false);
|
||||
|
||||
// debug output the softap config
|
||||
void debugSoftAPConfig();
|
||||
|
||||
// debug output platform info and versioning
|
||||
void debugPlatformInfo();
|
||||
|
||||
// helper for html
|
||||
String htmlEntities(String str);
|
||||
|
||||
// set the country code for wifi settings
|
||||
// set the country code for wifi settings, CN
|
||||
void setCountry(String cc);
|
||||
// set body class (invert)
|
||||
|
||||
// set body class (invert), may be used for hacking in alt classes in the future
|
||||
void setClass(String str);
|
||||
|
||||
// get default ap esp uses , esp_chipid etc
|
||||
String getDefaultAPName();
|
||||
|
||||
// set port of webserver
|
||||
// set port of webserver, 80
|
||||
void setHttpPort(uint16_t port);
|
||||
|
||||
std::unique_ptr<DNSServer> dnsServer;
|
||||
@@ -343,8 +390,8 @@ class WiFiManager
|
||||
unsigned long _webPortalAccessed = 0; // ms last web access time
|
||||
WiFiMode_t _usermode = WIFI_STA; // Default user mode
|
||||
String _wifissidprefix = FPSTR(S_ssidpre); // auto apname prefix prefix+chipid
|
||||
uint8_t _lastconxresult = WL_IDLE_STATUS;
|
||||
int _numNetworks = 0;
|
||||
uint8_t _lastconxresult = WL_IDLE_STATUS; // store last result when doing connect operations
|
||||
int _numNetworks = 0; // init index for numnetworks wifiscans
|
||||
unsigned long _lastscan = 0; // ms for timing wifi scans
|
||||
unsigned long _startscan = 0; // ms for timing wifi scans
|
||||
int _cpclosedelay = 2000; // delay before wifisave, prevents captive portal from closing to fast.
|
||||
@@ -384,22 +431,32 @@ class WiFiManager
|
||||
boolean _showInfoErase = true; // info page erase button
|
||||
boolean _showBack = false; // show back button
|
||||
boolean _enableConfigPortal = true; // use config portal if autoconnect failed
|
||||
const char * _hostname = "";
|
||||
const char * _hostname = ""; // hostname for esp8266 for dhcp, and or MDNS
|
||||
|
||||
const char* _customHeadElement = ""; // store custom head element html from user
|
||||
String _bodyClass = ""; // class to add to body
|
||||
|
||||
// internal options
|
||||
|
||||
// wifiscan notes
|
||||
// The following are background wifi scanning optimizations
|
||||
// experimental to make scans faster, preload scans after starting cp, and visiting home page, so when you click wifi its already has your list
|
||||
// ideally we would add async and xhr here but I am holding off on js requirements atm
|
||||
// might be slightly buggy since captive portals hammer the home page, @todo workaround this somehow.
|
||||
// cache time helps throttle this
|
||||
// async enables asyncronous scans, so they do not block anything
|
||||
// the refresh button bypasses cache
|
||||
boolean _preloadwifiscan = true; // preload wifiscan if true
|
||||
boolean _asyncScan = false;
|
||||
boolean _asyncScan = false; // perform wifi network scan async
|
||||
unsigned int _scancachetime = 30000; // ms cache time for background scans
|
||||
|
||||
boolean _disableIpFields = false; // modify function of setShow_X_Fields(false), forces ip fields off instead of default show if set, eg. _staShowStaticFields=-1
|
||||
|
||||
String _wificountry = ""; // country code, @todo define in strings lang
|
||||
|
||||
// wrapper functions for handling setting and unsetting persistent for now.
|
||||
bool esp32persistent = false;
|
||||
bool _hasBegun = false;
|
||||
bool _hasBegun = false; // flag wm loaded,unloaded
|
||||
void _begin();
|
||||
void _end();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user