Check the link status on Ethernet #273

This commit is contained in:
Robert Strouse 2024-02-17 11:52:23 -08:00
parent 48ff18030e
commit 2a3d7aa7e7
3 changed files with 8 additions and 0 deletions

View file

@ -486,6 +486,7 @@ bool Network::openSoftAP() {
bool Network::connected() {
if(this->connType == conn_types::unset) return false;
else if(this->connType == conn_types::wifi) return WiFi.status() == WL_CONNECTED;
else if(this->connType == conn_types::ethernet) return ETH.linkUp();
else return this->connType != conn_types::unset;
return false;
}
@ -506,6 +507,13 @@ void Network::networkEvent(WiFiEvent_t event) {
net.mac = ETH.macAddress();
net.setConnected(conn_types::ethernet);
break;
/*
case ARDUINO_EVENT_ETH_LOST_IP:
Serial.println("Ethernet Lost IP");
sockEmit.sendToClients("ethernet", "{\"connected\":false, \"speed\":0,\"fullduplex\":false}");
net.connType = conn_types::unset;
break;
*/
case ARDUINO_EVENT_ETH_CONNECTED:
Serial.print("Ethernet Connected ");
// We don't want to call setConnected if we do not have an IP address yet

Binary file not shown.

Binary file not shown.