|
|
|
@ -355,7 +355,12 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (dev->is_connected())
|
|
|
|
if (dev->is_connected())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string payload = "{\"value\": " + std::to_string(info.Value()) + "}";
|
|
|
|
float weight_value = info.Value();
|
|
|
|
|
|
|
|
if (std::isinf(weight_value) || std::isnan(weight_value))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
weight_value = 0.0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string payload = "{\"value\": " + std::to_string(weight_value) + "}";
|
|
|
|
auto mqtt_msg = mqtt::make_message("pound/" + std::string(mqtt_topic_id) + "/scale/weight", payload);
|
|
|
|
auto mqtt_msg = mqtt::make_message("pound/" + std::string(mqtt_topic_id) + "/scale/weight", payload);
|
|
|
|
mqtt_msg->set_qos(0);
|
|
|
|
mqtt_msg->set_qos(0);
|
|
|
|
mqtt_msg->set_retained(true);
|
|
|
|
mqtt_msg->set_retained(true);
|
|
|
|
|