蓝牙通道补齐脱机日志读取 (此前仅 MQTT V1.06 / TCP JSON V1.02 有 log_* 命令): - 3 条 BLE 命令, 语义对齐 MQTT log_stat/log_query/log_clear - QUERY 直接传 32B OfflogEvt 原始结构 (二进制协议, 无需 JSON), 复用 idx = start_seq - seq_first 定位, 不新增 offlog API - 缓冲扩容: MAX_BLE_TMP_BUF_LEN 100→132, 新增 MAX_BLE_DAT_BUF_LEN=132 (QUERY 响应 1+4x32B=129B), clear_buf_dbn_ble_all memset 同步 - 新协议文档 docs/DLD960_BLE协议.md V1.00 (帧格式+分包+命令+记录结构) - 隔离测试 test_ble_offlog.c 嵌入源文件 3 case 真实文本, 7 例全过; offlog 回归 8 例 ALL PASS - devlog V4.0; README 协议矩阵补 BLE 行
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""从 dbn_ble_srv.c 提取脱机日志 3 case 文本, 供 test_ble_offlog.c 隔离验证。
|
|
|
|
用法: python3 extract_offlog_cases.py
|
|
输出: ./offlog_cases_embedded.c (在 tests/ 目录下运行)
|
|
|
|
原理: 测的是源文件真实代码而非拷贝 — 提取 `case CMD_DBN_OFFLOG_STAT`
|
|
到 `default:` 之间的文本 (含 STAT/QUERY/CLEAR 3 case), 嵌入测试框架编译。
|
|
"""
|
|
import os
|
|
|
|
SRC = os.path.join(os.path.dirname(__file__),
|
|
"../BLE/OnlyUpdateApp_Peripheral/APP/dbn_ble_srv.c")
|
|
OUT = os.path.join(os.path.dirname(__file__), "offlog_cases_embedded.c")
|
|
|
|
with open(SRC, "rb") as f:
|
|
content = f.read()
|
|
text = content.decode("utf-8", errors="replace").replace("\r\n", "\n")
|
|
|
|
start = text.find("case CMD_DBN_OFFLOG_STAT")
|
|
end = text.find("default:\n", start)
|
|
if start == -1 or end == -1:
|
|
raise SystemExit("ERROR: 未找到 offlog 3 case (确认 dbn_ble_srv.c 已修改)")
|
|
|
|
cases = text[start:end]
|
|
for c in ("CMD_DBN_OFFLOG_STAT", "CMD_DBN_OFFLOG_QUERY", "CMD_DBN_OFFLOG_CLEAR"):
|
|
if c not in cases:
|
|
raise SystemExit(f"ERROR: 提取内容缺少 {c}")
|
|
|
|
with open(OUT, "w") as f:
|
|
f.write(cases)
|
|
print(f"OK: {OUT} ({len(cases)} bytes, 3 cases)")
|