fixes for OTA
This commit is contained in:
2
Config.h
2
Config.h
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define NUKI_HUB_VERSION "8.14"
|
#define NUKI_HUB_VERSION "8.15"
|
||||||
|
|
||||||
#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
@@ -196,6 +196,11 @@ bool Network::update()
|
|||||||
|
|
||||||
_device->update();
|
_device->update();
|
||||||
|
|
||||||
|
if(!_mqttEnabled)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(!_device->isConnected())
|
if(!_device->isConnected())
|
||||||
{
|
{
|
||||||
if(_restartOnDisconnect && millis() > 60000)
|
if(_restartOnDisconnect && millis() > 60000)
|
||||||
@@ -1073,3 +1078,9 @@ void Network::clearWifiFallback()
|
|||||||
{
|
{
|
||||||
memset(WiFi_fallbackDetect, 0, sizeof(WiFi_fallbackDetect));
|
memset(WiFi_fallbackDetect, 0, sizeof(WiFi_fallbackDetect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Network::disableMqtt()
|
||||||
|
{
|
||||||
|
_device->disableMqtt();
|
||||||
|
_mqttEnabled = false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
void reconfigureDevice();
|
void reconfigureDevice();
|
||||||
void setMqttPresencePath(char* path);
|
void setMqttPresencePath(char* path);
|
||||||
void disableAutoRestarts(); // disable on OTA start
|
void disableAutoRestarts(); // disable on OTA start
|
||||||
|
void disableMqtt();
|
||||||
|
|
||||||
void subscribe(const char* prefix, const char* path);
|
void subscribe(const char* prefix, const char* path);
|
||||||
void initTopic(const char* prefix, const char* path, const char* value);
|
void initTopic(const char* prefix, const char* path, const char* value);
|
||||||
@@ -115,6 +116,7 @@ private:
|
|||||||
unsigned long _lastConnectedTs = 0;
|
unsigned long _lastConnectedTs = 0;
|
||||||
unsigned long _lastMaintenanceTs = 0;
|
unsigned long _lastMaintenanceTs = 0;
|
||||||
unsigned long _lastRssiTs = 0;
|
unsigned long _lastRssiTs = 0;
|
||||||
|
bool _mqttEnabled = true;
|
||||||
static unsigned long _ignoreSubscriptionsTs;
|
static unsigned long _ignoreSubscriptionsTs;
|
||||||
long _rssiPublishInterval = 0;
|
long _rssiPublishInterval = 0;
|
||||||
std::function<void()> _keepAliveCallback = nullptr;
|
std::function<void()> _keepAliveCallback = nullptr;
|
||||||
|
|||||||
@@ -681,3 +681,8 @@ std::string NukiOpenerWrapper::hardwareVersion() const
|
|||||||
{
|
{
|
||||||
return _hardwareVersion;
|
return _hardwareVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NukiOpenerWrapper::disableWatchdog()
|
||||||
|
{
|
||||||
|
_restartBeaconTimeout = -1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ public:
|
|||||||
|
|
||||||
void disableHASS();
|
void disableHASS();
|
||||||
|
|
||||||
|
void disableWatchdog();
|
||||||
|
|
||||||
const NukiOpener::OpenerState& keyTurnerState();
|
const NukiOpener::OpenerState& keyTurnerState();
|
||||||
const bool isPaired();
|
const bool isPaired();
|
||||||
const bool hasKeypad();
|
const bool hasKeypad();
|
||||||
|
|||||||
@@ -709,3 +709,8 @@ std::string NukiWrapper::hardwareVersion() const
|
|||||||
{
|
{
|
||||||
return _hardwareVersion;
|
return _hardwareVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NukiWrapper::disableWatchdog()
|
||||||
|
{
|
||||||
|
_restartBeaconTimeout = -1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ public:
|
|||||||
|
|
||||||
void disableHASS();
|
void disableHASS();
|
||||||
|
|
||||||
|
void disableWatchdog();
|
||||||
|
|
||||||
const NukiLock::KeyTurnerState& keyTurnerState();
|
const NukiLock::KeyTurnerState& keyTurnerState();
|
||||||
const bool isPaired();
|
const bool isPaired();
|
||||||
const bool hasKeypad();
|
const bool hasKeypad();
|
||||||
|
|||||||
@@ -1071,6 +1071,15 @@ void WebCfgServer::handleOtaUpload()
|
|||||||
_otaStartTs = millis();
|
_otaStartTs = millis();
|
||||||
esp_task_wdt_init(30, false);
|
esp_task_wdt_init(30, false);
|
||||||
_network->disableAutoRestarts();
|
_network->disableAutoRestarts();
|
||||||
|
_network->disableMqtt();
|
||||||
|
if(_nuki != nullptr)
|
||||||
|
{
|
||||||
|
_nuki->disableWatchdog();
|
||||||
|
}
|
||||||
|
if(_nukiOpener != nullptr)
|
||||||
|
{
|
||||||
|
_nukiOpener->disableWatchdog();
|
||||||
|
}
|
||||||
Log->print("handleFileUpload Name: "); Log->println(filename);
|
Log->print("handleFileUpload Name: "); Log->println(filename);
|
||||||
}
|
}
|
||||||
else if (upload.status == UPLOAD_FILE_WRITE)
|
else if (upload.status == UPLOAD_FILE_WRITE)
|
||||||
|
|||||||
@@ -130,13 +130,15 @@ ReconnectStatus EthLan8720Device::reconnect()
|
|||||||
|
|
||||||
void EthLan8720Device::update()
|
void EthLan8720Device::update()
|
||||||
{
|
{
|
||||||
if(_useEncryption)
|
if(_mqttEnabled)
|
||||||
{
|
{
|
||||||
_mqttClientSecure->loop();
|
if (_useEncryption)
|
||||||
}
|
{
|
||||||
else
|
_mqttClientSecure->loop();
|
||||||
{
|
} else
|
||||||
_mqttClient->loop();
|
{
|
||||||
|
_mqttClient->loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,3 +312,16 @@ uint16_t EthLan8720Device::mqttSubscribe(const char *topic, uint8_t qos)
|
|||||||
return _mqttClient->subscribe(topic, qos);
|
return _mqttClient->subscribe(topic, qos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EthLan8720Device::disableMqtt()
|
||||||
|
{
|
||||||
|
if (_useEncryption)
|
||||||
|
{
|
||||||
|
_mqttClientSecure->disconnect();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
_mqttClient->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
_mqttEnabled = false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public:
|
|||||||
|
|
||||||
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
|
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
|
||||||
|
|
||||||
|
void disableMqtt() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onDisconnected();
|
void onDisconnected();
|
||||||
|
|
||||||
@@ -83,6 +85,7 @@ private:
|
|||||||
eth_phy_type_t _type;
|
eth_phy_type_t _type;
|
||||||
eth_clock_mode_t _clock_mode;
|
eth_clock_mode_t _clock_mode;
|
||||||
bool _use_mac_from_efuse;
|
bool _use_mac_from_efuse;
|
||||||
|
bool _mqttEnabled = true;
|
||||||
|
|
||||||
char _ca[TLS_CA_MAX_SIZE] = {0};
|
char _ca[TLS_CA_MAX_SIZE] = {0};
|
||||||
char _cert[TLS_CERT_MAX_SIZE] = {0};
|
char _cert[TLS_CERT_MAX_SIZE] = {0};
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
virtual void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback) = 0;
|
virtual void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback) = 0;
|
||||||
virtual void mqttOnConnect(espMqttClientTypes::OnConnectCallback callback) = 0;
|
virtual void mqttOnConnect(espMqttClientTypes::OnConnectCallback callback) = 0;
|
||||||
virtual void mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback) = 0;
|
virtual void mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback) = 0;
|
||||||
|
virtual void disableMqtt() = 0;
|
||||||
|
|
||||||
virtual uint16_t mqttSubscribe(const char* topic, uint8_t qos) = 0;
|
virtual uint16_t mqttSubscribe(const char* topic, uint8_t qos) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,10 @@ void W5500Device::initializeMacAddress(byte *mac)
|
|||||||
void W5500Device::update()
|
void W5500Device::update()
|
||||||
{
|
{
|
||||||
_maintainResult = Ethernet.maintain();
|
_maintainResult = Ethernet.maintain();
|
||||||
_mqttClient.loop();
|
if(_mqttEnabled)
|
||||||
|
{
|
||||||
|
_mqttClient.loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t W5500Device::signalStrength()
|
int8_t W5500Device::signalStrength()
|
||||||
@@ -279,3 +282,9 @@ uint16_t W5500Device::mqttPublish(const char *topic, uint8_t qos, bool retain, c
|
|||||||
{
|
{
|
||||||
return _mqttClient.publish(topic, qos, retain, payload, length);
|
return _mqttClient.publish(topic, qos, retain, payload, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void W5500Device::disableMqtt()
|
||||||
|
{
|
||||||
|
_mqttClient.disconnect();
|
||||||
|
_mqttEnabled = false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ public:
|
|||||||
|
|
||||||
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
|
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
|
||||||
|
|
||||||
|
void disableMqtt() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetDevice();
|
void resetDevice();
|
||||||
void initializeMacAddress(byte* mac);
|
void initializeMacAddress(byte* mac);
|
||||||
@@ -72,6 +74,7 @@ private:
|
|||||||
char* _path;
|
char* _path;
|
||||||
W5500Variant _variant;
|
W5500Variant _variant;
|
||||||
bool _lastConnected = false;
|
bool _lastConnected = false;
|
||||||
|
bool _mqttEnabled = true;
|
||||||
|
|
||||||
byte _mac[6];
|
byte _mac[6];
|
||||||
};
|
};
|
||||||
@@ -142,13 +142,15 @@ ReconnectStatus WifiDevice::reconnect()
|
|||||||
|
|
||||||
void WifiDevice::update()
|
void WifiDevice::update()
|
||||||
{
|
{
|
||||||
if(_useEncryption)
|
if(_mqttEnabled)
|
||||||
{
|
{
|
||||||
_mqttClientSecure->loop();
|
if (_useEncryption)
|
||||||
}
|
{
|
||||||
else
|
_mqttClientSecure->loop();
|
||||||
{
|
} else
|
||||||
_mqttClient->loop();
|
{
|
||||||
|
_mqttClient->loop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,3 +329,16 @@ uint16_t WifiDevice::mqttSubscribe(const char *topic, uint8_t qos)
|
|||||||
return _mqttClient->subscribe(topic, qos);
|
return _mqttClient->subscribe(topic, qos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WifiDevice::disableMqtt()
|
||||||
|
{
|
||||||
|
if (_useEncryption)
|
||||||
|
{
|
||||||
|
_mqttClientSecure->disconnect();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
_mqttClient->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
_mqttEnabled = false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ public:
|
|||||||
|
|
||||||
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
|
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
|
||||||
|
|
||||||
|
void disableMqtt() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void clearRtcInitVar(WiFiManager*);
|
static void clearRtcInitVar(WiFiManager*);
|
||||||
|
|
||||||
@@ -65,6 +67,7 @@ private:
|
|||||||
bool _startAp = false;
|
bool _startAp = false;
|
||||||
char* _path;
|
char* _path;
|
||||||
bool _useEncryption = false;
|
bool _useEncryption = false;
|
||||||
|
bool _mqttEnabled = true;
|
||||||
|
|
||||||
char _ca[TLS_CA_MAX_SIZE] = {0};
|
char _ca[TLS_CA_MAX_SIZE] = {0};
|
||||||
char _cert[TLS_CERT_MAX_SIZE] = {0};
|
char _cert[TLS_CERT_MAX_SIZE] = {0};
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user