mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add Network to MQTT info topic and system/info command
This commit is contained in:
@@ -979,6 +979,35 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
||||
node["Dallas sensors"] = EMSESP::sensor_devices().size();
|
||||
}
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
// Network
|
||||
node = output.createNestedObject("Network");
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
node["connection"] = F("WiFi");
|
||||
node["hostname"] = WiFi.getHostname();
|
||||
node["SSID"] = WiFi.SSID();
|
||||
node["BSSID"] = WiFi.BSSIDstr();
|
||||
node["RSSI"] = WiFi.RSSI();
|
||||
node["MAC"] = WiFi.macAddress();
|
||||
node["IPv4 address"] = uuid::printable_to_string(WiFi.localIP()) + "/" + uuid::printable_to_string(WiFi.subnetMask());
|
||||
node["IPv4 gateway"] = uuid::printable_to_string(WiFi.gatewayIP());
|
||||
node["IPv4 nameserver"] = uuid::printable_to_string(WiFi.dnsIP());
|
||||
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||
node["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6());
|
||||
}
|
||||
} else if (EMSESP::system_.ethernet_connected()) {
|
||||
node["connection"] = F("Ethernet");
|
||||
node["hostname"] = ETH.getHostname();
|
||||
node["MAC"] = ETH.macAddress();
|
||||
node["IPv4 address"] = uuid::printable_to_string(ETH.localIP()) + "/" + uuid::printable_to_string(ETH.subnetMask());
|
||||
node["IPv4 gateway"] = uuid::printable_to_string(ETH.gatewayIP());
|
||||
node["IPv4 nameserver"] = uuid::printable_to_string(ETH.dnsIP());
|
||||
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||
node["IPv6 address"] = uuid::printable_to_string(ETH.localIPv6());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Status
|
||||
node = output.createNestedObject("Status");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user