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