Improve power stability when using MQTT (#1070)

* Changes to improve MQTT and power stability

* Re-added the memory leak fix

* Re-added the memory leak fix

* Stop client before deleting

* Fixed potential nullpointer
This commit is contained in:
Gunnar Skjold
2025-12-01 10:01:20 +01:00
committed by GitHub
parent c0c696a55c
commit 9252a810df
6 changed files with 29 additions and 18 deletions

View File

@@ -62,6 +62,11 @@ public:
virtual void onMessage(String &topic, String &payload) {};
virtual ~AmsMqttHandler() {
if(mqttSecureClient != NULL) {
mqttSecureClient->stop();
delete mqttSecureClient;
}
if(mqttClient != NULL) {
mqttClient->stop();
delete mqttClient;
@@ -81,6 +86,7 @@ protected:
bool caVerification = true;
WiFiClient *mqttClient = NULL;
WiFiClientSecure *mqttSecureClient = NULL;
boolean _connected = false;
char* json;
uint16_t BufferSize = 2048;
uint64_t lastStateUpdate = 0;