completely remove device connected check fix network task loop
This commit is contained in:
2
Config.h
2
Config.h
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define NUKI_HUB_VERSION "7.3-wm"
|
#define NUKI_HUB_VERSION "7.3-wm-2"
|
||||||
|
|
||||||
#define MQTT_QOS_LEVEL 1
|
#define MQTT_QOS_LEVEL 1
|
||||||
#define MQTT_CLEAN_SESSIONS false
|
#define MQTT_CLEAN_SESSIONS false
|
||||||
11
Network.cpp
11
Network.cpp
@@ -144,7 +144,7 @@ void Network::initialize()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Network::update()
|
bool Network::update()
|
||||||
{
|
{
|
||||||
unsigned long ts = millis();
|
unsigned long ts = millis();
|
||||||
|
|
||||||
@@ -179,11 +179,6 @@ int Network::update()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_device->isConnected())
|
|
||||||
{
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!_device->mqttClient()->connected())
|
if(!_device->mqttClient()->connected())
|
||||||
{
|
{
|
||||||
if(_networkTimeout > 0 && (ts - _lastConnectedTs > _networkTimeout * 1000) && ts > 60000)
|
if(_networkTimeout > 0 && (ts - _lastConnectedTs > _networkTimeout * 1000) && ts > 60000)
|
||||||
@@ -196,7 +191,7 @@ int Network::update()
|
|||||||
bool success = reconnect();
|
bool success = reconnect();
|
||||||
if(!success)
|
if(!success)
|
||||||
{
|
{
|
||||||
return 1;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +228,7 @@ int Network::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_device->mqttClient()->poll();
|
_device->mqttClient()->poll();
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Network::reconnect()
|
bool Network::reconnect()
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
explicit Network(Preferences* preferences, const String& maintenancePathPrefix);
|
explicit Network(Preferences* preferences, const String& maintenancePathPrefix);
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
int update();
|
bool update();
|
||||||
void registerMqttReceiver(MqttReceiver* receiver);
|
void registerMqttReceiver(MqttReceiver* receiver);
|
||||||
void reconfigureDevice();
|
void reconfigureDevice();
|
||||||
void setMqttPresencePath(char* path);
|
void setMqttPresencePath(char* path);
|
||||||
|
|||||||
14
main.cpp
14
main.cpp
@@ -31,24 +31,20 @@ void networkTask(void *pvParameters)
|
|||||||
{
|
{
|
||||||
while(true)
|
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)
|
if(openerEnabled)
|
||||||
{
|
{
|
||||||
networkOpener->update();
|
networkOpener->update();
|
||||||
}
|
}
|
||||||
network->update();
|
network->update();
|
||||||
webCfgServer->update();
|
webCfgServer->update();
|
||||||
break;
|
}
|
||||||
// Neither Network Devicc or MQTT is connected. Call network to allow for a reconnect.
|
else
|
||||||
default:
|
{
|
||||||
network->update();
|
network->update();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(200);
|
delay(200);
|
||||||
|
|||||||
Reference in New Issue
Block a user