From f18171fecc85b483199bb4bcdfc7573cb4091c6a Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Tue, 23 Aug 2022 20:39:47 +0200 Subject: [PATCH] Fixed MQTT byte mode --- src/AmsToMqttBridge.ino | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index 77261984..a10be9ac 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -835,6 +835,7 @@ bool readHanPort() { len += hanSerial->readBytes(hanBuffer+len, BUF_SIZE_HAN-len); if(mqttEnabled && mqtt != NULL && mqttHandler == NULL) { mqtt->publish(topic.c_str(), toHex(hanBuffer+pos, len)); + mqtt->loop(); } while(hanSerial->available()) hanSerial->read(); // Make sure it is all empty, in case we overflowed buffer above len = 0; @@ -851,6 +852,7 @@ bool readHanPort() { // If MQTT bytestream payload is selected (mqttHandler == NULL), send the payload to MQTT if(mqttEnabled && mqtt != NULL && mqttHandler == NULL) { mqtt->publish(topic.c_str(), toHex(hanBuffer+pos, ctx.length)); + mqtt->loop(); } debugV("Using application data:"); @@ -1175,6 +1177,7 @@ int16_t unwrapData(uint8_t *buf, DataParserContext &context) { // If MQTT bytestream payload is selected (mqttHandler == NULL), send the payload to MQTT if(mqttEnabled && mqtt != NULL && mqttHandler == NULL) { mqtt->publish(topic.c_str(), toHex(buf, curLen)); + mqtt->loop(); } break; case DATA_TAG_MBUS: @@ -1182,6 +1185,7 @@ int16_t unwrapData(uint8_t *buf, DataParserContext &context) { // If MQTT bytestream payload is selected (mqttHandler == NULL), send the payload to MQTT if(mqttEnabled && mqtt != NULL && mqttHandler == NULL) { mqtt->publish(topic.c_str(), toHex(buf, curLen)); + mqtt->loop(); } break; case DATA_TAG_GBT: @@ -1200,6 +1204,7 @@ int16_t unwrapData(uint8_t *buf, DataParserContext &context) { debugV("DSMR frame:"); if(mqttEnabled && mqtt != NULL && mqttHandler == NULL) { mqtt->publish(topic.c_str(), (char*) buf); + mqtt->loop(); } break; }