Continued implementation and changes after testing

This commit is contained in:
Gunnar Skjold
2026-03-26 14:16:27 +01:00
parent e91ef1a98c
commit ecd7017ac5
10 changed files with 637 additions and 531 deletions

View File

@@ -29,21 +29,16 @@ public:
#endif
this->config = config;
config->getMqttConfig(mqttConfig);
AmsMqttHandler(mqttConfig, debugger, buf, updater);
mqttConfigChanged = true;
init(debugger, buf, updater);
};
#if defined(AMS_REMOTE_DEBUG)
AmsMqttHandler(MqttConfig& MqttConfig, RemoteDebug* debugger, char* buf, AmsFirmwareUpdater* updater) {
#else
AmsMqttHandler(MqttConfig& MqttConfig, Stream* debugger, char* buf, AmsFirmwareUpdater* updater) {
#endif
this->debugger = debugger;
this->json = buf;
this->updater = updater;
mqtt.dropOverflow(true);
pubTopic = String(mqttConfig.publishTopic);
subTopic = String(mqttConfig.subscribeTopic);
if(subTopic.isEmpty()) subTopic = pubTopic+"/command";
this->mqttConfig = MqttConfig;
init(debugger, buf, updater);
}
void setCaVerification(bool);
@@ -88,16 +83,18 @@ protected:
#endif
AmsConfiguration* config;
MqttConfig mqttConfig;
bool mqttConfigChanged = false;
bool mqttConfigChanged = true;
#if defined(ESP32)
MQTTClient mqtt = MQTTClient(2048);
#else
MQTTClient mqtt = MQTTClient(256);
#endif
unsigned long lastMqttRetry = -10000;
bool caVerification = true;
WiFiClient *mqttClient = NULL;
WiFiClientSecure *mqttSecureClient = NULL;
boolean _connected = false;
char* json;
uint16_t BufferSize = 2048;
uint64_t lastStateUpdate = 0;
uint64_t lastSuccessfulLoop = 0;
@@ -106,6 +103,22 @@ protected:
AmsFirmwareUpdater* updater = NULL;
bool rebootSuggested = false;
private:
#if defined(AMS_REMOTE_DEBUG)
void init(RemoteDebug* debugger, char* buf, AmsFirmwareUpdater* updater) {
#else
void init(Stream* debugger, char* buf, AmsFirmwareUpdater* updater) {
#endif
this->debugger = debugger;
this->json = buf;
this->updater = updater;
mqtt.dropOverflow(true);
pubTopic = String(mqttConfig.publishTopic);
subTopic = String(mqttConfig.subscribeTopic);
if(subTopic.isEmpty()) subTopic = pubTopic+"/command";
}
};
#endif