Skip to content

Commit 2582dd8

Browse files
committed
version 0.10
ordered networks based on signal quality
1 parent f82141c commit 2582dd8

File tree

5 files changed

+33
-17
lines changed

5 files changed

+33
-17
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ First attempt at a library. Lots more changes and fixes to do. Contributions are
1818
- [Documentation](#documentation)
1919
- [Access Point Password](#password-protect-the-configuration-access-point)
2020
- [Callbacks](#callbacks)
21-
- [Timeout](#timeout)
21+
- [Configuration Portal Timeout](#configuration-portal-timeout)
2222
- [On Demand Configuration](#on-demand-configuration-portal)
2323
- [Custom Parameters](#custom-parameters)
2424
- [Custom IP Configuration](#custom-ip-configuration)
@@ -149,10 +149,10 @@ void saveConfigCallback () {
149149
}
150150
```
151151

152-
#### Timeout
152+
#### Configuration Portal Timeout
153153
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
154154
```cpp
155-
wifiManager.setTimeout(180);
155+
wifiManager.setConfigPortalTimeout(180);
156156
```
157157
which will wait 3 minutes (180 seconds). When the time passes, the autoConnect function will return, no matter the outcome.
158158
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)

WiFiManager.cpp

+26-9
Original file line numberDiff line numberDiff line change
@@ -352,21 +352,38 @@ void WiFiManager::handleWifi(boolean scan) {
352352
if (n == 0) {
353353
DEBUG_WM(F("No networks found"));
354354
page += F("No networks found. Refresh to scan again.");
355-
}
356-
else {
357-
for (int i = 0; i < n; ++i)
358-
{
359-
DEBUG_WM(WiFi.SSID(i));
360-
DEBUG_WM(WiFi.RSSI(i));
361-
int quality = getRSSIasQuality(WiFi.RSSI(i));
355+
} else {
356+
//sort networks
357+
int indices[n];
358+
359+
for (int i = 0; i < n; i++) {
360+
indices[i] = i;
361+
}
362+
363+
for (int i = 0; i < n; i++) {
364+
for (int j = i + 1; j < n; j++) {
365+
if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) {
366+
//int temp = indices[j];
367+
//indices[j] = indices[i];
368+
//indices[i] = temp;
369+
std::swap(indices[i], indices[j]);
370+
}
371+
}
372+
}
373+
374+
//display networks in page
375+
for (int i = 0; i < n; i++) {
376+
DEBUG_WM(WiFi.SSID(indices[i]));
377+
DEBUG_WM(WiFi.RSSI(indices[i]));
378+
int quality = getRSSIasQuality(WiFi.RSSI(indices[i]));
362379

363380
if (_minimumQuality == -1 || _minimumQuality < quality) {
364381
String item = FPSTR(HTTP_ITEM);
365382
String rssiQ;
366383
rssiQ += quality;
367-
item.replace("{v}", WiFi.SSID(i));
384+
item.replace("{v}", WiFi.SSID(indices[i]));
368385
item.replace("{r}", rssiQ);
369-
if (WiFi.encryptionType(i) != ENC_TYPE_NONE) {
386+
if (WiFi.encryptionType(indices[i]) != ENC_TYPE_NONE) {
370387
item.replace("{i}", "l");
371388
} else {
372389
item.replace("{i}", "");

keywords.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ getSSID KEYWORD2
1818
getPassword KEYWORD2
1919
getConfigPortalSSID KEYWORD2
2020
resetSettings KEYWORD2
21-
urldecode KEYWORD2
22-
setTimeout KEYWORD2
21+
setConfigPortalTimeout KEYWORD2
22+
setConnectTimeout KEYWORD2
2323
setDebugOutput KEYWORD2
2424
setMinimumSignalQuality KEYWORD2
2525
setAPStaticIPConfig KEYWORD2
2626
setSTAStaticIPConfig KEYWORD2
2727
setAPCallback KEYWORD2
2828
setSaveConfigCallback KEYWORD2
2929
addParameter KEYWORD2
30-
3130
getID KEYWORD2
3231
getValue KEYWORD2
3332
getPlaceholder KEYWORD2

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
},
1010
"frameworks": "arduino",
1111
"platforms": "espressif",
12-
"version": "0.9"
12+
"version": "0.10"
1313
}

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=WiFiManager
2-
version=0.9
2+
version=0.10
33
author=tzapu
44
maintainer=tzapu
55
sentence=ESP8266 WiFi Connection manager with fallback web configuration portal

0 commit comments

Comments
 (0)