mirror of https://github.com/arendst/Tasmota.git
Merge pull request #7145 from RoadRunnr/rssi-in-dbm
report signal strength in dBm over MQTT
This commit is contained in:
commit
9ecb48c51e
|
@ -134,6 +134,7 @@
|
|||
#define D_JSON_SELECTED "selected"
|
||||
#define D_JSON_SERIALRECEIVED "SerialReceived"
|
||||
#define D_JSON_SET "Set"
|
||||
#define D_JSON_SIGNAL "Signal"
|
||||
#define D_JSON_SSID "SSId"
|
||||
#define D_JSON_STARTDST "StartDST" // Start Daylight Savings Time
|
||||
#define D_JSON_STARTED "Started"
|
||||
|
|
|
@ -51,7 +51,7 @@ void OsWatchTicker(void)
|
|||
uint32_t last_run = abs(t - oswatch_last_loop_time);
|
||||
|
||||
#ifdef DEBUG_THEO
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_OSWATCH " FreeRam %d, rssi %d, last_run %d"), ESP.getFreeHeap(), WifiGetRssiAsQuality(WiFi.RSSI()), last_run);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_OSWATCH " FreeRam %d, rssi %d %% (%d dBm), last_run %d"), ESP.getFreeHeap(), WifiGetRssiAsQuality(WiFi.RSSI()), WiFi.RSSI(), last_run);
|
||||
#endif // DEBUG_THEO
|
||||
if (last_run >= (OSWATCH_RESET_TIME * 1000)) {
|
||||
// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING)); // Save iram space
|
||||
|
|
|
@ -583,8 +583,9 @@ void MqttShowState(void)
|
|||
MqttShowPWMState();
|
||||
}
|
||||
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_WIFI "\":{\"" D_JSON_AP "\":%d,\"" D_JSON_SSID "\":\"%s\",\"" D_JSON_BSSID "\":\"%s\",\"" D_JSON_CHANNEL "\":%d,\"" D_JSON_RSSI "\":%d,\"" D_JSON_LINK_COUNT "\":%d,\"" D_JSON_DOWNTIME "\":\"%s\"}}"),
|
||||
Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], WiFi.BSSIDstr().c_str(), WiFi.channel(), WifiGetRssiAsQuality(WiFi.RSSI()), WifiLinkCount(), WifiDowntime().c_str());
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_WIFI "\":{\"" D_JSON_AP "\":%d,\"" D_JSON_SSID "\":\"%s\",\"" D_JSON_BSSID "\":\"%s\",\"" D_JSON_CHANNEL "\":%d,\"" D_JSON_RSSI "\":%d,\"" D_JSON_SIGNAL "\":%d,\"" D_JSON_LINK_COUNT "\":%d,\"" D_JSON_DOWNTIME "\":\"%s\"}}"),
|
||||
Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], WiFi.BSSIDstr().c_str(), WiFi.channel(),
|
||||
WifiGetRssiAsQuality(WiFi.RSSI()), WiFi.RSSI(), WifiLinkCount(), WifiDowntime().c_str());
|
||||
}
|
||||
|
||||
void MqttPublishTeleState(void)
|
||||
|
|
|
@ -1638,11 +1638,11 @@ void HandleWifiConfiguration(void)
|
|||
int quality = WifiGetRssiAsQuality(WiFi.RSSI(indices[i]));
|
||||
int auth = WiFi.encryptionType(indices[i]);
|
||||
char encryption[20];
|
||||
WSContentSend_P(PSTR("<div><a href='#p' onclick='c(this)'>%s</a> (%d) <span class='q'>%s %d%%</span></div>"),
|
||||
WSContentSend_P(PSTR("<div><a href='#p' onclick='c(this)'>%s</a> (%d) <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
|
||||
quality, WiFi.RSSI()
|
||||
);
|
||||
delay(0);
|
||||
|
||||
|
@ -1970,7 +1970,7 @@ void HandleInformation(void)
|
|||
WSContentSend_P(PSTR("}1" D_FRIENDLY_NAME " %d}2%s"), i +1, Settings.friendlyname[i]);
|
||||
}
|
||||
WSContentSend_P(PSTR("}1}2 ")); // Empty line
|
||||
WSContentSend_P(PSTR("}1" D_AP "%d " D_SSID " (" D_RSSI ")}2%s (%d%%)"), Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], WifiGetRssiAsQuality(WiFi.RSSI()));
|
||||
WSContentSend_P(PSTR("}1" D_AP "%d " D_SSID " (" D_RSSI ")}2%s (%d%%, %d dBm)"), Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], WifiGetRssiAsQuality(WiFi.RSSI()), WiFi.RSSI());
|
||||
WSContentSend_P(PSTR("}1" D_HOSTNAME "}2%s%s"), my_hostname, (Wifi.mdns_begun) ? ".local" : "");
|
||||
if (static_cast<uint32_t>(WiFi.localIP()) != 0) {
|
||||
WSContentSend_P(PSTR("}1" D_IP_ADDRESS "}2%s"), WiFi.localIP().toString().c_str());
|
||||
|
|
Loading…
Reference in New Issue