feat: MQTT 双主题同步到 vd960DBN 固件 + DBNMQTTool devlog

vd960DBN 固件改动:
- net_srv.h: 默认 topic 改为 dld960/{sn}/srv + dld960/{sn}/dev
- net_srv.c: dg_subscribe_display_topic() 直接用 topic_sub 订阅(不再追加 client_id/sn 后缀)
- net_srv.c: mqtt_deserialize_publish() topic 过滤改用 g_iot_topic.topic_sub(不再硬编码 TOPIC_DEFAULT_SUBSCRIBE)

DBNMQTTool 文档:
- devlog.md: 清理过期 topic 引用语义
This commit is contained in:
wangfq
2026-07-07 09:46:54 +08:00
parent 770d67346f
commit b707241429
4 changed files with 17 additions and 15 deletions
+4
View File
@@ -85,3 +85,7 @@ at32_ide_proj/
wchreference/
# Python
__pycache__/
*.pyc
+2 -2
View File
@@ -17,7 +17,7 @@
### 2. 协议Topic Tab
- 预加载 `dld960/{sn}/srv/...` 订阅主题 和 `dev/...` 设备发起主题
- 预加载双主题:`dld960/{sn}/srv`(下发)、`dld960/{sn}/dev`(上报)
- QListWidget 展示,双击自动填充到发布区
- 发布区可编辑 JSON 载荷,一键发布
- 主题列表受 SN 输入框驱动,实时更新
@@ -74,7 +74,7 @@ paho-mqtt v2 默认 `callback_api_version=VERSION2``on_disconnect` 回调签
### 功能 (初始版本, tkinter)
- MQTT Broker 连接管理
- 设备自动发现 (`dld960/+/dev/#` 通配符订阅)
- 设备自动发现 (`dld960/+/dev` 通配符订阅)
- 设备信息查询 + 主题配置
- 实时线圈数据 / 事件上报 / 心跳 监控
- 控制命令: 密码验证/设置、出厂初始化、设备复位
@@ -32,8 +32,8 @@
#define COM_LSSC_UDP_PORT 5500
#define COM_DEV_MESSAGE_PORT 4900 //udp dev local message port
#define TOPIC_DEFAULT_SUBSCRIBE "ptpc/display"
#define TOPIC_DEFAULT_PUBLISH "gtpc/display/Initialize"
#define TOPIC_DEFAULT_SUBSCRIBE "dld960/{sn}/srv"
#define TOPIC_DEFAULT_PUBLISH "dld960/{sn}/dev"
#define UART_BAUD_DEFAULT_PORT_1 115200 // Loop MCU ͨŵIJ TTL, g_storage_uart_baud_1
#define UART_BAUD_DEFAULT_PORT_2 115200 // baud2 TTL g_storage_uart_baud_2
@@ -137,17 +137,13 @@ void dg_subscribe_display_topic(void)
}
memset(mBuff, 0, 256);
if(g_iot_topic.clientid_enable)
{
sprintf(mBuff, "%s/%s", g_iot_topic.topic_sub, iot_net_info.client_id);
}
else
{
sprintf(mBuff, "%s/%s", g_iot_topic.topic_sub, g_dev_number_str);
}
// V1.01: 双主题协议 — topic_sub 即为完整订阅主题,不再追加后缀
strcpy(mBuff, (char *)g_iot_topic.topic_sub);
{
PRINT("\r\nWill subscribe display_topic:\n%s\r\n", mBuff);
PRINT("
\nWill subscribe display_topic:\n%s
\n", mBuff);
}
MQTT_Subscribe(mBuff, 1);
@@ -225,9 +221,11 @@ 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\r\n", topic, msg, length);
// printf("display_mqtt_callback rev topic: %s\n msg:%s, len:%d
\n", topic, msg, length);
// }
if(strstr(topic, (char *)TOPIC_DEFAULT_SUBSCRIBE) != NULL) //
// V1.01: 使用配置的 topic_sub 匹配,而非硬编码默认值
if(strstr(topic, (char *)g_iot_topic.topic_sub) != NULL)
{
manage_mqtt_recv_message(msg, length);
}