北京星立方云软件,将productId改为可配置

This commit is contained in:
luoliangyi 2024-02-01 10:23:23 +08:00
parent a9e444d7ec
commit c9a9e37beb
1 changed files with 6 additions and 3 deletions

View File

@ -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);