fixes for OTA
This commit is contained in:
@@ -130,13 +130,15 @@ ReconnectStatus EthLan8720Device::reconnect()
|
||||
|
||||
void EthLan8720Device::update()
|
||||
{
|
||||
if(_useEncryption)
|
||||
if(_mqttEnabled)
|
||||
{
|
||||
_mqttClientSecure->loop();
|
||||
}
|
||||
else
|
||||
{
|
||||
_mqttClient->loop();
|
||||
if (_useEncryption)
|
||||
{
|
||||
_mqttClientSecure->loop();
|
||||
} else
|
||||
{
|
||||
_mqttClient->loop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,3 +312,16 @@ uint16_t EthLan8720Device::mqttSubscribe(const char *topic, uint8_t 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;
|
||||
|
||||
void disableMqtt() override;
|
||||
|
||||
private:
|
||||
void onDisconnected();
|
||||
|
||||
@@ -83,6 +85,7 @@ private:
|
||||
eth_phy_type_t _type;
|
||||
eth_clock_mode_t _clock_mode;
|
||||
bool _use_mac_from_efuse;
|
||||
bool _mqttEnabled = true;
|
||||
|
||||
char _ca[TLS_CA_MAX_SIZE] = {0};
|
||||
char _cert[TLS_CERT_MAX_SIZE] = {0};
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
virtual void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback) = 0;
|
||||
virtual void mqttOnConnect(espMqttClientTypes::OnConnectCallback callback) = 0;
|
||||
virtual void mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback) = 0;
|
||||
virtual void disableMqtt() = 0;
|
||||
|
||||
virtual uint16_t mqttSubscribe(const char* topic, uint8_t qos) = 0;
|
||||
|
||||
|
||||
@@ -207,7 +207,10 @@ void W5500Device::initializeMacAddress(byte *mac)
|
||||
void W5500Device::update()
|
||||
{
|
||||
_maintainResult = Ethernet.maintain();
|
||||
_mqttClient.loop();
|
||||
if(_mqttEnabled)
|
||||
{
|
||||
_mqttClient.loop();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void W5500Device::disableMqtt()
|
||||
{
|
||||
_mqttClient.disconnect();
|
||||
_mqttEnabled = false;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
|
||||
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
|
||||
|
||||
void disableMqtt() override;
|
||||
|
||||
private:
|
||||
void resetDevice();
|
||||
void initializeMacAddress(byte* mac);
|
||||
@@ -72,6 +74,7 @@ private:
|
||||
char* _path;
|
||||
W5500Variant _variant;
|
||||
bool _lastConnected = false;
|
||||
bool _mqttEnabled = true;
|
||||
|
||||
byte _mac[6];
|
||||
};
|
||||
@@ -142,13 +142,15 @@ ReconnectStatus WifiDevice::reconnect()
|
||||
|
||||
void WifiDevice::update()
|
||||
{
|
||||
if(_useEncryption)
|
||||
if(_mqttEnabled)
|
||||
{
|
||||
_mqttClientSecure->loop();
|
||||
}
|
||||
else
|
||||
{
|
||||
_mqttClient->loop();
|
||||
if (_useEncryption)
|
||||
{
|
||||
_mqttClientSecure->loop();
|
||||
} else
|
||||
{
|
||||
_mqttClient->loop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,3 +329,16 @@ uint16_t WifiDevice::mqttSubscribe(const char *topic, uint8_t 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;
|
||||
|
||||
void disableMqtt() override;
|
||||
|
||||
private:
|
||||
static void clearRtcInitVar(WiFiManager*);
|
||||
|
||||
@@ -65,6 +67,7 @@ private:
|
||||
bool _startAp = false;
|
||||
char* _path;
|
||||
bool _useEncryption = false;
|
||||
bool _mqttEnabled = true;
|
||||
|
||||
char _ca[TLS_CA_MAX_SIZE] = {0};
|
||||
char _cert[TLS_CERT_MAX_SIZE] = {0};
|
||||
|
||||
Reference in New Issue
Block a user