diff --git a/app/scanner2/mqtt.cpp b/app/scanner2/mqtt.cpp index 96634821..ebf41933 100644 --- a/app/scanner2/mqtt.cpp +++ b/app/scanner2/mqtt.cpp @@ -111,16 +111,18 @@ bool mqtt_publish(const char *title, const char *info, bool will_set) bool mqtt_pulish_online() { + std::string productId = getCfgValue("mqtt", "productId", QString("GSYJ-BZ")).toStdString(); std::string deviceId = getCfgValue("mqtt", "deviceId", QString("testID")).toStdString(); - std::string title = "/GSYJ-BZ/" + deviceId + "/online"; + std::string title = "/" + productId + "/" + deviceId + "/online"; std::string info = "{\"deviceId\": \"" + deviceId + "\"}"; return mqtt_publish(title.c_str(), info.c_str(), false); } bool mqtt_pulish_offline() { + std::string productId = getCfgValue("mqtt", "productId", QString("GSYJ-BZ")).toStdString(); std::string deviceId = getCfgValue("mqtt", "deviceId", QString("testID")).toStdString(); - std::string title = "/GSYJ-BZ/" + deviceId + "/offline"; + std::string title = "/" + productId + "/" + deviceId + "/offline"; std::string info = "{\"deviceId\": \"" + deviceId + "\"}"; return mqtt_publish(title.c_str(), info.c_str(), true); } @@ -128,8 +130,9 @@ bool mqtt_pulish_offline() bool mqtt_publish_device_properties(const char *ip, const char *sysVerion, const char *deviceModel, const char *companyCode) { + std::string productId = getCfgValue("mqtt", "productId", QString("GSYJ-BZ")).toStdString(); std::string deviceId = getCfgValue("mqtt", "deviceId", QString("testID")).toStdString(); - std::string title = "/GSYJ-BZ/" + deviceId + "/properties/report"; + std::string title = "/" + productId + "/" + deviceId + "/properties/report"; std::string info = "{\"deviceId\": \"" + deviceId + "\", \"properties\": {\"ip\": \"" + ip + "\", \"sysVersion\": \"" + sysVerion + "\", \"deviceModel\": \"" + deviceModel + "\", \"companyCode\": \"" + companyCode + "\"}}"; return mqtt_publish(title.c_str(), info.c_str(), false);