add setShowDnsFields, adds edge case force hide ip fields

This commit is contained in:
Shawn A
2018-03-16 10:56:12 -05:00
parent 03a40915ee
commit 424f48f0a8
2 changed files with 28 additions and 7 deletions
+18 -3
View File
@@ -950,7 +950,7 @@ String WiFiManager::getIpForm(String id, String title, String value){
String WiFiManager::getStaticOut(){
String page;
if (_staShowStaticFields || _sta_static_ip) {
if ((_staShowStaticFields || _sta_static_ip) && _staShowStaticFields>=0) {
page += FPSTR(HTTP_FORM_STATIC_HEAD);
// @todo how can we get these accurate settings from memory , wifi_get_ip_info does not seem to reveal if struct ip_info is static or not
page += getIpForm(FPSTR(S_ip),FPSTR(S_staticip),(_sta_static_ip ? _sta_static_ip.toString() : "")); // @token staticip
@@ -959,8 +959,10 @@ String WiFiManager::getStaticOut(){
// WiFi.gatewayIP().toString();
page += getIpForm(FPSTR(S_sn),FPSTR(S_subnet),(_sta_static_sn ? _sta_static_sn.toString() : "")); // @token subnet
// WiFi.subnetMask().toString();
}
if((_staShowDns || _sta_static_dns) && _staShowDns>=0){
page += getIpForm(FPSTR(S_dns),FPSTR(S_staticdns),(_sta_static_dns ? _sta_static_dns.toString() : "")); // @token dns
page += FPSTR(HTTP_BR); // @todo remove these, use css
}
return page;
}
@@ -1782,7 +1784,20 @@ void WiFiManager::setRestorePersistent(boolean persistent) {
* @param boolean alwaysShow [false]
*/
void WiFiManager::setShowStaticFields(boolean alwaysShow){
_staShowStaticFields = alwaysShow;
if(_disableIpFields) _staShowStaticFields = alwaysShow ? 1 : -1;
else _staShowStaticFields = alwaysShow ? 1 : 0;
}
/**
* toggle showing dns fields
* if enabled, then the dns1 field will be visible, even if not set in code
* @since $dev
* @access public
* @param boolean alwaysShow [false]
*/
void WiFiManager::setShowDnsFields(boolean alwaysShow){
if(_disableIpFields) _staShowDns = alwaysShow ? 1 : -1;
_staShowDns = alwaysShow ? 1 : 0;
}
/**
+10 -4
View File
@@ -200,8 +200,10 @@ class WiFiManager
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, if false, only show when already set.
//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);
//if false, disable captive portal redirection
void setCaptivePortalEnable(boolean enabled);
//if false, timeout captive portal even if a STA client connected (false), suggest disabling if captiveportal is open
@@ -286,13 +288,14 @@ class WiFiManager
uint8_t WL_STATION_WRONG_PASSWORD = 7; // @kludge define a WL status for wrong password
#endif
// option parameters
// parameter options
int _minimumQuality = -1; // filter wifiscan ap by this rssi
int _staShowStaticFields = 0; // ternary always show static ip fields, only if not set in code, never(cannot change ips via web!)
int _staShowDns = 0; // ternary always show dns, only if not set in code, never(cannot change dns via web!)
boolean _removeDuplicateAPs = true; // remove dup aps from wifiscan
boolean _shouldBreakAfterConfig = false; // stop configportal on save failure
boolean _tryWPS = false; // try WPS on save failure, unsupported
boolean _configPortalIsBlocking = true; // configportal enters blocking loop
boolean _staShowStaticFields = false; // always show static ip fields, even if not set in code
boolean _enableCaptivePortal = true; // enable captive portal redirection
boolean _userpersistent = true; // users preffered persistence to restore
boolean _wifiAutoReconnect = true; // there is no platform getter for this, we must assume its true and make it so
@@ -300,11 +303,14 @@ class WiFiManager
boolean _webClientCheck = true; // keep cp alive if web have client
boolean _scanDispOptions = false; // show percentage in scans not icons
boolean _paramsInWifi = true; // show custom parameters on wifi page
boolean _preloadwifiscan = true; // preload wifiscan
const char * _hostname = "";
const char* _customHeadElement = ""; // store custom head element html from user
// internal options
boolean _preloadwifiscan = true; // preload wifiscan if true
boolean _disableIpFields = false; // edge case, if true, showxFields(false) forces ip fields off instead of default show when set
void setupConfigPortal();
void startWPS();
bool startAP();