Files
mobile_comm/luatos/air780epm/docs/rfa/2026-06-13-mobile-rf-test-redesign.md
wangfq 173dd6874f init: Air780EPM 官方 LuatOS 项目代码基线
- 来源: 合宙 LuatOS 官方仓库 air780epm 模块完整代码
- 路径: luatos/air780epm/module/Air780EPM/demo 含官方 demo(含 mqtt/mqtts/socket/uart 等)
- 后续: 基于 demo 开发 UART<->MQTT 数据上报功能
2026-08-31 08:53:49 +08:00

7.6 KiB

mobile RF 校准 rfa 重构实施计划

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans

Status: 已完成 5 阶段 6 commit (2026-06-13, branch: mobile-rf-test-rewrite)

Goal:mobile 库的 RF 校准功能从 C 端硬编码改为 Thin C / Fat Lua 架构, 沿用 luat_mobile_rf_test_* 前缀扩展 Architecture: Thin C (5 函数) / Fat Lua (新模块 rfa.*) Tech Stack: C (luat_mobile_*) + Lua 5.3 + xmake + MSVC

Worktree: D:\github\LuatOS\.worktrees\mobile-rf-test-rewrite (branch mobile-rf-test-rewrite)


File Structure

New (Create)

  • script/libs/rfa.lua — Lua 端 rfa.* 模块
  • testcase/utest/drv/mobile_rfa_basic/metas.json
  • testcase/utest/drv/mobile_rfa_basic/scripts/main.lua
  • testcase/utest/drv/mobile_rfa_basic/scripts/mobile_rfa_test.lua — 13 case
  • tools/rfa_com0com/at_server_main/main.lua
  • tools/rfa_com0com/setup_com0com_pair.ps1
  • tools/rfa_com0com/test_rfa_com0com.py
  • components/mobile/README_rfa.md
  • docs/superpowers/specs/2026-06-13-mobile-rf-test-redesign-design.md
  • docs/superpowers/plans/2026-06-13-mobile-rf-test-redesign.md (本文件)

Modify

  • components/mobile/luat_mobile.h — 改 rf_test_, 删 rfcal_, 加 3 个新函数
  • components/mobile/luat_lib_mobile.c — 改 nst_, 删 rfcal_, 加 5 个新绑定
  • bsp/pc/port/luat_mobile_pc.c — 改 rf_test_, 删 rfcal_, 加 s_rf_test + 3 个新函数
  • components/mobile/luat_mobile_airlink_rpc.c — 改 rf_test_*, 加 4 个新空桩
  • oldmodule/Air780E/demo/rf_test/main.lua — 加 deprecation 注释

Delete

  • lua/luat/rfcal_at_server.lua
  • testcase/utest/drv/mobile_rfcal_basic/ (整目录)
  • tools/rfcal_com0com/ (整目录)
  • components/mobile/README_rfcal.md
  • components/utest/mobile/luat_mobile_rfcal_utest.c

Task 1: 实化原有 rf_test_* + 新增 5 个新函数 (不删旧的)

Files: luat_mobile.h, luat_mobile_pc.c, luat_mobile_airlink_rpc.c, luat_lib_mobile.c

Commit: refactor(mobile): realize luat_mobile_rf_test_mode/input; add param/imei/set_rx_cb

  • Step 1: components/mobile/luat_mobile.h 末尾追加 5 个新函数声明 + key 宏 + rx_cb 结构
  • Step 2: bsp/pc/port/luat_mobile_pc.c 顶部加 s_rf_test 静态结构
  • Step 3: luat_mobile_pc.c 312-319 行替换空桩为实化实现 (调 s_rf_test)
  • Step 4: luat_mobile_pc.c 末尾加 4 个新函数 (set_rx_cb / param / imei_get / imei_set)
  • Step 5: luat_mobile_airlink_rpc.c 419-427 改空桩, 加 4 个新空桩 (返 -1)
  • Step 6: luat_lib_mobile.c 加 5 个新绑定 (rfTestMode/Input/Param/Imei/ImeiSet) 并注册到 reg_mobile
  • Step 7: 编译 cd bsp/pc && powershell -Command "& '.\build_windows_32bit_msvc.bat'"
  • Step 8: 烟雾测试 mobile_rf_test_smoke 14/14 全过

Task 2: 新增 script/libs/rfa.lua + 新 utest 套件

Files: script/libs/rfa.lua, testcase/utest/drv/mobile_rfa_basic/

Commit: feat(lua): add script/libs/rfa.lua state machine + dispatch

  • Step 1: 新建 script/libs/rfa.lua (~200 行, 状态机 7 阶段 + 派发表 + 扩展点)
  • Step 2: 新建 testcase/utest/drv/mobile_rfa_basic/metas.json
  • Step 3: 新建 testcase/utest/drv/mobile_rfa_basic/scripts/main.lua
  • Step 4: 新建 testcase/utest/drv/mobile_rfa_basic/scripts/mobile_rfa_test.lua (4 套件, 13 case)
  • Step 5: 跑测试 ./luatos-lua.exe ../../../../testcase/common/scripts/ ../../../../testcase/utest/drv/mobile_rfa_basic/scripts/ ../../../../script/libs/
  • Step 7: 验证 ### OVERALL_PASS ### mobile_rfa_basic

