apply restart option to W5500
This commit is contained in:
4
main.cpp
4
main.cpp
@@ -143,8 +143,8 @@ void setup()
|
|||||||
preferences->putBool(preference_lock_enabled, true);
|
preferences->putBool(preference_lock_enabled, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const NetworkDeviceType networkDevice = NetworkDeviceType::WiFi;
|
const NetworkDeviceType networkDevice = NetworkDeviceType::WiFi;
|
||||||
const NetworkDeviceType networkDevice = digitalRead(NETWORK_SELECT) == HIGH ? NetworkDeviceType::WiFi : NetworkDeviceType::W5500;
|
// const NetworkDeviceType networkDevice = digitalRead(NETWORK_SELECT) == HIGH ? NetworkDeviceType::WiFi : NetworkDeviceType::W5500;
|
||||||
|
|
||||||
network = new NetworkLock(networkDevice, preferences);
|
network = new NetworkLock(networkDevice, preferences);
|
||||||
network->initialize();
|
network->initialize();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ W5500Device::W5500Device(const String &hostname, Preferences* preferences)
|
|||||||
_preferences(preferences)
|
_preferences(preferences)
|
||||||
{
|
{
|
||||||
initializeMacAddress(_mac);
|
initializeMacAddress(_mac);
|
||||||
|
_restartOnDisconnect = _preferences->getBool(preference_restart_on_disconnect);
|
||||||
|
|
||||||
Serial.print("MAC Adress: ");
|
Serial.print("MAC Adress: ");
|
||||||
for(int i=0; i < 6; i++)
|
for(int i=0; i < 6; i++)
|
||||||
@@ -46,6 +47,11 @@ void W5500Device::initialize()
|
|||||||
|
|
||||||
bool W5500Device::reconnect()
|
bool W5500Device::reconnect()
|
||||||
{
|
{
|
||||||
|
if(_restartOnDisconnect && millis() > 60000)
|
||||||
|
{
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
|
||||||
_hasDHCPAddress = false;
|
_hasDHCPAddress = false;
|
||||||
|
|
||||||
// start the Ethernet connection:
|
// start the Ethernet connection:
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ private:
|
|||||||
|
|
||||||
int _maintainResult = 0;
|
int _maintainResult = 0;
|
||||||
bool _hasDHCPAddress = false;
|
bool _hasDHCPAddress = false;
|
||||||
|
bool _restartOnDisconnect = false;
|
||||||
|
|
||||||
byte _mac[6];
|
byte _mac[6];
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user