disable all automatic restarts when OTA has started
This commit is contained in:
13
Network.cpp
13
Network.cpp
@@ -37,6 +37,8 @@ void Network::setupDevice(const NetworkDeviceType hardware)
|
||||
|
||||
void Network::initialize()
|
||||
{
|
||||
_restartOnDisconnect = _preferences->getBool(preference_restart_on_disconnect);
|
||||
|
||||
if(_hostname == "")
|
||||
{
|
||||
_hostname = "nukihub";
|
||||
@@ -102,6 +104,11 @@ int Network::update()
|
||||
|
||||
if(!_device->isConnected())
|
||||
{
|
||||
if(_restartOnDisconnect && millis() > 60000)
|
||||
{
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
Serial.println(F("Network not connected. Trying reconnect."));
|
||||
bool success = _device->reconnect();
|
||||
Serial.println(success ? F("Reconnect successful") : F("Reconnect failed"));
|
||||
@@ -250,6 +257,12 @@ void Network::setMqttPresencePath(char *path)
|
||||
strcpy(_mqttPresencePrefix, path);
|
||||
}
|
||||
|
||||
void Network::disableAutoRestarts()
|
||||
{
|
||||
_networkTimeout = 0;
|
||||
_restartOnDisconnect = false;
|
||||
}
|
||||
|
||||
bool Network::isMqttConnected()
|
||||
{
|
||||
return _mqttConnected;
|
||||
|
||||
Reference in New Issue
Block a user