added static mode

thanks @jonathanendersby
renamed private variables for more clarity
readme update
This commit is contained in:
Alex Tudorache
2016-01-17 13:27:24 +02:00
parent 598baf4451
commit e2bbd527d1
3 changed files with 35 additions and 29 deletions
+11 -7
View File
@@ -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
+16 -14
View File
@@ -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;
+8 -8
View File
@@ -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;