feat(vd960DBN)+fix(DBNMQTTool): MQTT 查询命令补齐 + 工具命令集对齐 (2026-08-18)

固件 (V4.2):
- iot_mqtt_srv.c 补齐 ssc_net_query / iot_net_query / iot_topic_query (只读全局组包, 与 TCP JSON §4.5/4.7/4.9 对齐)
- 修复实测: MQTT 通道 ssc_net_query/iot_net_query 返回 code=4 unsupported

工具:
- 禁用固件未实现的 6 个按钮 (ssc/iot_net/iot_topic_set + pwd_set/factory_reset/device_reset) + tooltip 引导 TCP/BLE
- 设备刷新列表移除 loop_param_query (固件未实现)
- offscreen 验证按钮状态正确
This commit is contained in:
wangfq
2026-08-18 11:44:52 +08:00
parent d39ab5ae89
commit f2141976f0
4 changed files with 295 additions and 189 deletions
+18
View File
@@ -6,6 +6,24 @@
---
## 2026-08-18 — 命令集对齐:禁用固件未实现的 MQTT 命令按钮
### 背景
实测发现 MQTT 通道 `ssc_net_query` / `iot_net_query` 返回 `code=4 unsupported command`——固件 MQTT 分发只实现 6 条命令,工具按协议文档命令表做了全按钮。
### 变更
- **固件同步补齐**vd960DBN V4.2):`ssc_net_query` / `iot_net_query` / `iot_topic_query` 三条查询命令已实现,工具对应查询按钮保持可用
- **工具禁用**固件仍未实现的命令按钮:`ssc_net_set` / `iot_net_set` / `iot_topic_set` / `pwd_set` / `factory_reset` / `device_reset``setEnabled(False)` + tooltip 引导走 TCP JSON/BLE 通道)
- 设备刷新列表移除 `CMD_LOOP_PARAM_QUERY`(固件未实现,刷新时不再报 error)
### 验证
- offscreen 实例化:6 个按钮禁用 + tooltip 正确,查询类/验证密码/report_config/log_* 可用
---
## 2026-08-18 — 脱机日志支持快照流 (stream=snapshot, 协议 V1.07)
### 变更
+10 -1
View File
@@ -196,6 +196,8 @@ class MainWindow(QMainWindow):
b1.clicked.connect(self._query_ssc_net)
b2 = QPushButton("设置")
b2.clicked.connect(self._set_ssc_net)
b2.setEnabled(False)
b2.setToolTip("MQTT 固件暂未实现 ssc_net_set,请用 TCP JSON 或蓝牙通道配置")
btn_row.addWidget(b1)
btn_row.addWidget(b2)
btn_row.addStretch()
@@ -224,6 +226,8 @@ class MainWindow(QMainWindow):
b3.clicked.connect(self._query_iot_net)
b4 = QPushButton("设置")
b4.clicked.connect(self._set_iot_net)
b4.setEnabled(False)
b4.setToolTip("MQTT 固件暂未实现 iot_net_set,请用 TCP JSON 或蓝牙通道配置")
btn_row2.addWidget(b3)
btn_row2.addWidget(b4)
btn_row2.addStretch()
@@ -251,6 +255,8 @@ class MainWindow(QMainWindow):
b5.clicked.connect(self._query_iot_topic)
b6 = QPushButton("设置")
b6.clicked.connect(self._set_iot_topic)
b6.setEnabled(False)
b6.setToolTip("MQTT 固件暂未实现 iot_topic_set,请用 TCP JSON 或蓝牙通道配置")
btn_row3.addWidget(b5)
btn_row3.addWidget(b6)
btn_row3.addStretch()
@@ -278,6 +284,9 @@ class MainWindow(QMainWindow):
]:
btn = QPushButton(label)
btn.clicked.connect(slot)
if label != "验证密码":
btn.setEnabled(False)
btn.setToolTip(f"MQTT 固件暂未实现 {label},请用 TCP JSON 或蓝牙通道")
btn_row4.addWidget(btn)
btn_row4.addStretch()
g4_layout.addLayout(btn_row4, 1, 0, 1, 4)
@@ -1018,7 +1027,7 @@ class MainWindow(QMainWindow):
if not sn:
return
for cmd in [CMD_DEV_INFO_QUERY, CMD_SSC_NET_QUERY, CMD_IOT_NET_QUERY,
CMD_IOT_TOPIC_QUERY, CMD_LOOP_PARAM_QUERY]:
CMD_IOT_TOPIC_QUERY]:
try:
self._mqtt.send_command(sn, cmd)
except Exception:
@@ -671,6 +671,56 @@ static void iot_handle_publish(const char *topic, uint8_t *payload, int payload_
msg_id, dev_time_now());
iot_mqtt_publish(resp_topic, resp, strlen(resp), 1);
} else if (strcmp(cmd_str, "ssc_net_query") == 0) {
/* SSC 网络配置查询 (只读全局, 协议 V1.02) */
char resp[400];
snprintf(resp, sizeof(resp),
"{\"msg_id\":%lu,\"cmd\":\"ssc_net_query\","
"\"ts\":%lu,\"code\":0,\"msg\":\"success\","
"\"data\":{\"dev_ip\":\"%d.%d.%d.%d\",\"subnet_mask\":\"%d.%d.%d.%d\","
"\"route_ip\":\"%d.%d.%d.%d\",\"lssc_ip\":\"%d.%d.%d.%d\","
"\"dns\":\"%d.%d.%d.%d\",\"port\":%d}}",
msg_id, dev_time_now(),
local_net_cfg.lip[0], local_net_cfg.lip[1], local_net_cfg.lip[2], local_net_cfg.lip[3],
local_net_cfg.sub[0], local_net_cfg.sub[1], local_net_cfg.sub[2], local_net_cfg.sub[3],
local_net_cfg.gw[0], local_net_cfg.gw[1], local_net_cfg.gw[2], local_net_cfg.gw[3],
net_center_info.lssc_ip[0], net_center_info.lssc_ip[1],
net_center_info.lssc_ip[2], net_center_info.lssc_ip[3],
local_net_cfg.dns[0], local_net_cfg.dns[1], local_net_cfg.dns[2], local_net_cfg.dns[3],
net_center_info.tcp_port);
iot_mqtt_publish(resp_topic, resp, strlen(resp), 1);
PRINT("IOT: ssc_net_query dev_ip=%d.%d.%d.%d\n",
local_net_cfg.lip[0], local_net_cfg.lip[1], local_net_cfg.lip[2], local_net_cfg.lip[3]);
} else if (strcmp(cmd_str, "iot_net_query") == 0) {
/* IoT 网络配置查询 (只读全局) */
char resp[400];
snprintf(resp, sizeof(resp),
"{\"msg_id\":%lu,\"cmd\":\"iot_net_query\","
"\"ts\":%lu,\"code\":0,\"msg\":\"success\","
"\"data\":{\"host\":\"%s\",\"port\":%d,\"client_id\":\"%s\","
"\"username\":\"%s\",\"password\":\"%s\"}}",
msg_id, dev_time_now(),
iot_net_info.remote_addr, iot_net_info.mqtt_port,
iot_net_info.client_id, iot_net_info.username, iot_net_info.password);
iot_mqtt_publish(resp_topic, resp, strlen(resp), 1);
PRINT("IOT: iot_net_query host=%s port=%d\n",
iot_net_info.remote_addr, iot_net_info.mqtt_port);
} else if (strcmp(cmd_str, "iot_topic_query") == 0) {
/* IoT Topic 配置查询 (只读全局) */
char resp[300];
snprintf(resp, sizeof(resp),
"{\"msg_id\":%lu,\"cmd\":\"iot_topic_query\","
"\"ts\":%lu,\"code\":0,\"msg\":\"success\","
"\"data\":{\"client_id_enable\":%s,\"topic_pub\":\"%s\",\"topic_sub\":\"%s\"}}",
msg_id, dev_time_now(),
g_iot_topic.clientid_enable ? "true" : "false",
g_iot_topic.topic_pub, g_iot_topic.topic_sub);
iot_mqtt_publish(resp_topic, resp, strlen(resp), 1);
PRINT("IOT: iot_topic_query pub=%s sub=%s\n",
g_iot_topic.topic_pub, g_iot_topic.topic_sub);
} else {
// 暂不支持的命令, 返回错误
char resp[256];
+29
View File
@@ -4,6 +4,34 @@
>
> 项目定位: DLD960 通信板 — BLE 配网、TCP JSON 协议服务、Loop MCU 串口桥接
## 2026-08-18 — MQTT 命令集补齐:ssc_net_query / iot_net_query / iot_topic_query
### 背景
DBNMQTTool 实测发现 MQTT 通道 `ssc_net_query` / `iot_net_query` 返回 `code=4 unsupported command`。根因:MQTT 协议文档命令表声明 14 条 srv→dev 命令,固件 `manage_mqtt_recv_message` 只实现 6 条(dev_info_query / report_config / pwd_verify / event_report ACK / log_*),注释即"目前仅实现基本响应框架"。查询类命令缺口本次补齐。
### 变更
| 命令 | 数据源 | 说明 |
|------|--------|------|
| `ssc_net_query` | `local_net_cfg` + `net_center_info` | dev_ip/subnet_mask/route_ip/lssc_ip/dns/port 组包,与 TCP JSON §4.5 一致 |
| `iot_net_query` | `iot_net_info` | host/port/client_id/username/password,与 TCP JSON §4.7 一致 |
| `iot_topic_query` | `g_iot_topic` | client_id_enable/topic_pub/topic_sub,与 TCP JSON §4.9 一致 |
三条均为**只读全局变量组包**,低风险;插入点:log_clear 分支后、unsupported else 前。
### 仍未实现(协议声明但固件缺,工具已禁用对应按钮)
`ssc_net_set` / `iot_net_set` / `iot_topic_set` / `pwd_set` / `factory_reset` / `device_reset` / `dev_serial_set` / `loop_param_query` / `loop_param_set`——设置类涉及写 Flash/设备重启,loop_param 需 UART 透传异步机制,留待后续(工具侧已禁用按钮 + tooltip 引导走 TCP/BLE)。
### 验证
- check_c_balance OK;全局变量可见性确认(net_srv.h extern
- DBNMQTTool offscreen6 个未实现按钮禁用 + tooltip,查询类可用
- 待板级:MRS 编译 + 真机 MQTT `ssc_net_query` / `iot_net_query` / `iot_topic_query`
---
## 2026-08-18 — TCP/MQTT 脱机日志快照流支持(协议 V1.03/V1.07 落地)
### 背景
@@ -1307,6 +1335,7 @@ TCP 超时要等 ~2 分钟才触发 `SINT_STAT_TIM_OUT`,
| 版本 | 时间 | 说明 |
|------|------|------|
| V4.2 | 2026-08-18 | MQTT 命令集补齐: ssc_net_query/iot_net_query/iot_topic_query 只读组包 (协议 V1.02 对齐), 工具禁用未实现按钮 |
| V4.1 | 2026-08-18 | TCP/MQTT 脱机日志快照流: log_stat/log_query/log_clear 支持 stream=snapshot (协议 V1.03/V1.07), snap_rec_to_json 序列化, 事件流 count=0 按上限 |
| V4.0 | 2026-08-10 | BLE 脱机日志接口: OFFLOG_STAT/QUERY/CLEAR (0x25/0x26/0x27), 32B OfflogEvt 二进制直传, 缓冲扩容 132B, 隔离测试 7 例 + 协议文档 V1.00 |
| V3.9 | 2026-08-05 | offlog 协议导出命令分发: log_stat/log_query/log_clear 落地 MQTT V1.06 + TCP JSON V1.02 (seq_first/seq_last 计算、idx 映射、OFFLOG_MAX_QUERY_RECORDS=4、log_clear 阻塞~2.8s) |