mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-21 10:12:37 +10:00
added AP quality
added padlock for secured networks moved more stuff to PROGMEM
This commit is contained in:
+21
-1
@@ -333,8 +333,17 @@ void WiFiManager::handleWifi(bool scan) {
|
|||||||
{
|
{
|
||||||
DEBUG_PRINT(WiFi.SSID(i));
|
DEBUG_PRINT(WiFi.SSID(i));
|
||||||
DEBUG_PRINT(WiFi.RSSI(i));
|
DEBUG_PRINT(WiFi.RSSI(i));
|
||||||
String item = HTTP_ITEM;
|
String item = FPSTR(HTTP_ITEM);
|
||||||
|
String rssiQ;
|
||||||
|
rssiQ += getRSSIasQuality(WiFi.RSSI(i));
|
||||||
item.replace("{v}", WiFi.SSID(i));
|
item.replace("{v}", WiFi.SSID(i));
|
||||||
|
item.replace("{r}", rssiQ);
|
||||||
|
if(WiFi.encryptionType(i) != ENC_TYPE_NONE) {
|
||||||
|
item.replace("{i}", FPSTR(HTTP_ITEM_PADLOCK));
|
||||||
|
} else {
|
||||||
|
item.replace("{i}", "");
|
||||||
|
}
|
||||||
|
//DEBUG_PRINT(item);
|
||||||
server->sendContent(item);
|
server->sendContent(item);
|
||||||
delay(0);
|
delay(0);
|
||||||
}
|
}
|
||||||
@@ -436,7 +445,18 @@ void WiFiManager::DEBUG_PRINT(Generic text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WiFiManager::getRSSIasQuality(int RSSI) {
|
||||||
|
int quality = 0;
|
||||||
|
|
||||||
|
if(RSSI <= -100){
|
||||||
|
quality = 0;
|
||||||
|
}else if(RSSI >= -50){
|
||||||
|
quality = 100;
|
||||||
|
} else {
|
||||||
|
quality = 2 * (RSSI + 100);
|
||||||
|
}
|
||||||
|
return quality;
|
||||||
|
}
|
||||||
|
|
||||||
/** Is this an IP? */
|
/** Is this an IP? */
|
||||||
boolean WiFiManager::isIp(String str) {
|
boolean WiFiManager::isIp(String str) {
|
||||||
|
|||||||
+6
-3
@@ -26,7 +26,8 @@ const char HTTP_200[] PROGMEM = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\
|
|||||||
const char HTTP_STYLE[] PROGMEM = "<style>div,input {margin-bottom: 5px;} body{width:200px;display:block;margin-left:auto;margin-right:auto;} button{padding:0.75rem 1rem;border:0;border-radius:0.317rem;background-color:#1fa3ec;color:#fff;line-height:1.5;cursor:pointer;}</style>";
|
const char HTTP_STYLE[] PROGMEM = "<style>div,input {margin-bottom: 5px;} body{width:200px;display:block;margin-left:auto;margin-right:auto;} button{padding:0.75rem 1rem;border:0;border-radius:0.317rem;background-color:#1fa3ec;color:#fff;line-height:1.5;cursor:pointer;}</style>";
|
||||||
const char HTTP_SCRIPT[] PROGMEM = "<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();}</script>";
|
const char HTTP_SCRIPT[] PROGMEM = "<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();}</script>";
|
||||||
const char HTTP_HEAD_END[] PROGMEM = "</head><body>";
|
const char HTTP_HEAD_END[] PROGMEM = "</head><body>";
|
||||||
//const char HTTP_ITEM[] PROGMEM = "<div><a href='#' onclick='c(this)'>{v}</a></div>";
|
const char HTTP_ITEM[] PROGMEM = "<div><a href='#' onclick='c(this)'>{v}</a> {r}% {i}</div>";
|
||||||
|
const char HTTP_ITEM_PADLOCK[] PROGMEM = "<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEUAAAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADl82K3AAAAEXRSTlMAABUbPD94e7G3vcDD5PD5/Mw7MxAAAABQSURBVHgBrck5FoAgEATRBmQBZen7X1acN6KJmRX+gsHMp1qTx8wIBErhBj96dC72sSkc8hC4KzTaCyybAgmJ/IDCVRHgKwVov8KTQOYqw5weJgaXesJX/wAAAABJRU5ErkJggg=='/>";
|
||||||
const char HTTP_FORM[] PROGMEM = "<form method='get' action='wifisave'><input id='s' name='s' length=32 placeholder='SSID'><input id='p' name='p' length=64 placeholder='password'><br/><button type='submit'>save</button></form>";
|
const char HTTP_FORM[] PROGMEM = "<form method='get' action='wifisave'><input id='s' name='s' length=32 placeholder='SSID'><input id='p' name='p' length=64 placeholder='password'><br/><button type='submit'>save</button></form>";
|
||||||
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_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 = "</body></html>";
|
const char HTTP_END[] PROGMEM = "</body></html>";
|
||||||
@@ -71,7 +72,7 @@ private:
|
|||||||
//const String HTTP_STYLE = "<style>div,input {margin-bottom: 5px;} body{width:200px;display:block;margin-left:auto;margin-right:auto;} button{padding:0.75rem 1rem;border:0;border-radius:0.317rem;background-color:#1fa3ec;color:#fff;line-height:1.5;cursor:pointer;}</style>";
|
//const String HTTP_STYLE = "<style>div,input {margin-bottom: 5px;} body{width:200px;display:block;margin-left:auto;margin-right:auto;} button{padding:0.75rem 1rem;border:0;border-radius:0.317rem;background-color:#1fa3ec;color:#fff;line-height:1.5;cursor:pointer;}</style>";
|
||||||
//const String HTTP_SCRIPT = "<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();}</script>";
|
//const String HTTP_SCRIPT = "<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();}</script>";
|
||||||
//const String HTTP_HEAD_END = "</head><body>";
|
//const String HTTP_HEAD_END = "</head><body>";
|
||||||
const String HTTP_ITEM = "<div><a href='#' onclick='c(this)'>{v}</a></div>";
|
//const String HTTP_ITEM = "<div><a href='#' onclick='c(this)'>{v}</a></div>";
|
||||||
//const String HTTP_FORM = "<form method='get' action='wifisave'><input id='s' name='s' length=32 placeholder='SSID'><input id='p' name='p' length=64 placeholder='password'><br/><button type='submit'>save</button></form>";
|
//const String HTTP_FORM = "<form method='get' action='wifisave'><input id='s' name='s' length=32 placeholder='SSID'><input id='p' name='p' length=64 placeholder='password'><br/><button type='submit'>save</button></form>";
|
||||||
//const String HTTP_SAVED = "<div>Credentials Saved<br />Trying to connect ESP to network.<br />If it fails reconnect to AP to try again</div>";
|
//const String HTTP_SAVED = "<div>Credentials Saved<br />Trying to connect ESP to network.<br />If it fails reconnect to AP to try again</div>";
|
||||||
//const String HTTP_END = "</body></html>";
|
//const String HTTP_END = "</body></html>";
|
||||||
@@ -110,7 +111,9 @@ private:
|
|||||||
|
|
||||||
// DNS server
|
// DNS server
|
||||||
const byte DNS_PORT = 53;
|
const byte DNS_PORT = 53;
|
||||||
|
|
||||||
|
//helpers
|
||||||
|
int getRSSIasQuality(int RSSI);
|
||||||
boolean isIp(String str);
|
boolean isIp(String str);
|
||||||
String toStringIp(IPAddress ip);
|
String toStringIp(IPAddress ip);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user