From 608912e9f36c46b4d5ce5b3bf1b7e7e7827cc1b7 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Wed, 20 Jul 2022 19:21:31 +0200 Subject: [PATCH] Show network status (WiFi/Ethernet) in network info view --- src/WebApi_network.cpp | 13 +++++---- webapp/src/components/NetworkInfoView.vue | 21 +++++++------- ...ationInfo.vue => InterfaceNetworkInfo.vue} | 27 +++++++++--------- webapp_dist/js/app.js.gz | Bin 290843 -> 290881 bytes 4 files changed, 32 insertions(+), 29 deletions(-) rename webapp/src/components/partials/{InterfaceStationInfo.vue => InterfaceNetworkInfo.vue} (65%) diff --git a/src/WebApi_network.cpp b/src/WebApi_network.cpp index e5925f7..3254c4b 100644 --- a/src/WebApi_network.cpp +++ b/src/WebApi_network.cpp @@ -31,13 +31,14 @@ void WebApiNetworkClass::onNetworkStatus(AsyncWebServerRequest* request) root[F("sta_status")] = ((WiFi.getMode() & WIFI_STA) != 0); root[F("sta_ssid")] = WiFi.SSID(); - root[F("sta_ip")] = NetworkSettings.localIP().toString(); - root[F("sta_netmask")] = NetworkSettings.subnetMask().toString(); - root[F("sta_gateway")] = NetworkSettings.gatewayIP().toString(); - root[F("sta_dns1")] = NetworkSettings.dnsIP(0).toString(); - root[F("sta_dns2")] = NetworkSettings.dnsIP(1).toString(); - root[F("sta_mac")] = NetworkSettings.macAddress(); root[F("sta_rssi")] = WiFi.RSSI(); + root[F("network_ip")] = NetworkSettings.localIP().toString(); + root[F("network_netmask")] = NetworkSettings.subnetMask().toString(); + root[F("network_gateway")] = NetworkSettings.gatewayIP().toString(); + root[F("network_dns1")] = NetworkSettings.dnsIP(0).toString(); + root[F("network_dns2")] = NetworkSettings.dnsIP(1).toString(); + root[F("network_mac")] = NetworkSettings.macAddress(); + root[F("network_mode")] = NetworkSettings.NetworkMode() == network_mode::WiFi ? F("Station") : F("Ethernet"); root[F("ap_status")] = ((WiFi.getMode() & WIFI_AP) != 0); root[F("ap_ssid")] = NetworkSettings.getApName(); root[F("ap_ip")] = WiFi.softAPIP().toString(); diff --git a/webapp/src/components/NetworkInfoView.vue b/webapp/src/components/NetworkInfoView.vue index 819648d..3f42462 100644 --- a/webapp/src/components/NetworkInfoView.vue +++ b/webapp/src/components/NetworkInfoView.vue @@ -14,7 +14,7 @@
- +
@@ -26,14 +26,14 @@ import { defineComponent } from 'vue'; import WifiStationInfo from "./partials/WifiStationInfo.vue"; import WifiApInfo from "./partials/WifiApInfo.vue"; -import InterfaceStationInfo from "./partials/InterfaceStationInfo.vue"; +import InterfaceNetworkInfo from "./partials/InterfaceNetworkInfo.vue"; import InterfaceApInfo from "./partials/InterfaceApInfo.vue"; export default defineComponent({ components: { WifiStationInfo, WifiApInfo, - InterfaceStationInfo, + InterfaceNetworkInfo, InterfaceApInfo, }, data() { @@ -48,13 +48,14 @@ export default defineComponent({ ap_status: false, ap_ssid: "", ap_stationnum: 0, - // InterfaceStationInfo - sta_ip: "", - sta_netmask: "", - sta_gateway: "", - sta_dns1: "", - sta_dns2: "", - sta_mac: "", + // InterfaceNetworkInfo + network_ip: "", + network_netmask: "", + network_gateway: "", + network_dns1: "", + network_dns2: "", + network_mac: "", + network_mode: "", // InterfaceApInfo ap_ip: "", ap_mac: "", diff --git a/webapp/src/components/partials/InterfaceStationInfo.vue b/webapp/src/components/partials/InterfaceNetworkInfo.vue similarity index 65% rename from webapp/src/components/partials/InterfaceStationInfo.vue rename to webapp/src/components/partials/InterfaceNetworkInfo.vue index c70389e..dfb6aa7 100644 --- a/webapp/src/components/partials/InterfaceStationInfo.vue +++ b/webapp/src/components/partials/InterfaceNetworkInfo.vue @@ -1,7 +1,7 @@