diff --git a/Config.h b/Config.h index f5cd215..b17f6e6 100644 --- a/Config.h +++ b/Config.h @@ -1,6 +1,6 @@ #pragma once -#define NUKI_HUB_VERSION "7.3-wm" +#define NUKI_HUB_VERSION "7.3-wm-2" #define MQTT_QOS_LEVEL 1 #define MQTT_CLEAN_SESSIONS false \ No newline at end of file diff --git a/Network.cpp b/Network.cpp index 20a00f7..aa5514d 100644 --- a/Network.cpp +++ b/Network.cpp @@ -144,7 +144,7 @@ void Network::initialize() } } -int Network::update() +bool Network::update() { unsigned long ts = millis(); @@ -179,11 +179,6 @@ int Network::update() } - if(!_device->isConnected()) - { - return 2; - } - if(!_device->mqttClient()->connected()) { if(_networkTimeout > 0 && (ts - _lastConnectedTs > _networkTimeout * 1000) && ts > 60000) @@ -196,7 +191,7 @@ int Network::update() bool success = reconnect(); if(!success) { - return 1; + return false; } } @@ -233,7 +228,7 @@ int Network::update() } _device->mqttClient()->poll(); - return 0; + return true; } bool Network::reconnect() diff --git a/Network.h b/Network.h index 953094b..23813bc 100644 --- a/Network.h +++ b/Network.h @@ -18,7 +18,7 @@ public: explicit Network(Preferences* preferences, const String& maintenancePathPrefix); void initialize(); - int update(); + bool update(); void registerMqttReceiver(MqttReceiver* receiver); void reconfigureDevice(); void setMqttPresencePath(char* path); diff --git a/main.cpp b/main.cpp index a9d2417..931ab5b 100644 --- a/main.cpp +++ b/main.cpp @@ -31,24 +31,20 @@ void networkTask(void *pvParameters) { while(true) { - bool r = network->update(); + bool connected = network->update(); - switch(r) + if(connected) { - // Network Device and MQTT is connected. Process all updates. - case 0: - case 1: - if(openerEnabled) - { - networkOpener->update(); - } - network->update(); - webCfgServer->update(); - break; - // Neither Network Devicc or MQTT is connected. Call network to allow for a reconnect. - default: - network->update(); - break; + if(openerEnabled) + { + networkOpener->update(); + } + network->update(); + webCfgServer->update(); + } + else + { + network->update(); } delay(200);