mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-12 00:02:53 +00:00
IPv6 support
This commit is contained in:
parent
21bff28aee
commit
830e22d182
@ -72,7 +72,7 @@ struct NetworkConfig {
|
||||
uint8_t power;
|
||||
uint8_t sleep;
|
||||
uint8_t use11b;
|
||||
bool unused;
|
||||
bool ipv6;
|
||||
uint8_t mode;
|
||||
}; // 214
|
||||
|
||||
|
||||
@ -1034,6 +1034,7 @@ bool AmsConfiguration::relocateConfig103() {
|
||||
meter.txPin = 0xFF;
|
||||
meter.rxPinPullup = gpio103.hanPinPullup;
|
||||
wifi.mode = 1; // 1 == WiFi client
|
||||
wifi.ipv6 = false;
|
||||
|
||||
GpioConfig gpio = {
|
||||
gpio103.apPin,
|
||||
@ -1135,164 +1136,7 @@ void AmsConfiguration::print(Print* debugger)
|
||||
debugger->printf_P(PSTR("DNS2: '%s'\r\n"), network.dns2);
|
||||
}
|
||||
debugger->printf_P(PSTR("Hostname: '%s'\r\n"), network.hostname);
|
||||
debugger->printf_P(PSTR("mDNS: '%s'\r\n"), network.mdns ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("802.11b: '%s'\r\n"), network.use11b ? "Yes" : "No");
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
MqttConfig mqtt;
|
||||
if(getMqttConfig(mqtt)) {
|
||||
debugger->println(F("--MQTT configuration--"));
|
||||
if(strlen(mqtt.host) > 0) {
|
||||
debugger->printf_P(PSTR("Enabled: Yes\r\n"));
|
||||
debugger->printf_P(PSTR("Host: '%s'\r\n"), mqtt.host);
|
||||
debugger->printf_P(PSTR("Port: %i\r\n"), mqtt.port);
|
||||
debugger->printf_P(PSTR("Client ID: '%s'\r\n"), mqtt.clientId);
|
||||
debugger->printf_P(PSTR("Publish topic: '%s'\r\n"), mqtt.publishTopic);
|
||||
debugger->printf_P(PSTR("Subscribe topic: '%s'\r\n"), mqtt.subscribeTopic);
|
||||
if (strlen(mqtt.username) > 0) {
|
||||
debugger->printf_P(PSTR("Username: '%s'\r\n"), mqtt.username);
|
||||
debugger->printf_P(PSTR("Password: '%s'\r\n"), mqtt.password);
|
||||
}
|
||||
debugger->printf_P(PSTR("Payload format: %i\r\n"), mqtt.payloadFormat);
|
||||
debugger->printf_P(PSTR("SSL: %s\r\n"), mqtt.ssl ? "Yes" : "No");
|
||||
} else {
|
||||
debugger->printf_P(PSTR("Enabled: No\r\n"));
|
||||
}
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
WebConfig web;
|
||||
if(getWebConfig(web)) {
|
||||
debugger->println(F("--Web configuration--"));
|
||||
debugger->printf_P(PSTR("Security: %i\r\n"), web.security);
|
||||
if (web.security > 0) {
|
||||
debugger->printf_P(PSTR("Username: '%s'\r\n"), web.username);
|
||||
debugger->printf_P(PSTR("Password: '%s'\r\n"), web.password);
|
||||
}
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
MeterConfig meter;
|
||||
if(getMeterConfig(meter)) {
|
||||
debugger->println(F("--Meter configuration--"));
|
||||
debugger->printf_P(PSTR("HAN RX: %i\r\n"), meter.rxPin);
|
||||
debugger->printf_P(PSTR("HAN RX pullup %s\r\n"), meter.rxPinPullup ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("Baud: %i\r\n"), meter.baud);
|
||||
debugger->printf_P(PSTR("Parity: %i\r\n"), meter.parity);
|
||||
debugger->printf_P(PSTR("Invert serial: %s\r\n"), meter.invert ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("Buffer size: %i\r\n"), meter.bufferSize * 64);
|
||||
debugger->printf_P(PSTR("Distribution system: %i\r\n"), meter.distributionSystem);
|
||||
debugger->printf_P(PSTR("Main fuse: %i\r\n"), meter.mainFuse);
|
||||
debugger->printf_P(PSTR("Production Capacity: %i\r\n"), meter.productionCapacity);
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
GpioConfig gpio;
|
||||
if(getGpioConfig(gpio)) {
|
||||
debugger->println(F("--GPIO configuration--"));
|
||||
debugger->printf_P(PSTR("LED pin: %i\r\n"), gpio.ledPin);
|
||||
debugger->printf_P(PSTR("LED inverted: %s\r\n"), gpio.ledInverted ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("LED red pin: %i\r\n"), gpio.ledPinRed);
|
||||
debugger->printf_P(PSTR("LED green pin: %i\r\n"), gpio.ledPinGreen);
|
||||
debugger->printf_P(PSTR("LED blue pin: %i\r\n"), gpio.ledPinBlue);
|
||||
debugger->printf_P(PSTR("LED inverted: %s\r\n"), gpio.ledRgbInverted ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("AP pin: %i\r\n"), gpio.apPin);
|
||||
debugger->printf_P(PSTR("Temperature pin: %i\r\n"), gpio.tempSensorPin);
|
||||
debugger->printf_P(PSTR("Temp analog pin: %i\r\n"), gpio.tempAnalogSensorPin);
|
||||
debugger->printf_P(PSTR("Vcc pin: %i\r\n"), gpio.vccPin);
|
||||
debugger->printf_P(PSTR("LED disable pin: %i\r\n"), gpio.ledDisablePin);
|
||||
debugger->printf_P(PSTR("LED behaviour: %i\r\n"), gpio.ledBehaviour);
|
||||
if(gpio.vccMultiplier > 0) {
|
||||
debugger->printf_P(PSTR("Vcc multiplier: %f\r\n"), gpio.vccMultiplier / 1000.0);
|
||||
}
|
||||
if(gpio.vccOffset > 0) {
|
||||
debugger->printf_P(PSTR("Vcc offset: %f\r\n"), gpio.vccOffset / 100.0);
|
||||
}
|
||||
if(gpio.vccBootLimit > 0) {
|
||||
debugger->printf_P(PSTR("Vcc boot limit: %f\r\n"), gpio.vccBootLimit / 10.0);
|
||||
}
|
||||
debugger->printf_P(PSTR("GND resistor: %i\r\n"), gpio.vccResistorGnd);
|
||||
debugger->printf_P(PSTR("Vcc resistor: %i\r\n"), gpio.vccResistorVcc);
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
DomoticzConfig domo;
|
||||
if(getDomoticzConfig(domo)) {
|
||||
debugger->println(F("--Domoticz configuration--"));
|
||||
if(mqtt.payloadFormat == 3 && domo.elidx > 0) {
|
||||
debugger->printf_P(PSTR("Enabled: Yes\r\n"));
|
||||
debugger->printf_P(PSTR("Domoticz ELIDX: %i\r\n"), domo.elidx);
|
||||
debugger->printf_P(PSTR("Domoticz VL1IDX: %i\r\n"), domo.vl1idx);
|
||||
debugger->printf_P(PSTR("Domoticz VL2IDX: %i\r\n"), domo.vl2idx);
|
||||
debugger->printf_P(PSTR("Domoticz VL3IDX: %i\r\n"), domo.vl3idx);
|
||||
debugger->printf_P(PSTR("Domoticz CL1IDX: %i\r\n"), domo.cl1idx);
|
||||
} else {
|
||||
debugger->printf_P(PSTR("Enabled: No\r\n"));
|
||||
}
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
NtpConfig ntp;
|
||||
if(getNtpConfig(ntp)) {
|
||||
debugger->println(F("--NTP configuration--"));
|
||||
debugger->printf_P(PSTR("Enabled: %s\r\n"), ntp.enable ? "Yes" : "No");
|
||||
if(ntp.enable) {
|
||||
debugger->printf_P(PSTR("Timezone: %s\r\n"), ntp.timezone);
|
||||
debugger->printf_P(PSTR("Server: %s\r\n"), ntp.server);
|
||||
debugger->printf_P(PSTR("DHCP: %s\r\n"), ntp.dhcp ? "Yes" : "No");
|
||||
}
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
PriceServiceConfig price;
|
||||
if(getPriceServiceConfig(price)) {
|
||||
if(strlen(price.area) > 0) {
|
||||
debugger->println(F("--Price configuration--"));
|
||||
debugger->printf_P(PSTR("Area: %s\r\n"), price.area);
|
||||
debugger->printf_P(PSTR("Currency: %s\r\n"), price.currency);
|
||||
debugger->printf_P(PSTR("ENTSO-E Token: %s\r\n"), price.entsoeToken);
|
||||
}
|
||||
debugger->println(F(""));
|
||||
delay(10); debugger->println(F("-----------------------------------------------"));
|
||||
NetworkConfig network;
|
||||
if(getNetworkConfig(network)) {
|
||||
debugger->println(F("--Network configuration--"));
|
||||
switch(network.mode) {
|
||||
case 1:
|
||||
debugger->printf_P(PSTR("Mode: 'WiFi client'\r\n"));
|
||||
break;
|
||||
case 2:
|
||||
debugger->printf_P(PSTR("Mode: 'WiFi AP'\r\n"));
|
||||
break;
|
||||
case 3:
|
||||
debugger->printf_P(PSTR("Mode: 'Ethernet'\r\n"));
|
||||
break;
|
||||
}
|
||||
debugger->printf_P(PSTR("SSID: '%s'\r\n"), network.ssid);
|
||||
debugger->printf_P(PSTR("Psk: '%s'\r\n"), network.psk);
|
||||
if(strlen(network.ip) > 0) {
|
||||
debugger->printf_P(PSTR("IP: '%s'\r\n"), network.ip);
|
||||
debugger->printf_P(PSTR("Gateway: '%s'\r\n"), network.gateway);
|
||||
debugger->printf_P(PSTR("Subnet: '%s'\r\n"), network.subnet);
|
||||
debugger->printf_P(PSTR("DNS1: '%s'\r\n"), network.dns1);
|
||||
debugger->printf_P(PSTR("DNS2: '%s'\r\n"), network.dns2);
|
||||
}
|
||||
debugger->printf_P(PSTR("Hostname: '%s'\r\n"), network.hostname);
|
||||
debugger->printf_P(PSTR("IPv6: '%s'\r\n"), network.ipv6 ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("mDNS: '%s'\r\n"), network.mdns ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("802.11b: '%s'\r\n"), network.use11b ? "Yes" : "No");
|
||||
debugger->println(F(""));
|
||||
@ -1437,6 +1281,5 @@ void AmsConfiguration::print(Print* debugger)
|
||||
}
|
||||
|
||||
debugger->println(F("-----------------------------------------------"));
|
||||
debugger->flush();
|
||||
}
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#elif defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
esp_netif_t* get_esp_interface_netif(esp_interface_t interface);
|
||||
#endif
|
||||
|
||||
#define NETWORK_MODE_WIFI_CLIENT 1
|
||||
@ -31,6 +32,8 @@ public:
|
||||
virtual IPAddress getGateway();
|
||||
virtual IPAddress getDns(uint8_t idx);
|
||||
#if defined(ESP32)
|
||||
virtual IPv6Address getIPv6();
|
||||
virtual IPv6Address getDNSv6(uint8_t idx);
|
||||
virtual void eventHandler(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
#endif
|
||||
|
||||
|
||||
@ -26,8 +26,9 @@ public:
|
||||
IPAddress getSubnetMask();
|
||||
IPAddress getGateway();
|
||||
IPAddress getDns(uint8_t idx);
|
||||
|
||||
#if defined(ESP32)
|
||||
IPv6Address getIPv6();
|
||||
IPv6Address getDNSv6(uint8_t idx);
|
||||
void eventHandler(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
#endif
|
||||
|
||||
|
||||
@ -25,8 +25,9 @@ public:
|
||||
IPAddress getSubnetMask();
|
||||
IPAddress getGateway();
|
||||
IPAddress getDns(uint8_t idx);
|
||||
|
||||
#if defined(ESP32)
|
||||
IPv6Address getIPv6();
|
||||
IPv6Address getDNSv6(uint8_t idx);
|
||||
void eventHandler(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
#endif
|
||||
|
||||
|
||||
@ -27,8 +27,9 @@ public:
|
||||
IPAddress getSubnetMask();
|
||||
IPAddress getGateway();
|
||||
IPAddress getDns(uint8_t idx);
|
||||
|
||||
#if defined(ESP32)
|
||||
IPv6Address getIPv6();
|
||||
IPv6Address getDNSv6(uint8_t idx);
|
||||
void eventHandler(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
#endif
|
||||
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
|
||||
#if defined(ESP32)
|
||||
#include <ETH.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <lwip/dns.h>
|
||||
#endif
|
||||
|
||||
EthernetConnectionHandler::EthernetConnectionHandler(RemoteDebug* debugger) {
|
||||
@ -125,11 +127,34 @@ void EthernetConnectionHandler::eventHandler(WiFiEvent_t event, WiFiEventInfo_t
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||
if(debugger->isActive(RemoteDebug::INFO)) {
|
||||
debugger->printf_P(PSTR("IP: %s\n"), ETH.localIP().toString().c_str());
|
||||
debugger->printf_P(PSTR("GW: %s\n"), ETH.gatewayIP().toString().c_str());
|
||||
debugger->printf_P(PSTR("DNS: %s\n"), ETH.dnsIP().toString().c_str());
|
||||
debugger->printf_P(PSTR("IP: %s\n"), getIP().toString().c_str());
|
||||
debugger->printf_P(PSTR("GW: %s\n"), getGateway().toString().c_str());
|
||||
for(uint8_t i = 0; i < 3; i++) {
|
||||
IPAddress dns4 = getDns(i);
|
||||
if(!dns4.isAny()) debugger->printf_P(PSTR("DNS: %s\n"), dns4.toString().c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_GOT_IP6: {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) {
|
||||
IPv6Address ipv6 = getIPv6();
|
||||
if(ipv6 == IPv6Address()) {
|
||||
// No IP
|
||||
} else {
|
||||
debugger->printf_P(PSTR("IPv6: %s\n"), ipv6.toString().c_str());
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < 3; i++) {
|
||||
IPv6Address dns6 = getDNSv6(i);
|
||||
if(dns6 == IPv6Address()) {
|
||||
// No IP
|
||||
} else {
|
||||
debugger->printf_P(PSTR("DNSv6: %s\n"), dns6.toString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
||||
connected = false;
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) {
|
||||
@ -179,3 +204,23 @@ IPAddress EthernetConnectionHandler::getDns(uint8_t idx) {
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ESP32)
|
||||
IPv6Address EthernetConnectionHandler::getIPv6() {
|
||||
esp_ip6_addr_t addr;
|
||||
if(esp_netif_get_ip6_global(get_esp_interface_netif(ESP_IF_ETH), &addr) == ESP_OK) {
|
||||
return IPv6Address(addr.addr);
|
||||
}
|
||||
return IPv6Address();
|
||||
}
|
||||
|
||||
IPv6Address EthernetConnectionHandler::getDNSv6(uint8_t idx) {
|
||||
for(uint8_t i = 0; i < 3; i++) {
|
||||
const ip_addr_t * dns = dns_getserver(i);
|
||||
if(dns->type == IPADDR_TYPE_V6) {
|
||||
if(idx-- == 0) return IPv6Address(dns->u_addr.ip6.addr);
|
||||
}
|
||||
}
|
||||
return IPv6Address();
|
||||
}
|
||||
#endif
|
||||
@ -90,3 +90,13 @@ IPAddress WiFiAccessPointConnectionHandler::getGateway() {
|
||||
IPAddress WiFiAccessPointConnectionHandler::getDns(uint8_t idx) {
|
||||
return WiFi.softAPIP();
|
||||
}
|
||||
|
||||
#if defined(ESP32)
|
||||
IPv6Address WiFiAccessPointConnectionHandler::getIPv6() {
|
||||
return IPv6Address();
|
||||
}
|
||||
|
||||
IPv6Address WiFiAccessPointConnectionHandler::getDNSv6(uint8_t idx) {
|
||||
return IPv6Address();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "WiFiClientConnectionHandler.h"
|
||||
#if defined(ESP32)
|
||||
#include <esp_wifi.h>
|
||||
#include <lwip/dns.h>
|
||||
#endif
|
||||
|
||||
WiFiClientConnectionHandler::WiFiClientConnectionHandler(RemoteDebug* debugger) {
|
||||
@ -144,13 +145,11 @@ void WiFiClientConnectionHandler::eventHandler(WiFiEvent_t event, WiFiEventInfo_
|
||||
esp_wifi_config_11b_rate(WIFI_IF_STA, true);
|
||||
}
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP: {
|
||||
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Successfully connected to WiFi!\n"));
|
||||
if(debugger->isActive(RemoteDebug::INFO)) {
|
||||
debugger->printf_P(PSTR("IP: %s\n"), WiFi.localIP().toString().c_str());
|
||||
debugger->printf_P(PSTR("GW: %s\n"), WiFi.gatewayIP().toString().c_str());
|
||||
debugger->printf_P(PSTR("DNS: %s\n"), WiFi.dnsIP().toString().c_str());
|
||||
}
|
||||
if(config.ipv6 && !WiFi.enableIpV6()) {
|
||||
debugger->printf_P(PSTR("Unable to enable IPv6\n"));
|
||||
}
|
||||
#if defined(ESP32)
|
||||
if(firstConnect && config.use11b) {
|
||||
// If first boot and phyMode is better than 11b, disable 11b for BUS powered devices
|
||||
@ -194,7 +193,38 @@ void WiFiClientConnectionHandler::eventHandler(WiFiEvent_t event, WiFiEventInfo_
|
||||
#elif defined(ESP8266)
|
||||
WiFi.setOutputPower(config.power / 10.0);
|
||||
#endif
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP: {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) {
|
||||
debugger->printf_P(PSTR("IP: %s\n"), getIP().toString().c_str());
|
||||
debugger->printf_P(PSTR("GW: %s\n"), getGateway().toString().c_str());
|
||||
for(uint8_t i = 0; i < 3; i++) {
|
||||
IPAddress dns4 = getDns(i);
|
||||
if(!dns4.isAny()) debugger->printf_P(PSTR("DNS: %s\n"), dns4.toString().c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP6: {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) {
|
||||
IPv6Address ipv6 = getIPv6();
|
||||
if(ipv6 == IPv6Address()) {
|
||||
// No IP
|
||||
} else {
|
||||
debugger->printf_P(PSTR("IPv6: %s\n"), ipv6.toString().c_str());
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < 3; i++) {
|
||||
IPv6Address dns6 = getDNSv6(i);
|
||||
if(dns6 == IPv6Address()) {
|
||||
// No IP
|
||||
} else {
|
||||
debugger->printf_P(PSTR("DNSv6: %s\n"), dns6.toString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED: {
|
||||
wifi_err_reason_t reason = (wifi_err_reason_t) info.wifi_sta_disconnected.reason;
|
||||
const char* descr = WiFi.disconnectReasonName(reason);
|
||||
@ -236,5 +266,35 @@ IPAddress WiFiClientConnectionHandler::getGateway() {
|
||||
}
|
||||
|
||||
IPAddress WiFiClientConnectionHandler::getDns(uint8_t idx) {
|
||||
return WiFi.dnsIP(idx);
|
||||
#if defined(ESP32)
|
||||
for(uint8_t i = 0; i < 3; i++) {
|
||||
const ip_addr_t * dns = dns_getserver(i);
|
||||
if(dns->type == IPADDR_TYPE_V4) {
|
||||
if(idx-- == 0) return IPAddress(dns->u_addr.ip4.addr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
return WiFi.dnsIP(idx);
|
||||
#endif
|
||||
return IPAddress();
|
||||
}
|
||||
|
||||
#if defined(ESP32)
|
||||
IPv6Address WiFiClientConnectionHandler::getIPv6() {
|
||||
esp_ip6_addr_t addr;
|
||||
if(esp_netif_get_ip6_global(get_esp_interface_netif(ESP_IF_WIFI_STA), &addr) == ESP_OK) {
|
||||
return IPv6Address(addr.addr);
|
||||
}
|
||||
return IPv6Address();
|
||||
}
|
||||
|
||||
IPv6Address WiFiClientConnectionHandler::getDNSv6(uint8_t idx) {
|
||||
for(uint8_t i = 0; i < 3; i++) {
|
||||
const ip_addr_t * dns = dns_getserver(i);
|
||||
if(dns->type == IPADDR_TYPE_V6) {
|
||||
if(idx-- == 0) return IPv6Address(dns->u_addr.ip6.addr);
|
||||
}
|
||||
}
|
||||
return IPv6Address();
|
||||
}
|
||||
#endif
|
||||
|
||||
12
lib/SvelteUi/app/dist/index.js
vendored
12
lib/SvelteUi/app/dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -81,7 +81,7 @@
|
||||
},
|
||||
w: { s: '', p: '', w: 0.0, z: 255, a: true, b: true },
|
||||
n: {
|
||||
m: '', i: '', s: '', g: '', d1: '', d2: '', d: false, n1: '', n2: '', h: false
|
||||
m: '', i: '', s: '', g: '', d1: '', d2: '', d: false, n1: '', n2: '', h: false, x: false
|
||||
},
|
||||
q: {
|
||||
h: '', p: 1883, u: '', a: '', b: '',
|
||||
@ -558,6 +558,9 @@
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="my-1">
|
||||
<label><input name="nx" value="true" bind:checked={configuration.n.x} type="checkbox" class="rounded mb-1"/> IPv6</label>
|
||||
</div>
|
||||
<div class="my-1">
|
||||
<label><input name="nd" value="true" bind:checked={configuration.n.d} type="checkbox" class="rounded mb-1"/> {translations.conf?.network?.tick_mdns ?? "mDNS"}</label>
|
||||
</div>
|
||||
|
||||
@ -199,8 +199,18 @@
|
||||
{translations.conf?.network?.gw ?? "Gateway"}: {sysinfo.net.gw}
|
||||
</div>
|
||||
<div class="my-2">
|
||||
{translations.conf?.network?.dns ?? "DNS"}: {sysinfo.net.dns1} {#if sysinfo.net.dns2}/ {sysinfo.net.dns2}{/if}
|
||||
{#if sysinfo.net.dns1}{translations.conf?.network?.dns ?? "DNS"}: {sysinfo.net.dns1}{/if}
|
||||
{#if sysinfo.net.dns2}{translations.conf?.network?.dns ?? "DNS"}: {sysinfo.net.dns2}{/if}
|
||||
</div>
|
||||
{#if sysinfo.net.ipv6}
|
||||
<div class="my-2">
|
||||
IPv6: {sysinfo.net.ipv6}
|
||||
</div>
|
||||
<div class="my-2">
|
||||
{#if sysinfo.net.dns1v6}DNSv6: {sysinfo.net.dns1v6}{/if}
|
||||
{#if sysinfo.net.dns2v6}DNSv6: {sysinfo.net.dns2v6}{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="cnt">
|
||||
|
||||
@ -8,5 +8,6 @@
|
||||
"d2": "%s",
|
||||
"d": %s,
|
||||
"n1": "%s",
|
||||
"h": %s
|
||||
"h": %s,
|
||||
"x": %s
|
||||
},
|
||||
|
||||
@ -17,7 +17,10 @@
|
||||
"mask": "%s",
|
||||
"gw": "%s",
|
||||
"dns1": "%s",
|
||||
"dns2": "%s"
|
||||
"dns2": "%s",
|
||||
"ipv6": "%s",
|
||||
"dns1v6": "%s",
|
||||
"dns2v6": "%s"
|
||||
},
|
||||
"if": {
|
||||
"eth": %s
|
||||
|
||||
@ -279,6 +279,11 @@ void AmsWebServer::sysinfoJson() {
|
||||
IPAddress gateway;
|
||||
IPAddress dns1;
|
||||
IPAddress dns2;
|
||||
#if defined(ESP32)
|
||||
IPv6Address ipv6;
|
||||
IPv6Address dns1v6;
|
||||
IPv6Address dns2v6;
|
||||
#endif
|
||||
|
||||
if(ch == NULL) {
|
||||
localIp = WiFi.softAPIP();
|
||||
@ -292,6 +297,11 @@ void AmsWebServer::sysinfoJson() {
|
||||
gateway = ch->getGateway();
|
||||
dns1 = ch->getDns(0);
|
||||
dns2 = ch->getDns(1);
|
||||
#if defined(ESP32)
|
||||
ipv6 = ch->getIPv6();
|
||||
dns1v6 = ch->getDNSv6(0);
|
||||
dns2v6 = ch->getDNSv6(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
char macStr[18] = { 0 };
|
||||
@ -361,12 +371,18 @@ void AmsWebServer::sysinfoJson() {
|
||||
gateway.isSet() ? gateway.toString().c_str() : "",
|
||||
dns1.isSet() ? dns1.toString().c_str() : "",
|
||||
dns2.isSet() ? dns2.toString().c_str() : "",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
#else
|
||||
localIp != INADDR_NONE ? localIp.toString().c_str() : "",
|
||||
subnet != INADDR_NONE ? subnet.toString().c_str() : "",
|
||||
gateway != INADDR_NONE ? gateway.toString().c_str() : "",
|
||||
dns1 != INADDR_NONE ? dns1.toString().c_str() : "",
|
||||
dns2 != INADDR_NONE ? dns2.toString().c_str() : "",
|
||||
ipv6 == IPv6Address() ? "" : ipv6.toString().c_str(),
|
||||
dns1v6 == IPv6Address() ? "" : dns1v6.toString().c_str(),
|
||||
dns2v6 == IPv6Address() ? "" : dns2v6.toString().c_str(),
|
||||
#endif
|
||||
sys.boardType > 240 && sys.boardType < 250 ? "true" : "false",
|
||||
meterState->getMeterType(),
|
||||
@ -999,7 +1015,8 @@ void AmsWebServer::configurationJson() {
|
||||
networkConfig.dns2,
|
||||
networkConfig.mdns ? "true" : "false",
|
||||
ntpConfig.server,
|
||||
ntpConfig.dhcp ? "true" : "false"
|
||||
ntpConfig.dhcp ? "true" : "false",
|
||||
networkConfig.ipv6 ? "true" : "false"
|
||||
);
|
||||
server.sendContent(buf);
|
||||
snprintf_P(buf, BufferSize, CONF_MQTT_JSON,
|
||||
|
||||
@ -205,18 +205,30 @@ void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
if(setupMode) return; // None of this necessary in setup mode
|
||||
if(ch != NULL) ch->eventHandler(event, info);
|
||||
switch(event) {
|
||||
case ARDUINO_EVENT_WIFI_STA_CONNECTED: {
|
||||
dnsState = 0;
|
||||
if(ch != NULL) {
|
||||
NetworkConfig conf;
|
||||
ch->getCurrentConfig(conf);
|
||||
dnsState = conf.ipv6 ? 2 : 0; // Never reset if IPv6 is enabled
|
||||
debugI_P(PSTR("IPv6 enabled, not monitoring DNS poisoning"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP: {
|
||||
const ip_addr_t* dns = dns_getserver(0);
|
||||
memcpy(&dns0, dns, sizeof(dns0));
|
||||
if(dnsState == 0) {
|
||||
const ip_addr_t* dns = dns_getserver(0);
|
||||
memcpy(&dns0, dns, sizeof(dns0));
|
||||
|
||||
IPAddress res;
|
||||
int ret = WiFi.hostByName("hub.amsleser.no", res);
|
||||
if(ret == 0) {
|
||||
dnsState = 2;
|
||||
debugI_P(PSTR("No DNS, probably a closed network"));
|
||||
} else {
|
||||
debugI_P(PSTR("DNS is present and working, monitoring"));
|
||||
dnsState = 1;
|
||||
IPAddress res;
|
||||
int ret = WiFi.hostByName("hub.amsleser.no", res);
|
||||
if(ret == 0) {
|
||||
dnsState = 2;
|
||||
debugI_P(PSTR("No DNS, probably a closed network"));
|
||||
} else {
|
||||
debugI_P(PSTR("DNS is present and working, monitoring DNS poisoning"));
|
||||
dnsState = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user