Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _codeql_detected_source_root
22 changes: 22 additions & 0 deletions src/net_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ NetManagerTask::NetManagerTask(LcdTask &lcd, LedManagerTask &led, TimeManager &t
_apClients(0),
_state(NetState::Starting),
_ipaddress(""),
_ipv6address(""),
_macaddress(""),
_clientDisconnects(0),
_clientRetry(false),
Expand Down Expand Up @@ -170,6 +171,7 @@ void NetManagerTask::wifiClientConnect()
WiFi.setSleep(WIFI_PS_NONE);
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
WiFi.enableIpV6();
WiFi.begin(esid.c_str(), epass.c_str());

_clientRetryTime = millis() + WIFI_CLIENT_RETRY_TIMEOUT;
Expand Down Expand Up @@ -425,6 +427,21 @@ void NetManagerTask::onNetEvent(WiFiEvent_t event, arduino_event_info_t &info)
wifiOnStationModeGotIP(dst);
} break;

case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
{
_ipv6address = WiFi.localIPv6().toString();
DBUGF("WiFi STA IPv6: %s", _ipv6address.c_str());

StaticJsonDocument<256> doc;
doc["wifi_client_connected"] = (int)net.isWifiClientConnected();
doc["eth_connected"] = (int)net.isWiredConnected();
doc["net_connected"] = (int)net.isWifiClientConnected();
doc["ipaddress"] = net.getIp();
doc["ipv6address"] = net.getIpv6();
doc["macaddress"] = net.getMac();
event_send(doc);
} break;

case ARDUINO_EVENT_WIFI_AP_STACONNECTED:
{
auto& src = info.wifi_ap_staconnected;
Expand Down Expand Up @@ -469,6 +486,7 @@ void NetManagerTask::onNetEvent(WiFiEvent_t event, arduino_event_info_t &info)
break;
case ARDUINO_EVENT_ETH_CONNECTED:
DBUGLN("ETH Connected");
ETH.enableIpV6();
break;
case ARDUINO_EVENT_ETH_GOT_IP:
DBUG("ETH MAC: ");
Expand All @@ -486,6 +504,10 @@ void NetManagerTask::onNetEvent(WiFiEvent_t event, arduino_event_info_t &info)
_ethConnected = true;
wifiStop();
break;
case ARDUINO_EVENT_ETH_GOT_IP6:
_ipv6address = ETH.localIPv6().toString();
DBUGF("ETH IPv6: %s", _ipv6address.c_str());
break;
case ARDUINO_EVENT_ETH_DISCONNECTED:
DBUGLN("ETH Disconnected");
_ethConnected = false;
Expand Down
4 changes: 4 additions & 0 deletions src/net_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class NetManagerTask : public MicroTasks::Task
// Network state
NetState _state;
String _ipaddress;
String _ipv6address;
String _macaddress;

DNSServer _dnsServer; // Create class DNS server, captive portal re-direct
Expand Down Expand Up @@ -215,6 +216,9 @@ class NetManagerTask : public MicroTasks::Task
String getIp() {
return _ipaddress;
}
String getIpv6() {
return _ipv6address;
}
String getMac() {
return _macaddress;
}
Expand Down
1 change: 1 addition & 0 deletions src/web_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ void buildStatus(DynamicJsonDocument &doc) {
doc["eth_connected"] = (int)net.isWiredConnected();
doc["net_connected"] = (int)net.isWifiClientConnected();
doc["ipaddress"] = net.getIp();
doc["ipv6address"] = net.getIpv6();
doc["macaddress"] = net.getMac();

doc["emoncms_connected"] = (int)emoncms_connected;
Expand Down
Loading