Fix webserver enhanced wifi scan

This commit is contained in:
Theo Arends 2021-04-13 16:04:22 +02:00
parent 3751a3ff07
commit 22fcf5061d
1 changed files with 17 additions and 29 deletions

View File

@ -1822,11 +1822,12 @@ void HandleWifiConfiguration(void) {
DEBUG_CORE_LOG(PSTR(D_LOG_WIFI D_SSID " %s, " D_BSSID " %s, " D_CHANNEL " %d, " D_RSSI " %d"), DEBUG_CORE_LOG(PSTR(D_LOG_WIFI D_SSID " %s, " D_BSSID " %s, " D_CHANNEL " %d, " D_RSSI " %d"),
ssid.c_str(), WiFi.BSSIDstr(indices[i]).c_str(), WiFi.channel(indices[i]), rssi); ssid.c_str(), WiFi.BSSIDstr(indices[i]).c_str(), WiFi.channel(indices[i]), rssi);
String ssid_copy = ssid;
if (!ssid_copy.length()) { ssid_copy = F("no_name"); }
// Print SSID // Print SSID
if (!limitScannedNetworks) { if (!limitScannedNetworks) {
WSContentSend_P(PSTR("<div><a href='#p' onclick='c(this)'>%s</a><br>"), HtmlEscape(ssid).c_str()); WSContentSend_P(PSTR("<div><a href='#p' onclick='c(this)'>%s</a><br>"), HtmlEscape(ssid_copy).c_str());
} }
skipduplicated = false; skipduplicated = false;
String nextSSID = ""; String nextSSID = "";
// Handle all APs with the same SSID // Handle all APs with the same SSID
@ -1838,29 +1839,22 @@ void HandleWifiConfiguration(void) {
uint32_t rssi_as_quality = WifiGetRssiAsQuality(rssi); uint32_t rssi_as_quality = WifiGetRssiAsQuality(rssi);
uint32_t num_bars = changeUIntScale(rssi_as_quality, 0, 100, 0, 4); uint32_t num_bars = changeUIntScale(rssi_as_quality, 0, 100, 0, 4);
WSContentSend_P(PSTR("<div title='%d dBm (%d%%)'>"), rssi, rssi_as_quality);
if (limitScannedNetworks) { if (limitScannedNetworks) {
// Print SSID and item // Print SSID and item
WSContentSend_P(PSTR("<div title='%d dBm (%d%%)'><a href='#p' onclick='c(this)'>%s</a><span class='q'><div class='si'>"), rssi, rssi_as_quality, HtmlEscape(ssid).c_str()); WSContentSend_P(PSTR("<a href='#p' onclick='c(this)'>%s</a><span class='q'><div class='si'>"), HtmlEscape(ssid_copy).c_str());
// Print signal strength indicator
for (uint32_t k = 0; k < 4; ++k) {
WSContentSend_P(PSTR("<i class='b%d%s'></i>"), k, (num_bars < k) ? PSTR(" o30") : PSTR(""));
}
WSContentSend_P(PSTR("</span></div>"));
ssid_showed++; ssid_showed++;
skipduplicated = true; // For the simplified page, just show 1 SSID if there are many Networks with the same skipduplicated = true; // For the simplified page, just show 1 SSID if there are many Networks with the same
} else { } else {
// Print item // Print item
WSContentSend_P(PSTR("<div title='%d dBm (%d%%)'>%s<span class='q'>(%d) <div class='si'>"), WSContentSend_P(PSTR("%s<span class='q'>(%d) <div class='si'>"), WiFi.BSSIDstr(indices[j]).c_str(), WiFi.channel(indices[j])
rssi, rssi_as_quality,
WiFi.BSSIDstr(indices[j]).c_str(),
WiFi.channel(indices[j])
); );
// Print signal strength indicator
for (uint32_t k = 0; k < 4; ++k) {
WSContentSend_P(PSTR("<i class='b%d%s'></i>"), k, (num_bars < k) ? PSTR(" o30") : PSTR(""));
}
WSContentSend_P(PSTR("</span></div></div>"));
} }
// Print signal strength indicator
for (uint32_t k = 0; k < 4; ++k) {
WSContentSend_P(PSTR("<i class='b%d%s'></i>"), k, (num_bars < k) ? PSTR(" o30") : PSTR(""));
}
WSContentSend_P(PSTR("</span></div></div>"));
} else { } else {
if (ssid_showed <= networksToShow ) { networksToShow++; } if (ssid_showed <= networksToShow ) { networksToShow++; }
} }
@ -1868,7 +1862,9 @@ void HandleWifiConfiguration(void) {
} }
delay(0); delay(0);
} }
WSContentSend_P(PSTR("</div>")); if (!limitScannedNetworks) {
WSContentSend_P(PSTR("</div>"));
}
} }
} }
#else // No USE_ENHANCED_GUI_WIFI_SCAN #else // No USE_ENHANCED_GUI_WIFI_SCAN
@ -1892,18 +1888,10 @@ void HandleWifiConfiguration(void) {
DEBUG_CORE_LOG(PSTR(D_LOG_WIFI D_SSID " %s, " D_BSSID " %s, " D_CHANNEL " %d, " D_RSSI " %d"), DEBUG_CORE_LOG(PSTR(D_LOG_WIFI D_SSID " %s, " D_BSSID " %s, " D_CHANNEL " %d, " D_RSSI " %d"),
WiFi.SSID(indices[i]).c_str(), WiFi.BSSIDstr(indices[i]).c_str(), WiFi.channel(indices[i]), rssi); WiFi.SSID(indices[i]).c_str(), WiFi.BSSIDstr(indices[i]).c_str(), WiFi.channel(indices[i]), rssi);
int quality = WifiGetRssiAsQuality(rssi); int quality = WifiGetRssiAsQuality(rssi);
/* String ssid_copy = WiFi.SSID(indices[i]);
int auth = WiFi.encryptionType(indices[i]); if (!ssid_copy.length()) { ssid_copy = F("no_name"); }
char encryption[20];
WSContentSend_P(PSTR("<div><a href='#p' onclick='c(this)'>%s</a>&nbsp;(%d)&nbsp<span class='q'>%s %d%% (%d dBm)</span></div>"),
HtmlEscape(WiFi.SSID(indices[i])).c_str(),
WiFi.channel(indices[i]),
GetTextIndexed(encryption, sizeof(encryption), auth +1, kEncryptionType),
quality, rssi
);
*/
WSContentSend_P(PSTR("<div><a href='#p' onclick='c(this)'>%s</a>&nbsp;(%d)&nbsp<span class='q'>%d%% (%d dBm)</span></div>"), WSContentSend_P(PSTR("<div><a href='#p' onclick='c(this)'>%s</a>&nbsp;(%d)&nbsp<span class='q'>%d%% (%d dBm)</span></div>"),
HtmlEscape(WiFi.SSID(indices[i])).c_str(), HtmlEscape(ssid_copy).c_str(),
WiFi.channel(indices[i]), WiFi.channel(indices[i]),
quality, rssi quality, rssi
); );