From 9de86888a997f608f23a1ea4446641bb7da87705 Mon Sep 17 00:00:00 2001 From: technyon Date: Wed, 22 Feb 2023 19:23:20 +0100 Subject: [PATCH] LAN8720: return critical failure if hardware not found --- Network.cpp | 4 ++-- networkDevices/EthLan8720Device.cpp | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Network.cpp b/Network.cpp index 13664b5..480867e 100644 --- a/Network.cpp +++ b/Network.cpp @@ -72,12 +72,12 @@ void Network::setupDevice() } else if(hardwareDetect == 3) { - Log->print(F("W5500 on M5Stack Atom POE")); + Log->println(F("W5500 on M5Stack Atom POE")); _networkDeviceType = NetworkDeviceType::W5500; } else if(hardwareDetect == 4) { - Log->print(F("Olimex ESP32-POE / ESP-POE-ISO")); + Log->println(F("Olimex ESP32-POE / ESP-POE-ISO")); _networkDeviceType = NetworkDeviceType::LAN8720; } else diff --git a/networkDevices/EthLan8720Device.cpp b/networkDevices/EthLan8720Device.cpp index 41e226f..991599d 100644 --- a/networkDevices/EthLan8720Device.cpp +++ b/networkDevices/EthLan8720Device.cpp @@ -1,5 +1,5 @@ -#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT -#define ETH_PHY_POWER 12 +//#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT +//#define ETH_PHY_POWER 12 #include #include @@ -55,14 +55,14 @@ EthLan8720Device::EthLan8720Device(const String& hostname, Preferences* _prefere const String EthLan8720Device::deviceName() const { - return "LAN8720"; + return "Olimex LAN8720"; } void EthLan8720Device::initialize() { delay(250); - _hardwareInitialized = ETH.begin(); + _hardwareInitialized = ETH.begin(ETH_PHY_ADDR, 12, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLOCK_GPIO17_OUT); if(_restartOnDisconnect) { @@ -79,7 +79,7 @@ void EthLan8720Device::initialize() void EthLan8720Device::reconfigure() { delay(200); - restartEsp(RestartReason::ReconfigureWifi); + restartEsp(RestartReason::ReconfigureLAN8720); } void EthLan8720Device::printError() @@ -100,6 +100,10 @@ bool EthLan8720Device::isConnected() ReconnectStatus EthLan8720Device::reconnect() { + if(!_hardwareInitialized) + { + return ReconnectStatus::CriticalFailure; + } delay(3000); return isConnected() ? ReconnectStatus::Success : ReconnectStatus::Failure; }