From 034ca92937e8f2d424912f93ded6f43b69016b47 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 29 Dec 2021 13:20:07 -0500 Subject: [PATCH] Make zm_mqtt compile --- src/zm_mqtt.cpp | 27 +++++++++++++-------------- src/zm_mqtt.h | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/zm_mqtt.cpp b/src/zm_mqtt.cpp index 0904e8207..50e4d4f55 100644 --- a/src/zm_mqtt.cpp +++ b/src/zm_mqtt.cpp @@ -1,6 +1,7 @@ #include "zm.h" #include "zm_logger.h" #include "zm_mqtt.h" +#include "zm_monitor.h" #include "zm_time.h" #include @@ -49,15 +50,13 @@ void MQTT::send() { int mid; std::stringstream mqtt_topic; std::stringstream mqtt_payload; - mqtt_topic << "/a/"; - mqtt_topic << api_key; - mqtt_topic << "/p/"; - mqtt_topic << project_id; - mqtt_topic << "/device/" << device_id; - mqtt_topic << "/sensor/" << outer_iter->first; + //mqtt_topic << "/a/"; + mqtt_topic << "/" << MQTT_TOPIC_PREFIX; + mqtt_topic << "/monitor/" << monitor_->Id(); + //mqtt_topic << "/sensor/" << outer_iter->first; mqtt_topic << "/data"; - mqtt_payload << "{ \"value\":"<second<<" }"; + //mqtt_payload << "{ \"value\":"<second<<" }"; const std::string mqtt_topic_string = mqtt_topic.str(); const std::string mqtt_payload_string = mqtt_payload.str(); @@ -84,13 +83,13 @@ void MQTT::addActuator(std::string name, std::function f) { int mid; std::stringstream mqtt_topic; - mqtt_topic << "/a/"; - mqtt_topic << api_key; - mqtt_topic << "/p/"; - mqtt_topic << project_id; - mqtt_topic << "/device/" << device_id; - mqtt_topic << "/actuator/" << name; - mqtt_topic << "/state"; + //mqtt_topic << "/a/"; + //mqtt_topic << api_key; + //mqtt_topic << "/p/"; + //mqtt_topic << project_id; + //mqtt_topic << "/device/" << device_id; + //mqtt_topic << "/actuator/" << name; + //mqtt_topic << "/state"; subscribe(&mid, mqtt_topic.str().c_str()); } diff --git a/src/zm_mqtt.h b/src/zm_mqtt.h index 45bf5f6cc..6da3c6031 100644 --- a/src/zm_mqtt.h +++ b/src/zm_mqtt.h @@ -39,7 +39,7 @@ class MQTT : public mosqpp::mosquittopp { std::map>::iterator sensorListIterator; std::map actuatorList; - Monitor *monitor; + Monitor *monitor_; bool connected_; };