mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-10-28 11:14:58 +00:00
fixes #3246
This commit is contained in:
@@ -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
|
- 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)
|
- Ethernet MAC address changed with the new SDK, breaking DHCP reservations (currently disabled)
|
||||||
- "IPv4 nameserver" showed an IPv6 address when IPv6 was in use
|
- "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
|
- 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)
|
- 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)
|
- solar module switches [#3223](https://github.com/emsesp/EMS-ESP32/issues/3223)
|
||||||
|
|||||||
@@ -90,7 +90,10 @@ const APStatus = () => {
|
|||||||
<ListItemAvatar>
|
<ListItemAvatar>
|
||||||
<Avatar sx={{ bgcolor: 'primary.main' }}>IP</Avatar>
|
<Avatar sx={{ bgcolor: 'primary.main' }}>IP</Avatar>
|
||||||
</ListItemAvatar>
|
</ListItemAvatar>
|
||||||
<ListItemText primary={LL.ADDRESS_OF('IP')} secondary={data.ip_address} />
|
<ListItemText
|
||||||
|
primary={LL.ADDRESS_OF('IP')}
|
||||||
|
secondary={data.ip_address || 'none'}
|
||||||
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
||||||
<Divider variant="inset" component="li" />
|
<Divider variant="inset" component="li" />
|
||||||
@@ -103,7 +106,7 @@ const APStatus = () => {
|
|||||||
</ListItemAvatar>
|
</ListItemAvatar>
|
||||||
<ListItemText
|
<ListItemText
|
||||||
primary={LL.ADDRESS_OF('MAC')}
|
primary={LL.ADDRESS_OF('MAC')}
|
||||||
secondary={data.mac_address}
|
secondary={data.mac_address || 'none'}
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ import SettingsInputComponentIcon from '@mui/icons-material/SettingsInputCompone
|
|||||||
import WifiIcon from '@mui/icons-material/Wifi';
|
import WifiIcon from '@mui/icons-material/Wifi';
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
|
Box,
|
||||||
Divider,
|
Divider,
|
||||||
List,
|
List,
|
||||||
ListItem,
|
ListItem,
|
||||||
ListItemAvatar,
|
ListItemAvatar,
|
||||||
ListItemText,
|
ListItemText,
|
||||||
|
Typography,
|
||||||
useTheme
|
useTheme
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import type { Theme } from '@mui/material';
|
import type { Theme } from '@mui/material';
|
||||||
@@ -62,26 +64,40 @@ const networkQualityHighlight = ({ rssi }: NetworkStatusType, theme: Theme) => {
|
|||||||
return theme.palette.success.main;
|
return theme.palette.success.main;
|
||||||
};
|
};
|
||||||
|
|
||||||
const dnsServers = ({ dns_ip_1, dns_ip_2 }: NetworkStatusType) => {
|
// one address per line, with an optional dimmed note such as the IPv6 scope
|
||||||
if (!dns_ip_1) {
|
const AddressList = ({
|
||||||
|
addresses
|
||||||
|
}: {
|
||||||
|
addresses: { value: string; note?: string }[];
|
||||||
|
}) => {
|
||||||
|
if (addresses.length === 0) {
|
||||||
return 'none';
|
return 'none';
|
||||||
}
|
}
|
||||||
return dns_ip_1 + (!dns_ip_2 || dns_ip_2 === '0.0.0.0' ? '' : ', ' + dns_ip_2);
|
return addresses.map(({ value, note }) => (
|
||||||
|
<Box component="span" sx={{ display: 'block' }} key={value}>
|
||||||
|
{value}
|
||||||
|
{note && (
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
variant="body2"
|
||||||
|
sx={{ color: 'grey.600', ml: 1 }} // dimmer than the grey[500] secondary text
|
||||||
|
>
|
||||||
|
({note})
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
const IPs = (status: NetworkStatusType) => {
|
const isSet = (ip?: string) => !!ip && ip !== '0.0.0.0' && ip !== '::';
|
||||||
if (
|
|
||||||
!status.local_ipv6 ||
|
const ipAddresses = ({ local_ip, ipv6 }: NetworkStatusType) => [
|
||||||
status.local_ipv6 === '0000:0000:0000:0000:0000:0000:0000:0000' ||
|
...(isSet(local_ip) ? [{ value: local_ip }] : []),
|
||||||
status.local_ipv6 === '::'
|
...(ipv6 ?? []).map(({ address, scope }) => ({ value: address, note: scope }))
|
||||||
) {
|
];
|
||||||
return status.local_ip;
|
|
||||||
}
|
const dnsServers = ({ dns }: NetworkStatusType) =>
|
||||||
if (!status.local_ip || status.local_ip === '0.0.0.0') {
|
(dns ?? []).filter(isSet).map((value) => ({ value }));
|
||||||
return status.local_ipv6;
|
|
||||||
}
|
|
||||||
return status.local_ip + ', ' + status.local_ipv6;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getNetworkStatusText = (
|
const getNetworkStatusText = (
|
||||||
status: NetworkConnectionStatus,
|
status: NetworkConnectionStatus,
|
||||||
@@ -178,7 +194,10 @@ const NetworkStatus = () => {
|
|||||||
<ListItemAvatar>
|
<ListItemAvatar>
|
||||||
<Avatar>IP</Avatar>
|
<Avatar>IP</Avatar>
|
||||||
</ListItemAvatar>
|
</ListItemAvatar>
|
||||||
<ListItemText primary={LL.ADDRESS_OF('IP')} secondary={IPs(data)} />
|
<ListItemText
|
||||||
|
primary={LL.ADDRESS_OF('IP')}
|
||||||
|
secondary={<AddressList addresses={ipAddresses(data)} />}
|
||||||
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<Divider variant="inset" component="li" />
|
<Divider variant="inset" component="li" />
|
||||||
<ListItem>
|
<ListItem>
|
||||||
@@ -223,7 +242,7 @@ const NetworkStatus = () => {
|
|||||||
</ListItemAvatar>
|
</ListItemAvatar>
|
||||||
<ListItemText
|
<ListItemText
|
||||||
primary={LL.NETWORK_DNS()}
|
primary={LL.NETWORK_DNS()}
|
||||||
secondary={dnsServers(data)}
|
secondary={<AddressList addresses={dnsServers(data)} />}
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -20,19 +20,23 @@ export enum WiFiEncryptionType {
|
|||||||
WIFI_AUTH_WPA2_WPA3_PSK = 7
|
WIFI_AUTH_WPA2_WPA3_PSK = 7
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IPv6AddressType {
|
||||||
|
address: string;
|
||||||
|
scope: string; // global, unique local, site local or link local
|
||||||
|
}
|
||||||
|
|
||||||
export interface NetworkStatusType {
|
export interface NetworkStatusType {
|
||||||
status: NetworkConnectionStatus;
|
status: NetworkConnectionStatus;
|
||||||
local_ip: string;
|
local_ip: string;
|
||||||
local_ipv6: string;
|
ipv6?: IPv6AddressType[];
|
||||||
mac_address: string;
|
mac_address: string;
|
||||||
rssi: number;
|
rssi: number;
|
||||||
ssid: string;
|
ssid: string;
|
||||||
bssid: string;
|
bssid: string;
|
||||||
channel: number;
|
channel: number;
|
||||||
subnet_mask: string;
|
subnet_mask: string;
|
||||||
gateway_ip: string;
|
gateway_ip?: string;
|
||||||
dns_ip_1: string;
|
dns?: string[];
|
||||||
dns_ip_2: string;
|
|
||||||
hostname: string;
|
hostname: string;
|
||||||
reconnect_count: number;
|
reconnect_count: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+8
-8
@@ -175,10 +175,10 @@ importers:
|
|||||||
devDependencies:
|
devDependencies:
|
||||||
'@trivago/prettier-plugin-sort-imports':
|
'@trivago/prettier-plugin-sort-imports':
|
||||||
specifier: ^6.0.2
|
specifier: ^6.0.2
|
||||||
version: 6.0.2(prettier@3.9.7)
|
version: 6.0.2(prettier@3.9.8)
|
||||||
prettier:
|
prettier:
|
||||||
specifier: ^3.9.7
|
specifier: ^3.9.8
|
||||||
version: 3.9.7
|
version: 3.9.8
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -303,8 +303,8 @@ packages:
|
|||||||
picocolors@1.1.1:
|
picocolors@1.1.1:
|
||||||
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
||||||
|
|
||||||
prettier@3.9.7:
|
prettier@3.9.8:
|
||||||
resolution: {integrity: sha512-T3mF5P7HFzZVLDQuCUNtJj6WK1pcpLMweMNUVwGb01bLNkH9AkKxtZvmInw8K6bnn2O3d6/5RHl6zSHiBAD0Og==}
|
resolution: {integrity: sha512-WRFq3Wn3WId7LLROfMLdH7xaFr2jR62wU8nLO6rQUOLOxNZUviyJQs1M0iIhLexSFy+L+w0ch66wtoO2jRjG0A==}
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ snapshots:
|
|||||||
|
|
||||||
'@msgpack/msgpack@3.1.3': {}
|
'@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:
|
dependencies:
|
||||||
'@babel/generator': 7.29.8
|
'@babel/generator': 7.29.8
|
||||||
'@babel/parser': 7.29.8
|
'@babel/parser': 7.29.8
|
||||||
@@ -383,7 +383,7 @@ snapshots:
|
|||||||
lodash-es: 4.18.1
|
lodash-es: 4.18.1
|
||||||
minimatch: 9.0.9
|
minimatch: 9.0.9
|
||||||
parse-imports-exports: 0.2.4
|
parse-imports-exports: 0.2.4
|
||||||
prettier: 3.9.7
|
prettier: 3.9.8
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -421,4 +421,4 @@ snapshots:
|
|||||||
|
|
||||||
picocolors@1.1.1: {}
|
picocolors@1.1.1: {}
|
||||||
|
|
||||||
prettier@3.9.7: {}
|
prettier@3.9.8: {}
|
||||||
|
|||||||
@@ -580,7 +580,7 @@ let ap_settings = {
|
|||||||
max_clients: 4
|
max_clients: 4
|
||||||
};
|
};
|
||||||
const ap_status = {
|
const ap_status = {
|
||||||
status: 1,
|
status: 0, // active - an inactive AP reports no address at all
|
||||||
ip_address: '192.168.4.1',
|
ip_address: '192.168.4.1',
|
||||||
mac_address: '3C:61:05:03:AB:2D',
|
mac_address: '3C:61:05:03:AB:2D',
|
||||||
station_num: 0
|
station_num: 0
|
||||||
@@ -612,6 +612,11 @@ let network_settings = {
|
|||||||
const network_status = {
|
const network_status = {
|
||||||
status: 3,
|
status: 3,
|
||||||
local_ip: '10.10.10.101',
|
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',
|
mac_address: '3C:61:05:03:AB:2C',
|
||||||
rssi: -41,
|
rssi: -41,
|
||||||
ssid: 'home',
|
ssid: 'home',
|
||||||
@@ -619,8 +624,7 @@ const network_status = {
|
|||||||
channel: 11,
|
channel: 11,
|
||||||
subnet_mask: '255.255.255.0',
|
subnet_mask: '255.255.255.0',
|
||||||
gateway_ip: '10.10.10.1',
|
gateway_ip: '10.10.10.1',
|
||||||
dns_ip_1: '10.10.10.1',
|
dns: ['10.10.10.1', 'fd00:1234:5678::1'],
|
||||||
dns_ip_2: '0.0.0.0',
|
|
||||||
hostname: 'ems-esp',
|
hostname: 'ems-esp',
|
||||||
reconnect_count: 1
|
reconnect_count: 1
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ void APStatus::apStatus(AsyncWebServerRequest * request) {
|
|||||||
JsonObject root = response->getRoot();
|
JsonObject root = response->getRoot();
|
||||||
|
|
||||||
root["status"] = _apSettingsService->getAPNetworkStatus();
|
root["status"] = _apSettingsService->getAPNetworkStatus();
|
||||||
root["ip_address"] = emsesp::EMSESP::network_.getLocalIP();
|
root["ip_address"] = emsesp::EMSESP::network_.getAPIP();
|
||||||
root["mac_address"] = emsesp::EMSESP::network_.getMacAddress();
|
root["mac_address"] = emsesp::EMSESP::network_.getAPMacAddress();
|
||||||
root["station_num"] = emsesp::EMSESP::network_.getStationNum();
|
root["station_num"] = emsesp::EMSESP::network_.getAPStationNum();
|
||||||
|
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
|
|||||||
@@ -2,6 +2,30 @@
|
|||||||
|
|
||||||
#include <emsesp.h>
|
#include <emsesp.h>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void add_ipv6(JsonObject root, NetworkInterface & netif) {
|
||||||
|
auto found = emsesp::Network::ipv6_addresses(netif);
|
||||||
|
if (found.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JsonArray addresses = root["ipv6"].to<JsonArray>();
|
||||||
|
for (const auto & ipv6 : found) {
|
||||||
|
JsonObject entry = addresses.add<JsonObject>();
|
||||||
|
entry["address"] = ipv6.ip.toString();
|
||||||
|
entry["scope"] = ipv6.scope;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_dns(JsonObject root, const NetworkInterface & netif) {
|
||||||
|
JsonArray servers = root["dns"].to<JsonArray>();
|
||||||
|
for (const auto & ip : emsesp::Network::dns_servers(netif)) {
|
||||||
|
servers.add(ip.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
NetworkStatus::NetworkStatus(AsyncWebServer * server, SecurityManager * securityManager) {
|
NetworkStatus::NetworkStatus(AsyncWebServer * server, SecurityManager * securityManager) {
|
||||||
securityManager->addEndpoint(server, NETWORK_STATUS_SERVICE_PATH, AuthenticationPredicates::IS_AUTHENTICATED, [this](AsyncWebServerRequest * request) {
|
securityManager->addEndpoint(server, NETWORK_STATUS_SERVICE_PATH, AuthenticationPredicates::IS_AUTHENTICATED, [this](AsyncWebServerRequest * request) {
|
||||||
networkStatus(request);
|
networkStatus(request);
|
||||||
@@ -27,21 +51,15 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
|
|||||||
if (emsesp::EMSESP::network_.ethernet_connected()) {
|
if (emsesp::EMSESP::network_.ethernet_connected()) {
|
||||||
// Ethernet
|
// Ethernet
|
||||||
root["local_ip"] = ETH.localIP().toString();
|
root["local_ip"] = ETH.localIP().toString();
|
||||||
root["local_ipv6"] = ETH.linkLocalIPv6().toString();
|
|
||||||
root["mac_address"] = ETH.macAddress();
|
root["mac_address"] = ETH.macAddress();
|
||||||
root["subnet_mask"] = ETH.subnetMask().toString();
|
root["subnet_mask"] = ETH.subnetMask().toString();
|
||||||
root["gateway_ip"] = ETH.gatewayIP().toString();
|
if (IPUtils::isSet(ETH.gatewayIP())) {
|
||||||
IPAddress dnsIP1 = ETH.dnsIP(0);
|
root["gateway_ip"] = ETH.gatewayIP().toString();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
add_ipv6(root, ETH);
|
||||||
|
add_dns(root, ETH);
|
||||||
} else if (wifi_status == WL_CONNECTED) {
|
} else if (wifi_status == WL_CONNECTED) {
|
||||||
root["local_ip"] = WiFi.localIP().toString();
|
root["local_ip"] = WiFi.localIP().toString();
|
||||||
root["local_ipv6"] = WiFi.linkLocalIPv6().toString();
|
|
||||||
root["mac_address"] = WiFi.macAddress();
|
root["mac_address"] = WiFi.macAddress();
|
||||||
root["rssi"] = WiFi.RSSI();
|
root["rssi"] = WiFi.RSSI();
|
||||||
root["ssid"] = WiFi.SSID();
|
root["ssid"] = WiFi.SSID();
|
||||||
@@ -49,18 +67,11 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
|
|||||||
root["channel"] = WiFi.channel();
|
root["channel"] = WiFi.channel();
|
||||||
root["reconnect_count"] = emsesp::EMSESP::network_.getNetworkReconnects();
|
root["reconnect_count"] = emsesp::EMSESP::network_.getNetworkReconnects();
|
||||||
root["subnet_mask"] = WiFi.subnetMask().toString();
|
root["subnet_mask"] = WiFi.subnetMask().toString();
|
||||||
|
if (IPUtils::isSet(WiFi.gatewayIP())) {
|
||||||
if (WiFi.gatewayIP() != INADDR_NONE) {
|
|
||||||
root["gateway_ip"] = WiFi.gatewayIP().toString();
|
root["gateway_ip"] = WiFi.gatewayIP().toString();
|
||||||
}
|
}
|
||||||
IPAddress dnsIP1 = WiFi.dnsIP(0);
|
add_ipv6(root, WiFi.STA);
|
||||||
IPAddress dnsIP2 = WiFi.dnsIP(1);
|
add_dns(root, WiFi.STA);
|
||||||
if (dnsIP1 != INADDR_NONE) {
|
|
||||||
root["dns_ip_1"] = dnsIP1.toString();
|
|
||||||
}
|
|
||||||
if (dnsIP2 != INADDR_NONE) {
|
|
||||||
root["dns_ip_2"] = dnsIP2.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response->setLength();
|
response->setLength();
|
||||||
|
|||||||
+20
-14
@@ -1723,17 +1723,23 @@ void EMSESP::start() {
|
|||||||
|
|
||||||
// start the file system
|
// start the file system
|
||||||
#ifndef EMSESP_STANDALONE
|
#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)) {
|
if (!LittleFS.begin(true)) {
|
||||||
LOG_ERROR("LittleFS Mount Failed");
|
LOG_ERROR("LittleFS Mount Failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// else {
|
#endif
|
||||||
// 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
|
// 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;
|
bool factory_settings = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// start NVS storage
|
// start NVS storage
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
if (esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_NVS, "nvs1")) {
|
if (esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_NVS, "nvs1")) {
|
||||||
nvs_.begin("ems-esp", false, "nvs1");
|
nvs_.begin("ems-esp", false, "nvs1");
|
||||||
@@ -1766,11 +1772,11 @@ void EMSESP::start() {
|
|||||||
// loads core system services settings (mqtt, ap, ntp etc)
|
// loads core system services settings (mqtt, ap, ntp etc)
|
||||||
esp32React.begin();
|
esp32React.begin();
|
||||||
|
|
||||||
// output filesystem folders and files for debugging
|
// output filesystem folders and files for debugging
|
||||||
// #if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
// LOG_DEBUG("Listing root directory after:");
|
LOG_DEBUG("Listing root directory after:");
|
||||||
// system_.listDir("/", 3); // show the contents of the root directory
|
system_.listDir("/", 3); // show the contents of the root directory
|
||||||
// #endif
|
#endif
|
||||||
|
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
if (factory_settings) {
|
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());
|
LOG_INFO("Last system reset reason Core0: %s, Core1: %s", system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// see if we're restoring a settings file
|
// see if we're restoring a settings file
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
if (system_.check_restore()) {
|
if (system_.check_restore()) {
|
||||||
LOG_WARNING("EMS-ESP will restart to apply new settings. Please wait.");
|
LOG_WARNING("EMS-ESP will restart to apply new settings. Please wait.");
|
||||||
|
|||||||
+67
-28
@@ -154,44 +154,83 @@ bool Network::formatBSSID([[maybe_unused]] const String & bssid, [[maybe_unused]
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the local IP address of the network interface
|
// get the soft-AP's own IP address, empty when the AP isn't running
|
||||||
std::string Network::getLocalIP() const {
|
std::string Network::getAPIP() const {
|
||||||
switch (network_iface_) {
|
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
case NetIface::AP:
|
const IPAddress ip = WiFi.softAPIP();
|
||||||
return WiFi.softAPIP().toString().c_str();
|
if (static_cast<uint32_t>(ip) != 0) {
|
||||||
case NetIface::WIFI:
|
return ip.toString().c_str();
|
||||||
return WiFi.localIP().toString().c_str();
|
|
||||||
case NetIface::ETHERNET:
|
|
||||||
return ETH.localIP().toString().c_str();
|
|
||||||
case NetIface::NONE:
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the MAC address of the network interface
|
|
||||||
std::string Network::getMacAddress() const {
|
|
||||||
switch (network_iface_) {
|
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
case NetIface::AP:
|
// Every IPv6 address bound to the interface, widest scope first so the address most people need
|
||||||
return WiFi.softAPmacAddress().c_str();
|
// comes out on top. linkLocalIPv6() and globalIPv6() each only ever return a single address, so a
|
||||||
case NetIface::WIFI:
|
// dual-stack host holding both a ULA and a routable GUA would have one of them hidden.
|
||||||
return WiFi.macAddress().c_str();
|
std::vector<Network::IPv6Address> Network::ipv6_addresses([[maybe_unused]] NetworkInterface & netif) {
|
||||||
case NetIface::ETHERNET:
|
std::vector<IPv6Address> addresses;
|
||||||
return ETH.macAddress().c_str();
|
|
||||||
case NetIface::NONE:
|
#if CONFIG_LWIP_IPV6
|
||||||
#endif
|
esp_ip6_addr_t raw[CONFIG_LWIP_IPV6_NUM_ADDRESSES];
|
||||||
default:
|
int found = esp_netif_get_all_ip6(netif.netif(), raw);
|
||||||
return "";
|
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<const uint8_t *>(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<IPAddress> Network::dns_servers(const NetworkInterface & netif) {
|
||||||
|
std::vector<IPAddress> servers;
|
||||||
|
for (uint8_t i = 0; i < ESP_NETIF_DNS_MAX; i++) {
|
||||||
|
IPAddress ip = netif.dnsIP(i);
|
||||||
|
if (ip.type() == IPv4 ? static_cast<uint32_t>(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
|
// get the number of sessions connected to the AP
|
||||||
uint8_t Network::getStationNum() const {
|
uint8_t Network::getAPStationNum() const {
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
return network_iface_ == NetIface::AP ? WiFi.softAPgetStationNum() : 0;
|
return WiFi.softAPgetStationNum();
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+18
-3
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
#include <esp_mac.h>
|
#include <esp_mac.h>
|
||||||
|
#include <esp_netif.h>
|
||||||
#include <esp_wifi.h>
|
#include <esp_wifi.h>
|
||||||
#include <ETH.h>
|
#include <ETH.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <esp32-psram.h>
|
#include <esp32-psram.h>
|
||||||
#include <uuid/log.h>
|
#include <uuid/log.h>
|
||||||
@@ -132,11 +134,24 @@ class Network {
|
|||||||
return reconnect_count_;
|
return reconnect_count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getLocalIP() const;
|
// the soft-AP's own details, which are what the Access Point status page reports
|
||||||
std::string getMacAddress() const;
|
std::string getAPIP() const;
|
||||||
uint8_t getStationNum() const;
|
std::string getAPMacAddress() const;
|
||||||
|
uint8_t getAPStationNum() const;
|
||||||
|
|
||||||
const char * ethernet_status() 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<IPv6Address> ipv6_addresses(NetworkInterface & netif);
|
||||||
|
static std::vector<IPAddress> dns_servers(const NetworkInterface & netif);
|
||||||
|
#endif
|
||||||
|
|
||||||
void reconnect();
|
void reconnect();
|
||||||
|
|
||||||
// ask for a reconnect() to run from the next Network::loop()
|
// ask for a reconnect() to run from the next Network::loop()
|
||||||
|
|||||||
+40
-31
@@ -98,16 +98,40 @@ static void sendmail_tls_handshake(bool & success) {
|
|||||||
success = sendmail_ssl_client != nullptr && sendmail_ssl_client->connectSSL();
|
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
|
// Print the full set of addresses for an interface. Every DNS server is listed, labelled with its
|
||||||
// IPv6 server. Pick the first IPv4 one so it matches the label we print it under.
|
// own family since the slots are shared, and every IPv6 address with its scope.
|
||||||
static IPAddress dns_ipv4(const NetworkInterface & netif) {
|
static void show_addresses(uuid::console::Shell & shell, NetworkInterface & netif) {
|
||||||
for (uint8_t i = 0; i < ESP_NETIF_DNS_MAX; i++) {
|
shell.printfln(" IPv4 address: %s/%s", uuid::printable_to_string(netif.localIP()).c_str(), uuid::printable_to_string(netif.subnetMask()).c_str());
|
||||||
IPAddress ip = netif.dnsIP(i);
|
shell.printfln(" IPv4 gateway: %s", uuid::printable_to_string(netif.gatewayIP()).c_str());
|
||||||
if (ip.type() == IPv4 && static_cast<uint32_t>(ip) != 0) {
|
for (const auto & dns : Network::dns_servers(netif)) {
|
||||||
return ip;
|
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<JsonArray>();
|
||||||
|
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<JsonArray>();
|
||||||
|
for (const auto & ipv6 : found) {
|
||||||
|
addresses.add(uuid::printable_to_string(ipv6.ip));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return IPAddress();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -893,18 +917,13 @@ void System::send_info_mqtt() {
|
|||||||
if (EMSESP::network_.ethernet_connected()) {
|
if (EMSESP::network_.ethernet_connected()) {
|
||||||
doc["network"] = "ethernet";
|
doc["network"] = "ethernet";
|
||||||
doc["hostname"] = ETH.getHostname();
|
doc["hostname"] = ETH.getHostname();
|
||||||
|
add_addresses(doc, ETH);
|
||||||
} else if (EMSESP::network_.wifi_connected()) {
|
} else if (EMSESP::network_.wifi_connected()) {
|
||||||
doc["network"] = "wifi";
|
doc["network"] = "wifi";
|
||||||
doc["hostname"] = WiFi.getHostname();
|
doc["hostname"] = WiFi.getHostname();
|
||||||
doc["SSID"] = WiFi.SSID();
|
doc["SSID"] = WiFi.SSID();
|
||||||
doc["BSSID"] = WiFi.BSSIDstr();
|
doc["BSSID"] = WiFi.BSSIDstr();
|
||||||
doc["MAC"] = WiFi.macAddress();
|
add_addresses(doc, WiFi.STA);
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Mqtt::queue_publish_retain(F_(info), doc.as<JsonObject>()); // topic called "info" and it's Retained
|
Mqtt::queue_publish_retain(F_(info), doc.as<JsonObject>()); // 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(" TxPower: %s dBm", Helpers::render_value(result, (double)(WiFi.getTxPower() / 4), 1));
|
||||||
shell.printfln(" MAC address: %s", WiFi.macAddress().c_str());
|
shell.printfln(" MAC address: %s", WiFi.macAddress().c_str());
|
||||||
shell.printfln(" Hostname: %s", WiFi.getHostname());
|
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());
|
show_addresses(shell, WiFi.STA);
|
||||||
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());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WL_CONNECT_FAILED:
|
case WL_CONNECT_FAILED:
|
||||||
@@ -1301,12 +1315,7 @@ void System::show_system(uuid::console::Shell & shell) {
|
|||||||
if (EMSESP::network_.ethernet_connected()) {
|
if (EMSESP::network_.ethernet_connected()) {
|
||||||
shell.printfln(" Ethernet MAC address: %s", ETH.macAddress().c_str());
|
shell.printfln(" Ethernet MAC address: %s", ETH.macAddress().c_str());
|
||||||
shell.printfln(" Hostname: %s", ETH.getHostname());
|
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());
|
show_addresses(shell, ETH);
|
||||||
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 AP is connected
|
// show AP is connected
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.9.0-dev.11"
|
#define EMSESP_APP_VERSION "3.9.0-dev.12"
|
||||||
|
|||||||
Reference in New Issue
Block a user