LAN8720: return critical failure if hardware not found
This commit is contained in:
@@ -72,12 +72,12 @@ void Network::setupDevice()
|
|||||||
}
|
}
|
||||||
else if(hardwareDetect == 3)
|
else if(hardwareDetect == 3)
|
||||||
{
|
{
|
||||||
Log->print(F("W5500 on M5Stack Atom POE"));
|
Log->println(F("W5500 on M5Stack Atom POE"));
|
||||||
_networkDeviceType = NetworkDeviceType::W5500;
|
_networkDeviceType = NetworkDeviceType::W5500;
|
||||||
}
|
}
|
||||||
else if(hardwareDetect == 4)
|
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;
|
_networkDeviceType = NetworkDeviceType::LAN8720;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
|
//#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
|
||||||
#define ETH_PHY_POWER 12
|
//#define ETH_PHY_POWER 12
|
||||||
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <ETH.h>
|
#include <ETH.h>
|
||||||
@@ -55,14 +55,14 @@ EthLan8720Device::EthLan8720Device(const String& hostname, Preferences* _prefere
|
|||||||
|
|
||||||
const String EthLan8720Device::deviceName() const
|
const String EthLan8720Device::deviceName() const
|
||||||
{
|
{
|
||||||
return "LAN8720";
|
return "Olimex LAN8720";
|
||||||
}
|
}
|
||||||
|
|
||||||
void EthLan8720Device::initialize()
|
void EthLan8720Device::initialize()
|
||||||
{
|
{
|
||||||
delay(250);
|
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)
|
if(_restartOnDisconnect)
|
||||||
{
|
{
|
||||||
@@ -79,7 +79,7 @@ void EthLan8720Device::initialize()
|
|||||||
void EthLan8720Device::reconfigure()
|
void EthLan8720Device::reconfigure()
|
||||||
{
|
{
|
||||||
delay(200);
|
delay(200);
|
||||||
restartEsp(RestartReason::ReconfigureWifi);
|
restartEsp(RestartReason::ReconfigureLAN8720);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EthLan8720Device::printError()
|
void EthLan8720Device::printError()
|
||||||
@@ -100,6 +100,10 @@ bool EthLan8720Device::isConnected()
|
|||||||
|
|
||||||
ReconnectStatus EthLan8720Device::reconnect()
|
ReconnectStatus EthLan8720Device::reconnect()
|
||||||
{
|
{
|
||||||
|
if(!_hardwareInitialized)
|
||||||
|
{
|
||||||
|
return ReconnectStatus::CriticalFailure;
|
||||||
|
}
|
||||||
delay(3000);
|
delay(3000);
|
||||||
return isConnected() ? ReconnectStatus::Success : ReconnectStatus::Failure;
|
return isConnected() ? ReconnectStatus::Success : ReconnectStatus::Failure;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user