Skip to content

Commit

Permalink
publish energy mqtt data with qos zero (#1518)
Browse files Browse the repository at this point in the history
  • Loading branch information
giedriuslt authored Jan 22, 2025
1 parent f209c00 commit 1ef7c81
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/driver/drv_bl_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
4 changes: 4 additions & 0 deletions src/mqtt/new_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/mqtt/new_mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1ef7c81

Please sign in to comment.