From 1ef7c8192fdbb6aacb4d4945fc7e69a6594bfca2 Mon Sep 17 00:00:00 2001 From: giedriuslt <123905703+giedriuslt@users.noreply.github.com> Date: Wed, 22 Jan 2025 14:51:23 +0200 Subject: [PATCH] publish energy mqtt data with qos zero (#1518) --- src/driver/drv_bl_shared.c | 2 +- src/mqtt/new_mqtt.c | 4 ++++ src/mqtt/new_mqtt.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/driver/drv_bl_shared.c b/src/driver/drv_bl_shared.c index 7a14083ff..cd83f70f8 100644 --- a/src/driver/drv_bl_shared.c +++ b/src/driver/drv_bl_shared.c @@ -716,7 +716,7 @@ void BL_ProcessUpdate(float voltage, float current, float power, } else { //all other sensors float val = sensors[i].lastReading; if (sensors[i].names.units == UNIT_WH) val = BL_ChangeEnergyUnitIfNeeded(val); - MQTT_PublishMain_StringFloat(sensors[i].names.name_mqtt, val, sensors[i].rounding_decimals, 0); + MQTT_PublishMain_StringFloat(sensors[i].names.name_mqtt, val, sensors[i].rounding_decimals, OBK_PUBLISH_FLAG_QOS_ZERO); } stat_updatesSent++; } diff --git a/src/mqtt/new_mqtt.c b/src/mqtt/new_mqtt.c index fe809a6a9..77fe53531 100644 --- a/src/mqtt/new_mqtt.c +++ b/src/mqtt/new_mqtt.c @@ -815,6 +815,10 @@ static OBK_Publish_Result MQTT_PublishTopicToClient(mqtt_client_t* client, const { err_t err; u8_t qos = 1; /* 0 1 or 2, see MQTT specification */ + if (flags & OBK_PUBLISH_FLAG_QOS_ZERO) + { + qos = 0; + } u8_t retain = 0; /* No don't retain such crappy payload... */ size_t sVal_len; char* pub_topic; diff --git a/src/mqtt/new_mqtt.h b/src/mqtt/new_mqtt.h index 0d4936744..b116c25c8 100644 --- a/src/mqtt/new_mqtt.h +++ b/src/mqtt/new_mqtt.h @@ -68,6 +68,7 @@ enum OBK_Publish_Result_e { #define OBK_PUBLISH_FLAG_FORCE_REMOVE_GET 4 // do not add anything to given topic #define OBK_PUBLISH_FLAG_RAW_TOPIC_NAME 8 +#define OBK_PUBLISH_FLAG_QOS_ZERO 16 #include "new_mqtt_deduper.h"