feat(vd960DBN)+fix(DBNMQTTool): log_query 改 hex 原始字节上报 (2026-08-18)
背景: MQTT 快照流实测 MQTTSerialize_publish failed — JSON 化快照记录 ~810B/条 超 800B 发送缓冲
方案(用户拍板): 对齐 BLE 通道, 原始字节 hex 上报
固件 (V4.3):
- offlog.c/h: 新增 offlog_evt_to_hex() (32B→64 hex)
- snapshot.c/h: 新增 snap_rec_to_hex() (64B→128 hex); 删 SNAP_MAX_QUERY_JSON, 恢复 count=2
- tcp_json_srv.c / iot_mqtt_srv.c: log_query 改 {"seq":N,"hex":"..."}; SEND_BUF 保持 800
- 2 条快照 hex 响应 406B < 800B
文档: TCP JSON V1.03 / MQTT V1.07 §4.17 records 改 hex + 解析表引用 BLE §6.4/§7
工具: parse_offlog_hex/parse_snap_hex/offlog_payload_desc + hex 展示; 验证: gcc 9 断言 + 工具解析全过 + offscreen UI
This commit is contained in:
@@ -590,7 +590,7 @@ static void iot_handle_publish(const char *topic, uint8_t *payload, int payload_
|
||||
iot_mqtt_publish(resp_topic, resp, strlen(resp), 1);
|
||||
|
||||
} else if (strcmp(cmd_str, "log_query") == 0) {
|
||||
/* 分页拉取脱机日志: 按全局序号, event/snapshot 流 (协议 V1.07) */
|
||||
/* 分页拉取脱机日志: 按全局序号, event/snapshot 流, hex 原始字节上报 (协议 V1.07) */
|
||||
static char resp[IOT_MQTT_SEND_BUF_LEN]; /* static: 避免大栈开销 */
|
||||
char stream_buf[16];
|
||||
uint32_t start_seq = 0, req_count = 0;
|
||||
@@ -622,9 +622,12 @@ static void iot_handle_publish(const char *topic, uint8_t *payload, int payload_
|
||||
uint32_t idx = start_seq - seq_first; /* 逻辑索引 = 全局序号 - seq_first */
|
||||
while (fetched < req_count && (idx + fetched) < total) {
|
||||
SnapRec rec;
|
||||
char hex[132]; /* 64B -> 128 hex + NUL */
|
||||
if (snap_read_idx(idx + fetched, &rec) != 0) break;
|
||||
if (fetched > 0) pos += snprintf(resp + pos, sizeof(resp) - pos, ",");
|
||||
pos += snap_rec_to_json(&rec, resp + pos, sizeof(resp) - pos);
|
||||
snap_rec_to_hex(&rec, hex, sizeof(hex));
|
||||
pos += snprintf(resp + pos, sizeof(resp) - pos,
|
||||
"{\"seq\":%lu,\"hex\":\"%s\"}", (unsigned long)rec.seq, hex);
|
||||
fetched++;
|
||||
}
|
||||
}
|
||||
@@ -640,9 +643,12 @@ static void iot_handle_publish(const char *topic, uint8_t *payload, int payload_
|
||||
uint32_t idx = start_seq - seq_first; /* 逻辑索引 = 全局序号 - seq_first */
|
||||
while (fetched < req_count && (idx + fetched) < total) {
|
||||
OfflogEvt evt;
|
||||
char hex[68]; /* 32B -> 64 hex + NUL */
|
||||
if (offlog_read_idx((uint16_t)(idx + fetched), &evt) != 0) break;
|
||||
if (fetched > 0) pos += snprintf(resp + pos, sizeof(resp) - pos, ",");
|
||||
pos += offlog_evt_to_json(&evt, resp + pos, sizeof(resp) - pos);
|
||||
offlog_evt_to_hex(&evt, hex, sizeof(hex));
|
||||
pos += snprintf(resp + pos, sizeof(resp) - pos,
|
||||
"{\"seq\":%lu,\"hex\":\"%s\"}", (unsigned long)evt.seq, hex);
|
||||
fetched++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user