print IP address for LAN8720 devices

This commit is contained in:
technyon
2023-03-02 20:11:30 +01:00
parent 709135d8ca
commit d6c0223800
3 changed files with 15 additions and 3 deletions

View File

@@ -69,6 +69,7 @@ void EthLan8720Device::initialize()
{
delay(250);
WiFi.setHostname(_hostname.c_str());
_hardwareInitialized = ETH.begin(_phy_addr, _power, _mdc, _mdio, _type, _clock_mode, _use_mac_from_efuse);
if(_restartOnDisconnect)
@@ -102,7 +103,17 @@ bool EthLan8720Device::supportsEncryption()
bool EthLan8720Device::isConnected()
{
return ETH.linkUp();
bool connected = ETH.linkUp();
if(_lastConnected == false && connected == true)
{
Serial.print("Ethernet connected. IP address: ");
Serial.println(ETH.localIP().toString());
}
_lastConnected = connected;
return connected;
}
ReconnectStatus EthLan8720Device::reconnect()
@@ -111,7 +122,7 @@ ReconnectStatus EthLan8720Device::reconnect()
{
return ReconnectStatus::CriticalFailure;
}
delay(3000);
delay(200);
return isConnected() ? ReconnectStatus::Success : ReconnectStatus::Failure;
}

View File

@@ -72,6 +72,7 @@ private:
char* _path;
bool _useEncryption = false;
bool _hardwareInitialized = false;
bool _lastConnected = false;
uint8_t _phy_addr;
int _power;