同步协议 V1.03:双主题发布对齐 + initialize 数据格式修正
vd960DBN:
- heartbeat/sensor/initialize 发布统一走 dld960/{sn}/dev
- dev_initialize_pub 补 model/hard_ver/soft_ver,删 extra_info.version
DBNMQTTool:
- 协议版本号更新至 V1.03
- 协议 Topic 树和模拟页增加 initialize 支持
This commit is contained in:
@@ -177,30 +177,32 @@ void mqtt_publish(char *topic, char *message, int req_qos)
|
||||
|
||||
void dev_initialize_pub(void)
|
||||
{
|
||||
char *mBuff = (char *)malloc(256);
|
||||
char *mBuff = (char *)malloc(512);
|
||||
if(mBuff == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
memset(mBuff, 0, 256);
|
||||
memset(mBuff, 0, 512);
|
||||
|
||||
// V1.03: 上线后发布 initialize,告知服务器设备信息
|
||||
// 格式: {msg_id, cmd:"initialize", ts, data:{dev_serial, extra_info:{code,csq,location,version}}}
|
||||
// 格式: {msg_id, cmd:"initialize", ts, data:{dev_serial, model, hard_ver, soft_ver, extra_info:{code,csq,location}}}
|
||||
uint32_t now = (mstick() > 0) ? (uint32_t)(mstick() / 1000) : 0;
|
||||
char topic[64];
|
||||
snprintf(topic, sizeof(topic), "dld960/%s/dev", g_dev_number_str);
|
||||
sprintf((char *)mBuff,
|
||||
"{\"msg_id\":%lu,\"cmd\":\"initialize\",\"ts\":%lu,"
|
||||
"\"data\":{\"dev_serial\":\"%s\","
|
||||
"\"data\":{\"dev_serial\":\"%s\",\"model\":\"%s\","
|
||||
"\"hard_ver\":\"%s\",\"soft_ver\":\"%s\","
|
||||
"\"extra_info\":{\"code\":\"%s\",\"csq\":\"%d\","
|
||||
"\"location\":\"%s\",\"version\":\"%s\"}}}",
|
||||
(unsigned long)++g_msg_id, (unsigned long)now,
|
||||
g_dev_number_str,
|
||||
"0", 0, "", FIRMWARE_VER);
|
||||
"\"location\":\"%s\"}}}",
|
||||
(unsigned long)++g_iot_msg_id, (unsigned long)now,
|
||||
g_dev_number_str, PRODUCT_MODEL,
|
||||
HARDWARE_VER, FIRMWARE_VER,
|
||||
"0", 0, "");
|
||||
|
||||
PRINT("
|
||||
\nWill publish initialize_topic:\n%s
|
||||
\n", mBuff);
|
||||
PRINT("\nWill publish initialize topic=%s:\n%s\n", topic, mBuff);
|
||||
|
||||
mqtt_publish((char *)(g_iot_topic.topic_pub), (char *)mBuff, 0);
|
||||
mqtt_publish(topic, (char *)mBuff, 0);
|
||||
|
||||
free(mBuff);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user