Skip to content

Commit

Permalink
version 0.10
Browse files Browse the repository at this point in the history
ordered networks based on signal quality
  • Loading branch information
tzapu committed Feb 16, 2016
1 parent f82141c commit 2582dd8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ First attempt at a library. Lots more changes and fixes to do. Contributions are
- [Documentation](#documentation)
- [Access Point Password](#password-protect-the-configuration-access-point)
- [Callbacks](#callbacks)
- [Timeout](#timeout)
- [Configuration Portal Timeout](#configuration-portal-timeout)
- [On Demand Configuration](#on-demand-configuration-portal)
- [Custom Parameters](#custom-parameters)
- [Custom IP Configuration](#custom-ip-configuration)
Expand Down Expand Up @@ -149,10 +149,10 @@ void saveConfigCallback () {
}
```

#### Timeout
#### Configuration Portal Timeout
If you need to set a timeout so the ESP doesn't hang waiting to be configured, for instance after a power failure, you can add
```cpp
wifiManager.setTimeout(180);
wifiManager.setConfigPortalTimeout(180);
```
which will wait 3 minutes (180 seconds). When the time passes, the autoConnect function will return, no matter the outcome.
Check for connection and if it's still not established do whatever is needed (on some modules I restart them to retry, on others I enter deep sleep)
Expand Down
35 changes: 26 additions & 9 deletions WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,21 +352,38 @@ void WiFiManager::handleWifi(boolean scan) {
if (n == 0) {
DEBUG_WM(F("No networks found"));
page += F("No networks found. Refresh to scan again.");
}
else {
for (int i = 0; i < n; ++i)
{
DEBUG_WM(WiFi.SSID(i));
DEBUG_WM(WiFi.RSSI(i));
int quality = getRSSIasQuality(WiFi.RSSI(i));
} else {
//sort networks
int indices[n];

for (int i = 0; i < n; i++) {
indices[i] = i;
}

for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) {
//int temp = indices[j];
//indices[j] = indices[i];
//indices[i] = temp;
std::swap(indices[i], indices[j]);
}
}
}

//display networks in page
for (int i = 0; i < n; i++) {
DEBUG_WM(WiFi.SSID(indices[i]));
DEBUG_WM(WiFi.RSSI(indices[i]));
int quality = getRSSIasQuality(WiFi.RSSI(indices[i]));

if (_minimumQuality == -1 || _minimumQuality < quality) {
String item = FPSTR(HTTP_ITEM);
String rssiQ;
rssiQ += quality;
item.replace("{v}", WiFi.SSID(i));
item.replace("{v}", WiFi.SSID(indices[i]));
item.replace("{r}", rssiQ);
if (WiFi.encryptionType(i) != ENC_TYPE_NONE) {
if (WiFi.encryptionType(indices[i]) != ENC_TYPE_NONE) {
item.replace("{i}", "l");
} else {
item.replace("{i}", "");
Expand Down
5 changes: 2 additions & 3 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ getSSID KEYWORD2
getPassword KEYWORD2
getConfigPortalSSID KEYWORD2
resetSettings KEYWORD2
urldecode KEYWORD2
setTimeout KEYWORD2
setConfigPortalTimeout KEYWORD2
setConnectTimeout KEYWORD2
setDebugOutput KEYWORD2
setMinimumSignalQuality KEYWORD2
setAPStaticIPConfig KEYWORD2
setSTAStaticIPConfig KEYWORD2
setAPCallback KEYWORD2
setSaveConfigCallback KEYWORD2
addParameter KEYWORD2

getID KEYWORD2
getValue KEYWORD2
getPlaceholder KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
},
"frameworks": "arduino",
"platforms": "espressif",
"version": "0.9"
"version": "0.10"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=WiFiManager
version=0.9
version=0.10
author=tzapu
maintainer=tzapu
sentence=ESP8266 WiFi Connection manager with fallback web configuration portal
Expand Down

0 comments on commit 2582dd8

Please sign in to comment.