mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-17 16:41:31 +10:00
Merge pull request #365 from vyruz1986/master
Allow showing static IP config without predefined value
This commit is contained in:
+9
-7
@@ -138,15 +138,17 @@ void WiFiManager::setupConfigPortal() {
|
||||
|
||||
}
|
||||
|
||||
boolean WiFiManager::autoConnect() {
|
||||
boolean WiFiManager::autoConnect(boolean showStaticIPFields) {
|
||||
String ssid = "ESP" + String(ESP.getChipId());
|
||||
return autoConnect(ssid.c_str(), NULL);
|
||||
return autoConnect(ssid.c_str(), NULL, showStaticIPFields);
|
||||
}
|
||||
|
||||
boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
boolean WiFiManager::autoConnect(char const *apName, char const *apPassword, boolean showStaticIPFields) {
|
||||
DEBUG_WM(F(""));
|
||||
DEBUG_WM(F("AutoConnect"));
|
||||
|
||||
_sta_show_static_fields = showStaticIPFields;
|
||||
|
||||
// read eeprom for ssid and pass
|
||||
//String ssid = getSSID();
|
||||
//String pass = getPassword();
|
||||
@@ -532,14 +534,14 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
page += "<br/>";
|
||||
}
|
||||
|
||||
if (_sta_static_ip) {
|
||||
if (_sta_show_static_fields || _sta_static_ip) {
|
||||
|
||||
String item = FPSTR(HTTP_FORM_PARAM);
|
||||
item.replace("{i}", "ip");
|
||||
item.replace("{n}", "ip");
|
||||
item.replace("{p}", "Static IP");
|
||||
item.replace("{l}", "15");
|
||||
item.replace("{v}", _sta_static_ip.toString());
|
||||
item.replace("{v}", (_sta_static_ip ? _sta_static_ip.toString() : ""));
|
||||
|
||||
page += item;
|
||||
|
||||
@@ -548,7 +550,7 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
item.replace("{n}", "gw");
|
||||
item.replace("{p}", "Static Gateway");
|
||||
item.replace("{l}", "15");
|
||||
item.replace("{v}", _sta_static_gw.toString());
|
||||
item.replace("{v}", (_sta_static_gw ? _sta_static_gw.toString() : ""));
|
||||
|
||||
page += item;
|
||||
|
||||
@@ -557,7 +559,7 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
item.replace("{n}", "sn");
|
||||
item.replace("{p}", "Subnet");
|
||||
item.replace("{l}", "15");
|
||||
item.replace("{v}", _sta_static_sn.toString());
|
||||
item.replace("{v}", (_sta_static_sn ? _sta_static_sn.toString() : ""));
|
||||
|
||||
page += item;
|
||||
|
||||
|
||||
+4
-3
@@ -36,7 +36,7 @@ const char HTTP_SCAN_LINK[] PROGMEM = "<br/><div class=\"c\"><a href=\"/wi
|
||||
const char HTTP_SAVED[] PROGMEM = "<div>Credentials Saved<br />Trying to connect ESP to network.<br />If it fails reconnect to AP to try again</div>";
|
||||
const char HTTP_END[] PROGMEM = "</div></body></html>";
|
||||
|
||||
#define WIFI_MANAGER_MAX_PARAMS 10
|
||||
#define WIFI_MANAGER_MAX_PARAMS 20
|
||||
|
||||
#define WFM_LABEL_BEFORE 1
|
||||
#define WFM_LABEL_AFTER 2
|
||||
@@ -75,8 +75,8 @@ class WiFiManager
|
||||
public:
|
||||
WiFiManager();
|
||||
|
||||
boolean autoConnect();
|
||||
boolean autoConnect(char const *apName, char const *apPassword = NULL);
|
||||
boolean autoConnect(boolean showStaticIPFields = false);
|
||||
boolean autoConnect(char const *apName, char const *apPassword = NULL, boolean showStaticIPFields = false);
|
||||
|
||||
//if you want to always start the config portal, without trying to connect first
|
||||
boolean startConfigPortal();
|
||||
@@ -145,6 +145,7 @@ class WiFiManager
|
||||
IPAddress _sta_static_ip;
|
||||
IPAddress _sta_static_gw;
|
||||
IPAddress _sta_static_sn;
|
||||
boolean _sta_show_static_fields = false;
|
||||
|
||||
int _paramsCount = 0;
|
||||
int _minimumQuality = -1;
|
||||
|
||||
Reference in New Issue
Block a user