diff --git a/README.md b/README.md index 11150f6..5c34ebc 100644 --- a/README.md +++ b/README.md @@ -195,22 +195,22 @@ This feature is a lot more involved than all the others, so here are some exampl - *Save and load custom parameters to EEPROM* (not done yet) -### Custom IP Configuration +### Custom Access Point IP Configuration This will set your captive portal to a specific IP should you need/want such a feature. Add the following snippet before `autoConnect()` ```cpp //set custom ip for portal -wifiManager.setAPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); +wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); ``` -### Custom Static IP Configuration -This will make use the specified IP configuration instead of using DHCP. -``` -wifiManager.setStaticIPConfig(IPAddress(192,168,0,99), IPAddress(192,168,0,1), IPAddress(255,255,255,0)); +### Custom Station Static IP Configuration +This will make use the specified IP configuration instead of using DHCP in station mode. +```cpp +wifiManager.setSTAStaticIPConfig(IPAddress(192,168,0,99), IPAddress(192,168,0,1), IPAddress(255,255,255,0)); ``` #### Filter Networks If you would like to filter low signal quality networks you can tell WiFiManager to not show networks below an arbitrary quality %; -``` +```cpp wifiManager.setMinimumSignalQuality(10); ``` will not show networks under 10% signal quality. If you omit the parameter it defaults to 8%; @@ -277,6 +277,10 @@ __THANK YOU__ [SebiPanther](https://github.com/SebiPanther) +[jonathanendersby](https://github.com/jonathanendersby) + +[walthercarsten](https://github.com/walthercarsten) + Sorry if i have missed anyone. #### Inspiration diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 4acf038..b43efff 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -67,9 +67,9 @@ void WiFiManager::setupConfigPortal() { } //optional soft ip config - if (_ip) { - DEBUG_WM(F("Custom IP/GW/Subnet")); - WiFi.softAPConfig(_ip, _gw, _sn); + if (_ap_static_ip) { + DEBUG_WM(F("Custom AP IP/GW/Subnet")); + WiFi.softAPConfig(_ap_static_ip, _ap_static_gw, _ap_static_sn); } if (_apPassword != NULL) { @@ -115,8 +115,10 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { WiFi.mode(WIFI_STA); // check if we've got static_ip settings, if we do, use those. - if (_static_ip){ - WiFi.config(_static_ip, _static_gw, _static_sn); + if (_sta_static_ip) { + DEBUG_WM(F("Custom STA IP/GW/Subnet")); + WiFi.config(_sta_static_ip, _sta_static_gw, _sta_static_sn); + DEBUG_WM(WiFi.localIP()); } if (connectWifi(ssid, pass) == WL_CONNECTED) { @@ -266,16 +268,16 @@ void WiFiManager::setDebugOutput(boolean debug) { _debug = debug; } -void WiFiManager::setAPConfig(IPAddress ip, IPAddress gw, IPAddress sn) { - _ip = ip; - _gw = gw; - _sn = sn; +void WiFiManager::setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn) { + _ap_static_ip = ip; + _ap_static_gw = gw; + _ap_static_sn = sn; } -void WiFiManager::setStaticIPConfig(IPAddress static_ip, IPAddress static_gw, IPAddress static_sn) { - _static_ip = static_ip; - _static_gw = static_gw; - _static_sn = static_sn; +void WiFiManager::setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn) { + _sta_static_ip = ip; + _sta_static_gw = gw; + _sta_static_sn = sn; } void WiFiManager::setMinimumSignalQuality(int quality) { @@ -346,7 +348,7 @@ void WiFiManager::handleWifi(boolean scan) { DEBUG_WM(WiFi.SSID(i)); DEBUG_WM(WiFi.RSSI(i)); int quality = getRSSIasQuality(WiFi.RSSI(i)); - + if (_minimumQuality == -1 || _minimumQuality < quality) { String item = FPSTR(HTTP_ITEM); String rssiQ; diff --git a/WiFiManager.h b/WiFiManager.h index 5708644..1dc2e1e 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -83,9 +83,9 @@ class WiFiManager //defaults to not showing anything under 8% signal quality if called void setMinimumSignalQuality(int quality = 8); //sets a custom ip /gateway /subnet configuration - void setAPConfig(IPAddress ip, IPAddress gw, IPAddress sn); + void setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn); //sets config for a static IP - void setStaticIPConfig(IPAddress static_ip, IPAddress static_gw, IPAddress static_sn); + void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn); //called when AP mode and config portal is started void setAPCallback( void (*func)(WiFiManager*) ); //called when settings have been changed and connection was successful @@ -111,12 +111,12 @@ class WiFiManager String _pass = ""; unsigned long timeout = 0; unsigned long start = 0; - IPAddress _ip; - IPAddress _gw; - IPAddress _sn; - IPAddress _static_ip; - IPAddress _static_gw; - IPAddress _static_sn; + IPAddress _ap_static_ip; + IPAddress _ap_static_gw; + IPAddress _ap_static_sn; + IPAddress _sta_static_ip; + IPAddress _sta_static_gw; + IPAddress _sta_static_sn; int _paramsCount = 0; int _minimumQuality = -1;