Network: status reports mask/gw/dns; UI shows the DHCP lease in the static fields

With DHCP on, the greyed-out IP/netmask/gateway/DNS fields show the
addresses in use. Unticking DHCP keeps them as the starting point for a
static setup. (Static addressing itself is not applied yet.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 23:42:35 +10:00
parent 122e46e862
commit c4468c4af0
3 changed files with 24 additions and 2 deletions
+13 -1
View File
@@ -138,10 +138,19 @@ static void net_apply(const cJSON *g)
static void net_status(cJSON *st)
{
char ip[16] = "", mac_s[18] = "";
char ip[16] = "", mask[16] = "", gw[16] = "", dns[16] = "", mac_s[18] = "";
esp_netif_ip_info_t info;
if (esp_netif_get_ip_info(s_netif, &info) == ESP_OK && info.ip.addr) {
snprintf(ip, sizeof(ip), IPSTR, IP2STR(&info.ip));
snprintf(mask, sizeof(mask), IPSTR, IP2STR(&info.netmask));
if (info.gw.addr) {
snprintf(gw, sizeof(gw), IPSTR, IP2STR(&info.gw));
}
}
esp_netif_dns_info_t d;
if (esp_netif_get_dns_info(s_netif, ESP_NETIF_DNS_MAIN, &d) == ESP_OK && d.ip.type == ESP_IPADDR_TYPE_V4 &&
d.ip.u_addr.ip4.addr) {
snprintf(dns, sizeof(dns), IPSTR, IP2STR(&d.ip.u_addr.ip4));
}
uint8_t mac[6];
if (esp_netif_get_mac(s_netif, mac) == ESP_OK) {
@@ -151,6 +160,9 @@ static void net_status(cJSON *st)
// Single untagged interface until the VLAN split: AES67 and web share it.
cJSON_AddStringToObject(st, "ip", ip);
cJSON_AddStringToObject(st, "aes67_ip", ip);
cJSON_AddStringToObject(st, "mask", mask); // in use (from DHCP or static)
cJSON_AddStringToObject(st, "gw", gw);
cJSON_AddStringToObject(st, "dns", dns);
cJSON_AddStringToObject(st, "mac", mac_s);
cJSON_AddStringToObject(st, "link", s_link);
}