Fixed MQTT byte mode

This commit is contained in:
Gunnar Skjold 2022-08-23 20:39:47 +02:00
parent a3c7a09211
commit f18171fecc

View File

@ -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;
}