mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
show eth parameters for eth connection (if eth/wifi connected)
This commit is contained in:
@@ -24,8 +24,23 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
|
|||||||
root["status"] = (uint8_t)wifi_status;
|
root["status"] = (uint8_t)wifi_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for Wifi
|
// for both connections show ethernet
|
||||||
if (wifi_status == WL_CONNECTED) {
|
if (ethernet_connected) {
|
||||||
|
// Ethernet
|
||||||
|
root["local_ip"] = ETH.localIP().toString();
|
||||||
|
root["local_ipv6"] = ETH.localIPv6().toString();
|
||||||
|
root["mac_address"] = ETH.macAddress();
|
||||||
|
root["subnet_mask"] = ETH.subnetMask().toString();
|
||||||
|
root["gateway_ip"] = ETH.gatewayIP().toString();
|
||||||
|
IPAddress dnsIP1 = ETH.dnsIP(0);
|
||||||
|
IPAddress dnsIP2 = ETH.dnsIP(1);
|
||||||
|
if (IPUtils::isSet(dnsIP1)) {
|
||||||
|
root["dns_ip_1"] = dnsIP1.toString();
|
||||||
|
}
|
||||||
|
if (IPUtils::isSet(dnsIP2)) {
|
||||||
|
root["dns_ip_2"] = dnsIP2.toString();
|
||||||
|
}
|
||||||
|
} else if (wifi_status == WL_CONNECTED) {
|
||||||
root["local_ip"] = WiFi.localIP().toString();
|
root["local_ip"] = WiFi.localIP().toString();
|
||||||
root["local_ipv6"] = WiFi.localIPv6().toString();
|
root["local_ipv6"] = WiFi.localIPv6().toString();
|
||||||
root["mac_address"] = WiFi.macAddress();
|
root["mac_address"] = WiFi.macAddress();
|
||||||
@@ -47,21 +62,6 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
|
|||||||
if (dnsIP2 != INADDR_NONE) {
|
if (dnsIP2 != INADDR_NONE) {
|
||||||
root["dns_ip_2"] = dnsIP2.toString();
|
root["dns_ip_2"] = dnsIP2.toString();
|
||||||
}
|
}
|
||||||
} else if (ethernet_connected) {
|
|
||||||
// Ethernet
|
|
||||||
root["local_ip"] = ETH.localIP().toString();
|
|
||||||
root["local_ipv6"] = ETH.localIPv6().toString();
|
|
||||||
root["mac_address"] = ETH.macAddress();
|
|
||||||
root["subnet_mask"] = ETH.subnetMask().toString();
|
|
||||||
root["gateway_ip"] = ETH.gatewayIP().toString();
|
|
||||||
IPAddress dnsIP1 = ETH.dnsIP(0);
|
|
||||||
IPAddress dnsIP2 = ETH.dnsIP(1);
|
|
||||||
if (IPUtils::isSet(dnsIP1)) {
|
|
||||||
root["dns_ip_1"] = dnsIP1.toString();
|
|
||||||
}
|
|
||||||
if (IPUtils::isSet(dnsIP2)) {
|
|
||||||
root["dns_ip_2"] = dnsIP2.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response->setLength();
|
response->setLength();
|
||||||
|
|||||||
@@ -541,7 +541,17 @@ void System::send_info_mqtt(const char * event_str) {
|
|||||||
doc["event"] = event_str;
|
doc["event"] = event_str;
|
||||||
doc["version"] = EMSESP_APP_VERSION;
|
doc["version"] = EMSESP_APP_VERSION;
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (EMSESP::system_.ethernet_connected()) {
|
||||||
|
doc["connection"] = "ethernet";
|
||||||
|
doc["hostname"] = ETH.getHostname();
|
||||||
|
doc["MAC"] = ETH.macAddress();
|
||||||
|
doc["IPv4 address"] = uuid::printable_to_string(ETH.localIP()) + "/" + uuid::printable_to_string(ETH.subnetMask());
|
||||||
|
doc["IPv4 gateway"] = uuid::printable_to_string(ETH.gatewayIP());
|
||||||
|
doc["IPv4 nameserver"] = uuid::printable_to_string(ETH.dnsIP());
|
||||||
|
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||||
|
doc["IPv6 address"] = uuid::printable_to_string(ETH.localIPv6());
|
||||||
|
}
|
||||||
|
} else if (WiFi.status() == WL_CONNECTED) {
|
||||||
doc["connection"] = "wifi";
|
doc["connection"] = "wifi";
|
||||||
doc["hostname"] = WiFi.getHostname();
|
doc["hostname"] = WiFi.getHostname();
|
||||||
doc["SSID"] = WiFi.SSID();
|
doc["SSID"] = WiFi.SSID();
|
||||||
@@ -554,16 +564,6 @@ void System::send_info_mqtt(const char * event_str) {
|
|||||||
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||||
doc["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6());
|
doc["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6());
|
||||||
}
|
}
|
||||||
} else if (EMSESP::system_.ethernet_connected()) {
|
|
||||||
doc["connection"] = "ethernet";
|
|
||||||
doc["hostname"] = ETH.getHostname();
|
|
||||||
doc["MAC"] = ETH.macAddress();
|
|
||||||
doc["IPv4 address"] = uuid::printable_to_string(ETH.localIP()) + "/" + uuid::printable_to_string(ETH.subnetMask());
|
|
||||||
doc["IPv4 gateway"] = uuid::printable_to_string(ETH.gatewayIP());
|
|
||||||
doc["IPv4 nameserver"] = uuid::printable_to_string(ETH.dnsIP());
|
|
||||||
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
|
||||||
doc["IPv6 address"] = uuid::printable_to_string(ETH.localIPv6());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Mqtt::publish_retain(F_(info), doc.as<JsonObject>(), true); // topic called "info" and it's Retained
|
Mqtt::publish_retain(F_(info), doc.as<JsonObject>(), true); // topic called "info" and it's Retained
|
||||||
@@ -1062,6 +1062,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
// node["uptime (seconds)"] = uuid::get_uptime_sec();
|
// node["uptime (seconds)"] = uuid::get_uptime_sec();
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
node["freemem"] = ESP.getFreeHeap() / 1024; // kilobytes
|
node["freemem"] = ESP.getFreeHeap() / 1024; // kilobytes
|
||||||
|
node["maxalloc"] = ESP.getMaxAllocHeap() / 1024; // kilobytes
|
||||||
node["free_app"] = EMSESP::system_.appFree(); // kilobytes
|
node["free_app"] = EMSESP::system_.appFree(); // kilobytes
|
||||||
#endif
|
#endif
|
||||||
node["reset reason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1);
|
node["reset reason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1);
|
||||||
@@ -1069,7 +1070,17 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
// Network Status
|
// Network Status
|
||||||
node = output.createNestedObject("Network Info");
|
node = output.createNestedObject("Network Info");
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (EMSESP::system_.ethernet_connected()) {
|
||||||
|
node["connection"] = "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());
|
||||||
|
}
|
||||||
|
} else if (WiFi.status() == WL_CONNECTED) {
|
||||||
node["connection"] = "WiFi";
|
node["connection"] = "WiFi";
|
||||||
node["hostname"] = WiFi.getHostname();
|
node["hostname"] = WiFi.getHostname();
|
||||||
// node["SSID"] = WiFi.SSID();
|
// node["SSID"] = WiFi.SSID();
|
||||||
@@ -1082,22 +1093,6 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||||
node["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6());
|
node["IPv6 address"] = uuid::printable_to_string(WiFi.localIPv6());
|
||||||
}
|
}
|
||||||
} else if (EMSESP::system_.ethernet_connected()) {
|
|
||||||
node["connection"] = "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());
|
|
||||||
}
|
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
|
||||||
node["phy type"] = settings.phy_type;
|
|
||||||
node["eth power"] = settings.eth_power;
|
|
||||||
node["eth phy addr"] = settings.eth_phy_addr;
|
|
||||||
node["eth clock mode"] = settings.eth_clock_mode;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & settings) {
|
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & settings) {
|
||||||
|
|||||||
Reference in New Issue
Block a user