diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/cfig_flash.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/cfig_flash.c index 71433b4..b51e291 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/cfig_flash.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/cfig_flash.c @@ -4,7 +4,7 @@ * @author wfq * @version V1.0 * @date 2025-02-07 -* @brief ?????????????????????????? +* @brief ??????????��?��??????????????? * @attention ****************************************************************************** */ @@ -89,11 +89,23 @@ void factory_dev_info(void) "password", 0 }; + + // 使用实际设备序列号生成默认 topic(V1.01 双主题协议) + char sn_str[13]; + sprintf(sn_str, "%02X%02X%02X%02X%02X%02X", + gMacAddr[0], gMacAddr[1], gMacAddr[2], + gMacAddr[3], gMacAddr[4], gMacAddr[5]); + char default_pub[64], default_sub[64]; + sprintf(default_pub, "dld960/%s/dev", sn_str); + sprintf(default_sub, "dld960/%s/srv", sn_str); + IOT_Topic _topic = { 0, - TOPIC_DEFAULT_PUBLISH, - TOPIC_DEFAULT_SUBSCRIBE + {0}, + {0} }; + strncpy((char *)_topic.topic_pub, default_pub, MAX_TOPIC_LENGTH - 1); + strncpy((char *)_topic.topic_sub, default_sub, MAX_TOPIC_LENGTH - 1); write_net_config(&lcfg, &ccfg, &icfg, &_topic); } diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/include/net_srv.h b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/include/net_srv.h index 2f038f3..d4e8f9c 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/include/net_srv.h +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/include/net_srv.h @@ -32,6 +32,8 @@ #define COM_LSSC_UDP_PORT 5500 #define COM_DEV_MESSAGE_PORT 4900 //udp dev local message port +// 默认 Topic 格式模板(V1.01 双主题) +// 实际出厂值时 factory_dev_info() 会用真实序列号替换 {sn} #define TOPIC_DEFAULT_SUBSCRIBE "dld960/{sn}/srv" #define TOPIC_DEFAULT_PUBLISH "dld960/{sn}/dev" diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/net_srv.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/net_srv.c index b5da4ad..8b5e9ee 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/net_srv.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/net_srv.c @@ -141,9 +141,7 @@ void dg_subscribe_display_topic(void) strcpy(mBuff, (char *)g_iot_topic.topic_sub); { - PRINT(" -\nWill subscribe display_topic:\n%s -\n", mBuff); + PRINT("\nWill subscribe display_topic:\n%s\n", mBuff); } MQTT_Subscribe(mBuff, 1); @@ -219,11 +217,6 @@ void dev_response_heartbeat(char *dat) void mqtt_deserialize_publish(char* topic, char* msg, int length) { -// if(g_flag_debug) -// { -// printf("display_mqtt_callback rev topic: %s\n msg:%s, len:%d -\n", topic, msg, length); -// } // V1.01: 使用配置的 topic_sub 匹配,而非硬编码默认值 if(strstr(topic, (char *)g_iot_topic.topic_sub) != NULL) {