diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 5177d8985..f212913d8 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -27,6 +27,10 @@ This release is based on the latest Espressif/Arduino core version 3. It brings - LED stayed off on a healthy system when "Disable LED" was unchecked - Ethernet MAC address changed with the new SDK, breaking DHCP reservations (currently disabled) - "IPv4 nameserver" showed an IPv6 address when IPv6 was in use +- the Network status page showed at most one IPv6 address and could hide the IPv4 DNS server entirely. It only read the link-local address, so a dual-stack host's ULA and global addresses were never reported, and it only read two of the three DNS slots, which are shared between IPv4 and IPv6. It now lists every address the interface holds, each labelled with its IPv6 scope, and every configured DNS server [#3246](https://github.com/emsesp/EMS-ESP32/issues/3246) +- `show system` had the same gaps, reporting a link-local IPv6 address only and a single IPv4 DNS server. The WiFi and Ethernet sections now list every IPv6 address with its scope, and every DNS server labelled with its own family [#3246](https://github.com/emsesp/EMS-ESP32/issues/3246) +- the Access Point status page reported whichever interface happened to be active, so with the AP down it showed the station's IP and MAC address under an "Inactive" heading. It now always reports the soft-AP's own details, and shows `none` when the AP isn't running +- the MQTT `info` topic published no addresses at all when connected over Ethernet, and over WiFi only an IPv4 address plus a link-local IPv6 one. Both interfaces now report their MAC, IPv4 address and gateway, every IPv6 address and every DNS server. Note that `IPv6 address` is now an array, and `IPv4 DNS Server` is replaced by a `DNS Server` array that covers both families [#3246](https://github.com/emsesp/EMS-ESP32/issues/3246) - HA Discovery warning on Uptime after EMS-ESP boot due to NTP not ready - hc/control setting for UI800 thermostats [#3181](https://github.com/emsesp/EMS-ESP32/discussions/3181) - solar module switches [#3223](https://github.com/emsesp/EMS-ESP32/issues/3223) diff --git a/interface/src/app/status/APStatus.tsx b/interface/src/app/status/APStatus.tsx index 99dd77066..aed7fc035 100644 --- a/interface/src/app/status/APStatus.tsx +++ b/interface/src/app/status/APStatus.tsx @@ -90,7 +90,10 @@ const APStatus = () => { IP - + @@ -103,7 +106,7 @@ const APStatus = () => { diff --git a/interface/src/app/status/NetworkStatus.tsx b/interface/src/app/status/NetworkStatus.tsx index e72dcac95..97b9c66e0 100644 --- a/interface/src/app/status/NetworkStatus.tsx +++ b/interface/src/app/status/NetworkStatus.tsx @@ -7,11 +7,13 @@ import SettingsInputComponentIcon from '@mui/icons-material/SettingsInputCompone import WifiIcon from '@mui/icons-material/Wifi'; import { Avatar, + Box, Divider, List, ListItem, ListItemAvatar, ListItemText, + Typography, useTheme } from '@mui/material'; import type { Theme } from '@mui/material'; @@ -62,26 +64,40 @@ const networkQualityHighlight = ({ rssi }: NetworkStatusType, theme: Theme) => { return theme.palette.success.main; }; -const dnsServers = ({ dns_ip_1, dns_ip_2 }: NetworkStatusType) => { - if (!dns_ip_1) { +// one address per line, with an optional dimmed note such as the IPv6 scope +const AddressList = ({ + addresses +}: { + addresses: { value: string; note?: string }[]; +}) => { + if (addresses.length === 0) { return 'none'; } - return dns_ip_1 + (!dns_ip_2 || dns_ip_2 === '0.0.0.0' ? '' : ', ' + dns_ip_2); + return addresses.map(({ value, note }) => ( + + {value} + {note && ( + + ({note}) + + )} + + )); }; -const IPs = (status: NetworkStatusType) => { - if ( - !status.local_ipv6 || - status.local_ipv6 === '0000:0000:0000:0000:0000:0000:0000:0000' || - status.local_ipv6 === '::' - ) { - return status.local_ip; - } - if (!status.local_ip || status.local_ip === '0.0.0.0') { - return status.local_ipv6; - } - return status.local_ip + ', ' + status.local_ipv6; -}; +const isSet = (ip?: string) => !!ip && ip !== '0.0.0.0' && ip !== '::'; + +const ipAddresses = ({ local_ip, ipv6 }: NetworkStatusType) => [ + ...(isSet(local_ip) ? [{ value: local_ip }] : []), + ...(ipv6 ?? []).map(({ address, scope }) => ({ value: address, note: scope })) +]; + +const dnsServers = ({ dns }: NetworkStatusType) => + (dns ?? []).filter(isSet).map((value) => ({ value })); const getNetworkStatusText = ( status: NetworkConnectionStatus, @@ -178,7 +194,10 @@ const NetworkStatus = () => { IP - + } + /> @@ -223,7 +242,7 @@ const NetworkStatus = () => { } /> diff --git a/interface/src/types/network.ts b/interface/src/types/network.ts index 94e7a2984..f76c9479b 100644 --- a/interface/src/types/network.ts +++ b/interface/src/types/network.ts @@ -20,19 +20,23 @@ export enum WiFiEncryptionType { WIFI_AUTH_WPA2_WPA3_PSK = 7 } +export interface IPv6AddressType { + address: string; + scope: string; // global, unique local, site local or link local +} + export interface NetworkStatusType { status: NetworkConnectionStatus; local_ip: string; - local_ipv6: string; + ipv6?: IPv6AddressType[]; mac_address: string; rssi: number; ssid: string; bssid: string; channel: number; subnet_mask: string; - gateway_ip: string; - dns_ip_1: string; - dns_ip_2: string; + gateway_ip?: string; + dns?: string[]; hostname: string; reconnect_count: number; } diff --git a/mock-api/pnpm-lock.yaml b/mock-api/pnpm-lock.yaml index b4d8aad0b..27c733e28 100644 --- a/mock-api/pnpm-lock.yaml +++ b/mock-api/pnpm-lock.yaml @@ -175,10 +175,10 @@ importers: devDependencies: '@trivago/prettier-plugin-sort-imports': specifier: ^6.0.2 - version: 6.0.2(prettier@3.9.7) + version: 6.0.2(prettier@3.9.8) prettier: - specifier: ^3.9.7 - version: 3.9.7 + specifier: ^3.9.8 + version: 3.9.8 packages: @@ -303,8 +303,8 @@ packages: picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} - prettier@3.9.7: - resolution: {integrity: sha512-T3mF5P7HFzZVLDQuCUNtJj6WK1pcpLMweMNUVwGb01bLNkH9AkKxtZvmInw8K6bnn2O3d6/5RHl6zSHiBAD0Og==} + prettier@3.9.8: + resolution: {integrity: sha512-WRFq3Wn3WId7LLROfMLdH7xaFr2jR62wU8nLO6rQUOLOxNZUviyJQs1M0iIhLexSFy+L+w0ch66wtoO2jRjG0A==} engines: {node: '>=14'} hasBin: true @@ -373,7 +373,7 @@ snapshots: '@msgpack/msgpack@3.1.3': {} - '@trivago/prettier-plugin-sort-imports@6.0.2(prettier@3.9.7)': + '@trivago/prettier-plugin-sort-imports@6.0.2(prettier@3.9.8)': dependencies: '@babel/generator': 7.29.8 '@babel/parser': 7.29.8 @@ -383,7 +383,7 @@ snapshots: lodash-es: 4.18.1 minimatch: 9.0.9 parse-imports-exports: 0.2.4 - prettier: 3.9.7 + prettier: 3.9.8 transitivePeerDependencies: - supports-color @@ -421,4 +421,4 @@ snapshots: picocolors@1.1.1: {} - prettier@3.9.7: {} + prettier@3.9.8: {} diff --git a/mock-api/restServer.ts b/mock-api/restServer.ts index ee13459b5..b561e486d 100644 --- a/mock-api/restServer.ts +++ b/mock-api/restServer.ts @@ -580,7 +580,7 @@ let ap_settings = { max_clients: 4 }; const ap_status = { - status: 1, + status: 0, // active - an inactive AP reports no address at all ip_address: '192.168.4.1', mac_address: '3C:61:05:03:AB:2D', station_num: 0 @@ -612,6 +612,11 @@ let network_settings = { const network_status = { status: 3, local_ip: '10.10.10.101', + ipv6: [ + { address: '2001:db8:1234:5678::a1b2', scope: 'global' }, + { address: 'fd00:1234:5678::a1b2', scope: 'unique local' }, + { address: 'fe80::3e61:5ff:fe03:ab2c', scope: 'link local' } + ], mac_address: '3C:61:05:03:AB:2C', rssi: -41, ssid: 'home', @@ -619,8 +624,7 @@ const network_status = { channel: 11, subnet_mask: '255.255.255.0', gateway_ip: '10.10.10.1', - dns_ip_1: '10.10.10.1', - dns_ip_2: '0.0.0.0', + dns: ['10.10.10.1', 'fd00:1234:5678::1'], hostname: 'ems-esp', reconnect_count: 1 }; diff --git a/src/ESP32React/APStatus.cpp b/src/ESP32React/APStatus.cpp index c04a39cdc..9588cfd70 100644 --- a/src/ESP32React/APStatus.cpp +++ b/src/ESP32React/APStatus.cpp @@ -14,9 +14,9 @@ void APStatus::apStatus(AsyncWebServerRequest * request) { JsonObject root = response->getRoot(); root["status"] = _apSettingsService->getAPNetworkStatus(); - root["ip_address"] = emsesp::EMSESP::network_.getLocalIP(); - root["mac_address"] = emsesp::EMSESP::network_.getMacAddress(); - root["station_num"] = emsesp::EMSESP::network_.getStationNum(); + root["ip_address"] = emsesp::EMSESP::network_.getAPIP(); + root["mac_address"] = emsesp::EMSESP::network_.getAPMacAddress(); + root["station_num"] = emsesp::EMSESP::network_.getAPStationNum(); response->setLength(); request->send(response); diff --git a/src/ESP32React/NetworkStatus.cpp b/src/ESP32React/NetworkStatus.cpp index 75469892b..9c945249a 100644 --- a/src/ESP32React/NetworkStatus.cpp +++ b/src/ESP32React/NetworkStatus.cpp @@ -2,6 +2,30 @@ #include +namespace { + +void add_ipv6(JsonObject root, NetworkInterface & netif) { + auto found = emsesp::Network::ipv6_addresses(netif); + if (found.empty()) { + return; + } + JsonArray addresses = root["ipv6"].to(); + for (const auto & ipv6 : found) { + JsonObject entry = addresses.add(); + entry["address"] = ipv6.ip.toString(); + entry["scope"] = ipv6.scope; + } +} + +void add_dns(JsonObject root, const NetworkInterface & netif) { + JsonArray servers = root["dns"].to(); + for (const auto & ip : emsesp::Network::dns_servers(netif)) { + servers.add(ip.toString()); + } +} + +} // namespace + NetworkStatus::NetworkStatus(AsyncWebServer * server, SecurityManager * securityManager) { securityManager->addEndpoint(server, NETWORK_STATUS_SERVICE_PATH, AuthenticationPredicates::IS_AUTHENTICATED, [this](AsyncWebServerRequest * request) { networkStatus(request); @@ -27,21 +51,15 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) { if (emsesp::EMSESP::network_.ethernet_connected()) { // Ethernet root["local_ip"] = ETH.localIP().toString(); - root["local_ipv6"] = ETH.linkLocalIPv6().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(); + if (IPUtils::isSet(ETH.gatewayIP())) { + root["gateway_ip"] = ETH.gatewayIP().toString(); } + add_ipv6(root, ETH); + add_dns(root, ETH); } else if (wifi_status == WL_CONNECTED) { root["local_ip"] = WiFi.localIP().toString(); - root["local_ipv6"] = WiFi.linkLocalIPv6().toString(); root["mac_address"] = WiFi.macAddress(); root["rssi"] = WiFi.RSSI(); root["ssid"] = WiFi.SSID(); @@ -49,18 +67,11 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) { root["channel"] = WiFi.channel(); root["reconnect_count"] = emsesp::EMSESP::network_.getNetworkReconnects(); root["subnet_mask"] = WiFi.subnetMask().toString(); - - if (WiFi.gatewayIP() != INADDR_NONE) { + if (IPUtils::isSet(WiFi.gatewayIP())) { root["gateway_ip"] = WiFi.gatewayIP().toString(); } - IPAddress dnsIP1 = WiFi.dnsIP(0); - IPAddress dnsIP2 = WiFi.dnsIP(1); - if (dnsIP1 != INADDR_NONE) { - root["dns_ip_1"] = dnsIP1.toString(); - } - if (dnsIP2 != INADDR_NONE) { - root["dns_ip_2"] = dnsIP2.toString(); - } + add_ipv6(root, WiFi.STA); + add_dns(root, WiFi.STA); } response->setLength(); diff --git a/src/core/emsesp.cpp b/src/core/emsesp.cpp index fb7db4026..a43dd2b23 100644 --- a/src/core/emsesp.cpp +++ b/src/core/emsesp.cpp @@ -1723,17 +1723,23 @@ void EMSESP::start() { // start the file system #ifndef EMSESP_STANDALONE +#if defined(EMSESP_DEBUG) + // don't format the filesystem in debug mode + if (!LittleFS.begin(false)) { + LOG_ERROR("LittleFS Mount Failed. Attempting to convert..."); + return; + } else { + // it mounted, show the contents of the root directory + LOG_DEBUG("Listing root directory before:"); + system_.listDir("/", 3); + } +#else + // format filesystem if there isn't one if (!LittleFS.begin(true)) { LOG_ERROR("LittleFS Mount Failed"); return; } -// else { -// output filesystem folders and files for debugging -// #if defined(EMSESP_DEBUG) -// LOG_DEBUG("Listing root directory before:"); -// system_.listDir("/", 3); // show the contents of the root directory -// #endif -// } +#endif #endif // do a quick scan of the filesystem to see if we a settings file in the /config folder @@ -1746,7 +1752,7 @@ void EMSESP::start() { bool factory_settings = false; #endif - // start NVS storage +// start NVS storage #ifndef EMSESP_STANDALONE if (esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_NVS, "nvs1")) { nvs_.begin("ems-esp", false, "nvs1"); @@ -1766,11 +1772,11 @@ void EMSESP::start() { // loads core system services settings (mqtt, ap, ntp etc) esp32React.begin(); - // output filesystem folders and files for debugging - // #if defined(EMSESP_DEBUG) - // LOG_DEBUG("Listing root directory after:"); - // system_.listDir("/", 3); // show the contents of the root directory - // #endif +// output filesystem folders and files for debugging +#if defined(EMSESP_DEBUG) + LOG_DEBUG("Listing root directory after:"); + system_.listDir("/", 3); // show the contents of the root directory +#endif #ifndef EMSESP_STANDALONE if (factory_settings) { @@ -1818,7 +1824,7 @@ void EMSESP::start() { LOG_INFO("Last system reset reason Core0: %s, Core1: %s", system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str()); #endif - // see if we're restoring a settings file +// see if we're restoring a settings file #ifndef EMSESP_STANDALONE if (system_.check_restore()) { LOG_WARNING("EMS-ESP will restart to apply new settings. Please wait."); diff --git a/src/core/network.cpp b/src/core/network.cpp index a250255dd..4ecda77aa 100644 --- a/src/core/network.cpp +++ b/src/core/network.cpp @@ -154,44 +154,83 @@ bool Network::formatBSSID([[maybe_unused]] const String & bssid, [[maybe_unused] return true; } -// get the local IP address of the network interface -std::string Network::getLocalIP() const { - switch (network_iface_) { +// get the soft-AP's own IP address, empty when the AP isn't running +std::string Network::getAPIP() const { #ifndef EMSESP_STANDALONE - case NetIface::AP: - return WiFi.softAPIP().toString().c_str(); - case NetIface::WIFI: - return WiFi.localIP().toString().c_str(); - case NetIface::ETHERNET: - return ETH.localIP().toString().c_str(); - case NetIface::NONE: -#endif - default: - return ""; + const IPAddress ip = WiFi.softAPIP(); + if (static_cast(ip) != 0) { + return ip.toString().c_str(); } +#endif + return ""; } -// get the MAC address of the network interface -std::string Network::getMacAddress() const { - switch (network_iface_) { #ifndef EMSESP_STANDALONE - case NetIface::AP: - return WiFi.softAPmacAddress().c_str(); - case NetIface::WIFI: - return WiFi.macAddress().c_str(); - case NetIface::ETHERNET: - return ETH.macAddress().c_str(); - case NetIface::NONE: -#endif - default: - return ""; +// Every IPv6 address bound to the interface, widest scope first so the address most people need +// comes out on top. linkLocalIPv6() and globalIPv6() each only ever return a single address, so a +// dual-stack host holding both a ULA and a routable GUA would have one of them hidden. +std::vector Network::ipv6_addresses([[maybe_unused]] NetworkInterface & netif) { + std::vector addresses; + +#if CONFIG_LWIP_IPV6 + esp_ip6_addr_t raw[CONFIG_LWIP_IPV6_NUM_ADDRESSES]; + int found = esp_netif_get_all_ip6(netif.netif(), raw); + if (found <= 0) { + return addresses; } + + struct Scope { + esp_ip6_addr_type_t type; + const char * name; + }; + static const Scope scopes[] = {{ESP_IP6_ADDR_IS_GLOBAL, "global"}, + {ESP_IP6_ADDR_IS_UNIQUE_LOCAL, "unique local"}, + {ESP_IP6_ADDR_IS_SITE_LOCAL, "site local"}, + {ESP_IP6_ADDR_IS_LINK_LOCAL, "link local"}}; + + addresses.reserve(found); + for (const auto & scope : scopes) { + for (int i = 0; i < found; i++) { + IPAddress ip(IPv6, reinterpret_cast(raw[i].addr), raw[i].zone); + if (ip.addr_type() == scope.type) { + addresses.push_back({ip, scope.name}); + } + } + } +#endif + + return addresses; +} + +// Every DNS server configured on the interface. The slots are shared between IPv4 and IPv6, so +// reading only the first couple can hide the IPv4 resolver entirely once IPv6 is in use. +std::vector Network::dns_servers(const NetworkInterface & netif) { + std::vector servers; + for (uint8_t i = 0; i < ESP_NETIF_DNS_MAX; i++) { + IPAddress ip = netif.dnsIP(i); + if (ip.type() == IPv4 ? static_cast(ip) != 0 : ip != IN6ADDR_ANY) { + servers.push_back(ip); + } + } + return servers; +} +#endif + +// get the soft-AP's own MAC address, empty when the AP isn't running +std::string Network::getAPMacAddress() const { +#ifndef EMSESP_STANDALONE + uint8_t mac[6]; + if (WiFi.softAPmacAddress(mac) != nullptr) { // null once the AP netif is gone + return WiFi.softAPmacAddress().c_str(); + } +#endif + return ""; } // get the number of sessions connected to the AP -uint8_t Network::getStationNum() const { +uint8_t Network::getAPStationNum() const { #ifndef EMSESP_STANDALONE - return network_iface_ == NetIface::AP ? WiFi.softAPgetStationNum() : 0; + return WiFi.softAPgetStationNum(); #else return 0; #endif diff --git a/src/core/network.h b/src/core/network.h index 5c341a249..e88b8a1a9 100644 --- a/src/core/network.h +++ b/src/core/network.h @@ -21,6 +21,7 @@ #ifndef EMSESP_STANDALONE #include +#include #include #include #include @@ -30,6 +31,7 @@ #endif #include +#include #include #include @@ -132,11 +134,24 @@ class Network { return reconnect_count_; } - std::string getLocalIP() const; - std::string getMacAddress() const; - uint8_t getStationNum() const; + // the soft-AP's own details, which are what the Access Point status page reports + std::string getAPIP() const; + std::string getAPMacAddress() const; + uint8_t getAPStationNum() const; + const char * ethernet_status() const; +#ifndef EMSESP_STANDALONE + // an IPv6 address together with a readable scope, e.g. "global" or "link local" + struct IPv6Address { + IPAddress ip; + const char * scope; + }; + + static std::vector ipv6_addresses(NetworkInterface & netif); + static std::vector dns_servers(const NetworkInterface & netif); +#endif + void reconnect(); // ask for a reconnect() to run from the next Network::loop() diff --git a/src/core/system.cpp b/src/core/system.cpp index 214fe72d6..b867e8642 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -98,16 +98,40 @@ static void sendmail_tls_handshake(bool & success) { success = sendmail_ssl_client != nullptr && sendmail_ssl_client->connectSSL(); } -// The DNS slots are shared between IPv4 and IPv6, so with IPv6 enabled the first slot can hold an -// IPv6 server. Pick the first IPv4 one so it matches the label we print it under. -static IPAddress dns_ipv4(const NetworkInterface & netif) { - for (uint8_t i = 0; i < ESP_NETIF_DNS_MAX; i++) { - IPAddress ip = netif.dnsIP(i); - if (ip.type() == IPv4 && static_cast(ip) != 0) { - return ip; +// Print the full set of addresses for an interface. Every DNS server is listed, labelled with its +// own family since the slots are shared, and every IPv6 address with its scope. +static void show_addresses(uuid::console::Shell & shell, NetworkInterface & netif) { + shell.printfln(" IPv4 address: %s/%s", uuid::printable_to_string(netif.localIP()).c_str(), uuid::printable_to_string(netif.subnetMask()).c_str()); + shell.printfln(" IPv4 gateway: %s", uuid::printable_to_string(netif.gatewayIP()).c_str()); + for (const auto & dns : Network::dns_servers(netif)) { + shell.printfln(" %s DNS Server: %s", dns.type() == IPv4 ? "IPv4" : "IPv6", uuid::printable_to_string(dns).c_str()); + } + for (const auto & ipv6 : Network::ipv6_addresses(netif)) { + shell.printfln(" IPv6 address: %s (%s)", uuid::printable_to_string(ipv6.ip).c_str(), ipv6.scope); + } +} + +// Add the full set of addresses for an interface to a JSON document, both families. +static void add_addresses(JsonDocument & doc, NetworkInterface & netif) { + doc["MAC"] = netif.macAddress(); + doc["IPv4 address"] = uuid::printable_to_string(netif.localIP()) + "/" + uuid::printable_to_string(netif.subnetMask()); + doc["IPv4 gateway"] = uuid::printable_to_string(netif.gatewayIP()); + + auto servers = Network::dns_servers(netif); + if (!servers.empty()) { + JsonArray dns = doc["DNS Server"].to(); + for (const auto & ip : servers) { + dns.add(uuid::printable_to_string(ip)); + } + } + + auto found = Network::ipv6_addresses(netif); + if (!found.empty()) { + JsonArray addresses = doc["IPv6 address"].to(); + for (const auto & ipv6 : found) { + addresses.add(uuid::printable_to_string(ipv6.ip)); } } - return IPAddress(); } #endif @@ -893,18 +917,13 @@ void System::send_info_mqtt() { if (EMSESP::network_.ethernet_connected()) { doc["network"] = "ethernet"; doc["hostname"] = ETH.getHostname(); + add_addresses(doc, ETH); } else if (EMSESP::network_.wifi_connected()) { - doc["network"] = "wifi"; - doc["hostname"] = WiFi.getHostname(); - doc["SSID"] = WiFi.SSID(); - doc["BSSID"] = WiFi.BSSIDstr(); - doc["MAC"] = WiFi.macAddress(); - doc["IPv4 address"] = uuid::printable_to_string(WiFi.localIP()) + "/" + uuid::printable_to_string(WiFi.subnetMask()); - doc["IPv4 gateway"] = uuid::printable_to_string(WiFi.gatewayIP()); - doc["IPv4 DNS Server"] = uuid::printable_to_string(dns_ipv4(WiFi.STA)); - if (WiFi.linkLocalIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && WiFi.linkLocalIPv6().toString() != "::") { - doc["IPv6 address"] = uuid::printable_to_string(WiFi.linkLocalIPv6()); - } + doc["network"] = "wifi"; + doc["hostname"] = WiFi.getHostname(); + doc["SSID"] = WiFi.SSID(); + doc["BSSID"] = WiFi.BSSIDstr(); + add_addresses(doc, WiFi.STA); } #endif Mqtt::queue_publish_retain(F_(info), doc.as()); // topic called "info" and it's Retained @@ -1266,12 +1285,7 @@ void System::show_system(uuid::console::Shell & shell) { shell.printfln(" TxPower: %s dBm", Helpers::render_value(result, (double)(WiFi.getTxPower() / 4), 1)); shell.printfln(" MAC address: %s", WiFi.macAddress().c_str()); shell.printfln(" Hostname: %s", WiFi.getHostname()); - shell.printfln(" IPv4 address: %s/%s", uuid::printable_to_string(WiFi.localIP()).c_str(), uuid::printable_to_string(WiFi.subnetMask()).c_str()); - shell.printfln(" IPv4 gateway: %s", uuid::printable_to_string(WiFi.gatewayIP()).c_str()); - shell.printfln(" IPv4 DNS Server: %s", uuid::printable_to_string(dns_ipv4(WiFi.STA)).c_str()); - if (WiFi.linkLocalIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && WiFi.linkLocalIPv6().toString() != "::") { - shell.printfln(" IPv6 address: %s", uuid::printable_to_string(WiFi.linkLocalIPv6()).c_str()); - } + show_addresses(shell, WiFi.STA); break; case WL_CONNECT_FAILED: @@ -1301,12 +1315,7 @@ void System::show_system(uuid::console::Shell & shell) { if (EMSESP::network_.ethernet_connected()) { shell.printfln(" Ethernet MAC address: %s", ETH.macAddress().c_str()); shell.printfln(" Hostname: %s", ETH.getHostname()); - shell.printfln(" IPv4 address: %s/%s", uuid::printable_to_string(ETH.localIP()).c_str(), uuid::printable_to_string(ETH.subnetMask()).c_str()); - shell.printfln(" IPv4 gateway: %s", uuid::printable_to_string(ETH.gatewayIP()).c_str()); - shell.printfln(" IPv4 DNS Server: %s", uuid::printable_to_string(dns_ipv4(ETH)).c_str()); - if (ETH.linkLocalIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000" && ETH.linkLocalIPv6().toString() != "::") { - shell.printfln(" IPv6 address: %s", uuid::printable_to_string(ETH.linkLocalIPv6()).c_str()); - } + show_addresses(shell, ETH); } // show AP is connected diff --git a/src/emsesp_version.h b/src/emsesp_version.h index f23c4d33f..a0b2b0af5 100644 --- a/src/emsesp_version.h +++ b/src/emsesp_version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.9.0-dev.11" +#define EMSESP_APP_VERSION "3.9.0-dev.12"