disable all automatic restarts when OTA has started

This commit is contained in:
technyon
2022-07-21 18:31:46 +02:00
parent 2ade696e8b
commit a24bb4b0c2
9 changed files with 35 additions and 7 deletions

View File

@@ -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;