Skip to content

Commit

Permalink
Add BSSID and Signal Strength Indicator to GUI wifi scan result (#10253)
Browse files Browse the repository at this point in the history
Add BSSID and Signal Strength Indicator to GUI wifi scan result (#10253)
  • Loading branch information
arendst committed Dec 27, 2020
1 parent 31fedcb commit 83b3aa5
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- Gpio ``Option_a1`` enabling PWM2 high impedance if powered off as used by Wyze bulbs (#10196)
- Support for FTC532 8-button touch controller by Peter Franck (#10222)
- Support character `#` to be replaced by `space`-character in command ``Publish`` topic (#10258)
- BSSID and Signal Strength Indicator to GUI wifi scan result (#10253)

### Changed
- Logging from fixed global memory buffer to stack buffer freeing 700 bytes RAM
Expand Down
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
- Gpio ``Option_a1`` enabling PWM2 high impedance if powered off as used by Wyze bulbs [#10196](https://github.com/arendst/Tasmota/issues/10196)
- Support for FTC532 8-button touch controller by Peter Franck [#10222](https://github.com/arendst/Tasmota/issues/10222)
- Support character `#` to be replaced by `space`-character in command ``Publish`` topic [#10258](https://github.com/arendst/Tasmota/issues/10258)
- BSSID and Signal Strength Indicator to GUI wifi scan result [#10253](https://github.com/arendst/Tasmota/issues/10253)

### Changed
- Logging from fixed global memory buffer to stack buffer freeing 700 bytes RAM
Expand Down
1 change: 1 addition & 0 deletions tasmota/my_user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@
#define WEB_PORT 80 // Web server Port for User and Admin mode
#define WEB_USERNAME "admin" // Web server Admin mode user name
// #define USE_JAVASCRIPT_ES6 // Enable ECMAScript6 syntax using less JavaScript code bytes (fails on IE11)
#define USE_ENHANCED_GUI_WIFI_SCAN // Enable wifi scan output with BSSID (+0k5 code)
// #define USE_WEBSEND_RESPONSE // Enable command WebSend response message (+1k code)
#define USE_EMULATION_HUE // Enable Hue Bridge emulation for Alexa (+14k code, +2k mem common)
#define USE_EMULATION_WEMO // Enable Belkin WeMo emulation for Alexa (+6k code, +2k mem common)
Expand Down
3 changes: 3 additions & 0 deletions tasmota/tasmota_configurations.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@

#undef USE_KNX // Disable KNX IP Protocol Support
//#undef USE_WEBSERVER // Disable Webserver
#undef USE_ENHANCED_GUI_WIFI_SCAN // Disable wifi scan output with BSSID (+0k5 code)
//#undef USE_WEBSEND_RESPONSE // Disable command WebSend response message (+1k code)
#define USE_EMULATION // Enable Hue emulation
#define USE_EMULATION_HUE // Enable Hue Bridge emulation for Alexa (+14k code, +2k mem common)
Expand Down Expand Up @@ -607,6 +608,7 @@
#undef USE_MQTT_TLS // Disable TLS support won't work as the MQTTHost is not set
#undef USE_KNX // Disable KNX IP Protocol Support
//#undef USE_WEBSERVER // Disable Webserver
#undef USE_ENHANCED_GUI_WIFI_SCAN // Disable wifi scan output with BSSID (+0k5 code)
#undef USE_WEBSEND_RESPONSE // Disable command WebSend response message (+1k code)
//#undef USE_EMULATION // Disable Wemo or Hue emulation
//#undef USE_EMULATION_HUE // Disable Hue Bridge emulation for Alexa (+14k code, +2k mem common)
Expand Down Expand Up @@ -739,6 +741,7 @@
//#undef USE_MQTT_TLS // Disable TLS support won't work as the MQTTHost is not set
#undef USE_KNX // Disable KNX IP Protocol Support
//#undef USE_WEBSERVER // Disable Webserver
#undef USE_ENHANCED_GUI_WIFI_SCAN // Disable wifi scan output with BSSID (+0k5 code)
#undef USE_WEBSEND_RESPONSE // Disable command WebSend response message (+1k code)
#undef USE_EMULATION // Disable Wemo or Hue emulation
#undef USE_EMULATION_HUE // Disable Hue Bridge emulation for Alexa (+14k code, +2k mem common)
Expand Down
63 changes: 62 additions & 1 deletion tasmota/xdrv_01_webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,12 @@ const char HTTP_HEAD_STYLE_ZIGBEE[] PROGMEM =
#endif // USE_UNISHOX_COMPRESSION
#endif // USE_ZIGBEE

const char HTTP_HEAD_STYLE_SSI[] PROGMEM =
// Signal Strength Indicator
".si{display:inline-flex;align-items:flex-end;height:15px;padding:0}"
".si i{width:3px;margin-right:1px;border-radius:3px;background-color:#%06x}"
".si .b0{height:25%%}.si .b1{height:50%%}.si .b2{height:75%%}.si .b3{height:100%%}.o30{opacity:.3}";

const char HTTP_HEAD_STYLE3[] PROGMEM =
"</style>"

Expand Down Expand Up @@ -2084,7 +2090,11 @@ void HandleWifiConfiguration(void)

WSContentStart_P(PSTR(D_CONFIGURE_WIFI), !WifiIsInManagerMode());
WSContentSend_P(HTTP_SCRIPT_WIFI);
#ifdef USE_ENHANCED_GUI_WIFI_SCAN
WSContentSendStyle_P(HTTP_HEAD_STYLE_SSI, WebColor(COL_TEXT));
#else
WSContentSendStyle();
#endif // USE_ENHANCED_GUI_WIFI_SCAN

if (HTTP_MANAGER_RESET_ONLY != Web.state) {
if (Webserver->hasArg("scan")) {
Expand All @@ -2105,6 +2115,7 @@ void HandleWifiConfiguration(void)
indices[i] = i;
}


// RSSI SORT
for (uint32_t i = 0; i < n; i++) {
for (uint32_t j = i + 1; j < n; j++) {
Expand All @@ -2114,6 +2125,47 @@ void HandleWifiConfiguration(void)
}
}

#ifdef USE_ENHANCED_GUI_WIFI_SCAN
//display networks in page
for (uint32_t i = 0; i < n; i++) {
if (indices[i] < n) {
int32_t rssi = WiFi.RSSI(indices[i]);
String ssid = WiFi.SSID(indices[i]);
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);

// Print SSID
WSContentSend_P(PSTR("<div><a href='#p' onclick='c(this)'>%s</a><br>"), HtmlEscape(ssid).c_str());

String nextSSID = "";
// Handle all APs with the same SSID
for (uint32_t j = 0; j < n; j++) {
if ((indices[j] < n) && ((nextSSID = WiFi.SSID(indices[j])) == ssid)) {
// Update RSSI / quality
rssi = WiFi.RSSI(indices[j]);
uint32_t rssi_as_quality = WifiGetRssiAsQuality(rssi);
uint32_t num_bars = changeUIntScale(rssi_as_quality, 0, 100, 0, 4);

// Print item
WSContentSend_P(PSTR("<div title='%d dBm (%d%%)'>%s<span class='q'>(%d) <div class='si'>"),
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>"));

indices[j] = n;
}
delay(0);
}
WSContentSend_P(PSTR("</div>"));
}
}
#else // No USE_ENHANCED_GUI_WIFI_SCAN
// remove duplicates ( must be RSSI sorted )
String cssid;
for (uint32_t i = 0; i < n; i++) {
Expand All @@ -2135,6 +2187,7 @@ void HandleWifiConfiguration(void)
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);
int quality = WifiGetRssiAsQuality(rssi);
/*
int auth = WiFi.encryptionType(indices[i]);
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>"),
Expand All @@ -2143,9 +2196,17 @@ void HandleWifiConfiguration(void)
GetTextIndexed(encryption, sizeof(encryption), auth +1, kEncryptionType),
quality, rssi
);
delay(0);
*/
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(),
WiFi.channel(indices[i]),
quality, rssi
);

delay(0);
}
#endif // USE_ENHANCED_GUI_WIFI_SCAN

WSContentSend_P(PSTR("<br>"));
}
} else {
Expand Down

0 comments on commit 83b3aa5

Please sign in to comment.