apply restart option to W5500

This commit is contained in:
technyon
2022-06-30 20:38:52 +02:00
parent d693e8a065
commit 756c96a367
3 changed files with 9 additions and 2 deletions

View File

@@ -143,8 +143,8 @@ void setup()
preferences->putBool(preference_lock_enabled, true);
}
// const NetworkDeviceType networkDevice = NetworkDeviceType::WiFi;
const NetworkDeviceType networkDevice = digitalRead(NETWORK_SELECT) == HIGH ? NetworkDeviceType::WiFi : NetworkDeviceType::W5500;
const NetworkDeviceType networkDevice = NetworkDeviceType::WiFi;
// const NetworkDeviceType networkDevice = digitalRead(NETWORK_SELECT) == HIGH ? NetworkDeviceType::WiFi : NetworkDeviceType::W5500;
network = new NetworkLock(networkDevice, preferences);
network->initialize();

View File

@@ -9,6 +9,7 @@ W5500Device::W5500Device(const String &hostname, Preferences* preferences)
_preferences(preferences)
{
initializeMacAddress(_mac);
_restartOnDisconnect = _preferences->getBool(preference_restart_on_disconnect);
Serial.print("MAC Adress: ");
for(int i=0; i < 6; i++)
@@ -46,6 +47,11 @@ void W5500Device::initialize()
bool W5500Device::reconnect()
{
if(_restartOnDisconnect && millis() > 60000)
{
ESP.restart();
}
_hasDHCPAddress = false;
// start the Ethernet connection:

View File

@@ -31,6 +31,7 @@ private:
int _maintainResult = 0;
bool _hasDHCPAddress = false;
bool _restartOnDisconnect = false;
byte _mac[6];
};