Task 3: 迁移 com0com 工具 (双轨运行期)

Files: tools/rfa_com0com/ (新), tools/rfcal_com0com/ (保留到阶段 4)

Commit: feat(com0com): migrate rfcal_com0com → rfa_com0com (双轨运行期)

  • Step 1: mkdir -p tools/rfa_com0com/at_server_main
  • Step 2: 复制 setup_com0com_pair.ps1tools/rfa_com0com/
  • Step 3: 新建 tools/rfa_com0com/at_server_main/main.lua (改用 rfa, 内部 mobile.rfTest* 桥, 通过 script/libs 加载)
  • Step 4: 新建 tools/rfa_com0com/test_rfa_com0com.py (复制 + 改名 + 注释更新)
  • Step 5: 验证 tools/rfcal_com0com/ 仍存在 (双轨)

Task 4: 删旧代码 (rfcal_* + nst_* + 旧 utest/demos)

Files: 多文件删除

Commit: refactor(mobile): remove old luat_mobile_rfcal_* and nst_*

  • Step 1: luat_mobile.h 删 851-917 整段 (rfcal_* 7 个声明)
  • Step 2: luat_mobile_pc.c 删 493-615 整段 (rfcal_* PC 仿真实现)
  • Step 3: luat_lib_mobile.c 删 nst_* + rfcal_* + l_mobile_utest 块, reg_mobile 表对应项
  • Step 4: 新建 components/mobile/README_rfa.md (替代 README_rfcal.md)
  • Step 5:lua/luat/rfcal_at_server.lua
  • Step 6:components/mobile/README_rfcal.md
  • Step 7:components/utest/mobile/luat_mobile_rfcal_utest.c
  • Step 8:testcase/utest/drv/mobile_rfcal_basic/ (整目录)
  • Step 9:tools/rfcal_com0com/ (整目录)
  • Step 10: oldmodule/Air780E/demo/rf_test/main.lua 加 deprecation 注释
  • Step 11: testcase/utest/drv/mobile_rfa_basic/scripts/mobile_rfa_test.lua 改 nst_aliases 为反向验证
  • Step 12: 编译 + 全测试, 验证 13/13 OVERALL_PASS

Task 5: 写 spec/plan 落档

Files: docs/superpowers/specs/..., docs/superpowers/plans/...

Commit: docs(mobile): spec + plan for rfa redesign

  • Step 1: 新建 docs/superpowers/specs/2026-06-13-mobile-rf-test-redesign-design.md
  • Step 2: 新建 docs/superpowers/plans/2026-06-13-mobile-rf-test-redesign.md (本文件)
  • Step 3: 最终 commit

Self-Review

Spec coverage 检查表

  • Context 解释两个根本性错误
  • Goals 6 项明确
  • Non-goals 4 项边界
  • Chosen approach (Thin C / Fat Lua)
  • Architecture 5 段 (C 接口 / PC 仿真 / Lua API / 状态机 / AT 派发)
  • Failure modes 6 项
  • Verification 4 段
  • Critical files 完整列表 (Modify/Create/Delete)
  • 风险点 6 项

Placeholder scan

  • 无 TBD / TODO
  • 无空章节
  • 无歧义需求

Type consistency

  • 5 个 C 函数签名一致 (mode/input void, 其他 int)
  • 13 个 utest case 一致引用 mobile.rfTest*
  • README 表格/代码一致

验证

  • 13/13 utest OVERALL_PASS
  • 编译 0 错误 0 警告 (除 C4090 第三方)
  • smoke test 14/14 (阶段 1, 阶段 4 后已删)
  • com0com 文件双轨存在 (阶段 3 后, 阶段 4 已删旧)

落地

  • spec 落到 docs/superpowers/specs/2026-06-13-mobile-rf-test-redesign-design.md
  • plan 落到 docs/superpowers/plans/2026-06-13-mobile-rf-test-redesign.md
  • 5 个 commit 都在 mobile-rf-test-rewrite 分支
  • 主仓 master 不动

Commit 历史 (已落)

1. refactor(mobile): realize luat_mobile_rf_test_mode/input; add param/imei/set_rx_cb
2. feat(lua): add script/libs/rfa.lua state machine + dispatch
3. feat(com0com): migrate rfcal_com0com → rfa_com0com (双轨运行期)
4. refactor(mobile): remove old luat_mobile_rfcal_* and nst_*
5. docs(mobile): spec + plan for rfa redesign

后续工作 (out of scope)

  1. luatos-soc-2024 单独 PR — 实现真机端 5 个新 luat_rfa_* 函数 + 迁移 toupper 到 PLAT 层
  2. 真机端 com0com 回归 (EC718 模组) — 验证 Lua rfa 在真机 UART 上行为一致
  3. 产线工具对齐 — AT+ECRFNST 私有协议 cmdId 模板按需 rfa.registerRfnst 扩展