diff --git a/AGENTS.md b/AGENTS.md index d9182c3..f49137e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -34,6 +34,7 @@ This file is the only mandatory entry point for AI-assisted work in this reposit | BSP, pins, buses, display, audio, battery | `docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.md`, `components/bsp/include/bsp_pins.h` | | Demo or menu | `main/demo.h`, `main/main.c`, the nearest `main/demo_*.c` implementation | | Chinese UI text or fonts | `docs/development/engineering/lvgl-chinese-fonts.md`, the application's font assets, configuration, and widget styles | +| Wi-Fi connection or Bluetooth provisioning | `docs/development/engineering/wifi-provisioning.md`, the referenced `demo/blufi-provisioning` implementation | | Build, test, dependencies, partitions | `docs/development/engineering/build-and-test.md`, `docs/development/engineering/firmware-layout.md`, `sdkconfig.defaults`, `partitions.csv` | | CI or release | the matching file in `docs/development/ci/CI-*.md` and `.github/workflows/` | | Project completion | `docs/development/release/project-completion.md` (then the `issue-suggestions` or `experience-pr` skill) | diff --git a/AGENTS.zh_CN.md b/AGENTS.zh_CN.md index 2ac52d5..4ae53e6 100644 --- a/AGENTS.zh_CN.md +++ b/AGENTS.zh_CN.md @@ -33,6 +33,7 @@ | BSP、引脚、总线、显示、音频、电池 | `docs/hardware-design/AI_HARDWARE_DEVELOPMENT_GUIDE.zh_CN.md`、`components/bsp/include/bsp_pins.h` | | Demo 或菜单 | `main/demo.h`、`main/main.c`、最近的 `main/demo_*.c` 实现 | | 中文 UI 或字体 | `docs/development/engineering/lvgl-chinese-fonts.zh_CN.md`、应用字体素材、配置与控件样式 | +| Wi-Fi 联网或蓝牙配网 | `docs/development/engineering/wifi-provisioning.zh_CN.md`、其中引用的 `demo/blufi-provisioning` 实现 | | 构建、测试、依赖、分区 | `docs/development/engineering/build-and-test.zh_CN.md`、`docs/development/engineering/firmware-layout.zh_CN.md`、`sdkconfig.defaults`、`partitions.csv` | | CI 或发布 | `docs/development/ci/CI-*.zh_CN.md` 中的对应文件与 `.github/workflows/` | | 项目开发完成 | `docs/development/release/project-completion.zh_CN.md`(再进入 `issue-suggestions` 或 `experience-pr` skill) | diff --git a/docs/development/README.md b/docs/development/README.md index 7ad3fc7..d05b3d8 100644 --- a/docs/development/README.md +++ b/docs/development/README.md @@ -17,6 +17,7 @@ This directory contains AI Passport engineering rules and reusable workflows, gr - [firmware-layout.md](engineering/firmware-layout.md): default and user-defined partition layouts and merged-artifact validation. - [coding-conventions.md](engineering/coding-conventions.md): source-code and resource conventions, including Chinese font integration, blank/boxed text troubleshooting, and display acceptance. - [lvgl-chinese-fonts.md](engineering/lvgl-chinese-fonts.md): step-by-step CJK configuration, font generation/linking, fallback examples, glyph checks, and troubleshooting. +- [wifi-provisioning.md](engineering/wifi-provisioning.md): Bluetooth-based Wi-Fi setup using the BLUFI reference branch, the companion mini program, and integration checks. ## CI diff --git a/docs/development/README.zh_CN.md b/docs/development/README.zh_CN.md index b026b0d..2fa8c23 100644 --- a/docs/development/README.zh_CN.md +++ b/docs/development/README.zh_CN.md @@ -26,6 +26,7 @@ - [firmware-layout.zh_CN.md](engineering/firmware-layout.zh_CN.md):默认/用户自定义分区布局与合并产物验证。 - [coding-conventions.zh_CN.md](engineering/coding-conventions.zh_CN.md):代码约定(语言风格、复用、注释、测试同步、资源约束等),包含中文字体接入、空白/方框排查与显示验收。 - [lvgl-chinese-fonts.zh_CN.md](engineering/lvgl-chinese-fonts.zh_CN.md):CJK 配置、字体生成/链接、fallback 示例、缺字检查和故障排查的分步指南。 +- [wifi-provisioning.zh_CN.md](engineering/wifi-provisioning.zh_CN.md):参考 BLUFI 分支实现蓝牙 Wi-Fi 配网,包含配套小程序名称及接入检查。 ## CI(ci) diff --git a/docs/development/engineering/wifi-provisioning.md b/docs/development/engineering/wifi-provisioning.md new file mode 100644 index 0000000..4f629f2 --- /dev/null +++ b/docs/development/engineering/wifi-provisioning.md @@ -0,0 +1,59 @@ +

+ 简体中文 · English +

+ +# Wi-Fi Connection via Bluetooth Provisioning + +When a user needs the device to connect to a Wi-Fi network, the +[`demo/blufi-provisioning` branch](https://github.com/FoloToy/ai-passport/tree/demo/blufi-provisioning) +provides a reference for Bluetooth-based Wi-Fi setup. The phone supplies the +SSID and password over BLE using BLUFI; the device connects as a Wi-Fi station +and reports connection status. Bluetooth carries the provisioning exchange, +not the application's Internet traffic. + +This is an optional application reference. The current `main` Wi-Fi demo only +scans networks; it does not implement connection or provisioning. Do not enable +networking for applications that do not need it. + +## Mini program name + +Use the companion mini program identified by the +[exact Chinese search name](wifi-provisioning.zh_CN.md#mini-program-name). +Keep that name unchanged in setup instructions rather than inventing a +translated search name. It is the mini program's name, not the device's BLE +advertising name. The reference firmware advertises as `BLUFI_FoloPassport`. + +The intended flow is to open provisioning on the device, enable Bluetooth and +the required permissions on the phone, open the mini program, select the target +device, and provide a 2.4 GHz Wi-Fi network's credentials. Confirm that the +device obtains an IP address, then test the application's actual network +request; a successful BLE connection alone does not prove Internet access. + +## Code to inspect + +- [`main/demo_blufi.c`](https://github.com/FoloToy/ai-passport/blob/demo/blufi-provisioning/main/demo_blufi.c): BLUFI callbacks, Wi-Fi scanning/connection, credential handling, status reporting, and lifecycle. +- [`main/demo_blufi_security.c`](https://github.com/FoloToy/ai-passport/blob/demo/blufi-provisioning/main/demo_blufi_security.c) and its header: BLUFI security negotiation callbacks; do not discard them when extracting the example. +- [`main/demo_radio.c`](https://github.com/FoloToy/ai-passport/blob/demo/blufi-provisioning/main/demo_radio.c): shared initialization of NVS, `esp_netif`, and the default event loop. +- [`main/CMakeLists.txt`](https://github.com/FoloToy/ai-passport/blob/demo/blufi-provisioning/main/CMakeLists.txt) and [`sdkconfig.defaults`](https://github.com/FoloToy/ai-passport/blob/demo/blufi-provisioning/sdkconfig.defaults): source registration, dependencies, NimBLE/BLUFI, and cryptographic configuration. Copying a single C file is not sufficient. + +## Integration and acceptance + +Start from the application's current baseline, record the reference commit, +and adapt only the relevant networking logic. Do not merge the entire demo or +overwrite current BSP, partitions, or configuration with the branch's older +versions. Implement the application's own UI and keep provisioning state, +tasks, and Wi-Fi/BLE services in the application layer. + +Define provisioning entry/exit, timeouts, retry limits, credential persistence, +and an explicit way to clear saved credentials. Never log or commit Wi-Fi +passwords. Preserve LVGL locking, non-blocking callbacks, and cleanup of tasks +and event handlers; budget internal RAM for concurrent Wi-Fi, BLE, and UI use. +The example is not a complete production authorization or security design. + +Run the [validation gate](build-and-test.md), then follow the +[on-device testing handoff](../ai-guide.md#offer-on-device-testing). Test with +the named mini program: discovery, successful provisioning, wrong-password and +unavailable-network failures, reconnect/restart behavior, credential clearing, +repeated entry/exit, and an actual application network request. Build success +does not prove mini program compatibility or on-device networking; keep +unperformed checks under `Unverified`. diff --git a/docs/development/engineering/wifi-provisioning.zh_CN.md b/docs/development/engineering/wifi-provisioning.zh_CN.md new file mode 100644 index 0000000..f98e73e --- /dev/null +++ b/docs/development/engineering/wifi-provisioning.zh_CN.md @@ -0,0 +1,52 @@ +

+ 简体中文 · English +

+ +# 通过蓝牙配网连接 Wi-Fi + +当用户需要设备通过 Wi-Fi 连接网络时,可以参考 +[`demo/blufi-provisioning` 分支](https://github.com/FoloToy/ai-passport/tree/demo/blufi-provisioning) +的代码实现蓝牙配网。手机通过 BLE 上的 BLUFI 协议发送 Wi-Fi 名称(SSID)和 +密码,设备以 Wi-Fi STA 模式连接网络并回报连接状态。蓝牙用于传递配网信息, +不是承载应用的互联网流量。 + +这是可选的应用参考。当前 `main` 的 Wi-Fi demo 仅扫描网络,并未实现联网或 +蓝牙配网;没有联网需求的应用不必启用网络功能。 + + + +## 小程序名称 + +配套小程序的准确名称为:**蓝牙配网-FoloToy AI PASSPORT**。 + +向用户说明或搜索小程序时,请使用上述完整名称,不要自行翻译或改写。 +这是小程序名称,不是设备的蓝牙广播名;参考固件的广播名为 +`BLUFI_FoloPassport`。 + +预期流程:设备进入配网状态,手机打开蓝牙并授予所需权限,打开该小程序, +选择目标设备,提供 2.4 GHz Wi-Fi 的名称和密码。确认设备取得 IP 地址后, +再验证应用实际需要的网络请求;仅蓝牙连接成功不能证明能够访问互联网。 + +## 代码参考入口 + +- [`main/demo_blufi.c`](https://github.com/FoloToy/ai-passport/blob/demo/blufi-provisioning/main/demo_blufi.c):BLUFI 回调、Wi-Fi 扫描与连接、凭据处理、状态回报和生命周期。 +- [`main/demo_blufi_security.c`](https://github.com/FoloToy/ai-passport/blob/demo/blufi-provisioning/main/demo_blufi_security.c) 及其头文件:BLUFI 安全协商回调,提取示例时不要丢弃这些逻辑。 +- [`main/demo_radio.c`](https://github.com/FoloToy/ai-passport/blob/demo/blufi-provisioning/main/demo_radio.c):NVS、`esp_netif` 和默认事件循环的共享初始化。 +- [`main/CMakeLists.txt`](https://github.com/FoloToy/ai-passport/blob/demo/blufi-provisioning/main/CMakeLists.txt) 和 [`sdkconfig.defaults`](https://github.com/FoloToy/ai-passport/blob/demo/blufi-provisioning/sdkconfig.defaults):源文件注册、依赖、NimBLE/BLUFI 和加密配置。不能只复制单个 C 文件就认为完成接入。 + +## 接入与验收 + +从应用当前基线出发,记录参考提交,仅移植适用的联网逻辑。不要直接合并整个 +demo,也不要用该分支的旧版 BSP、分区表或配置覆盖当前版本。重新实现应用 +自己的界面,将配网状态、任务及 Wi-Fi/BLE 服务放在应用层。 + +明确配网入口与退出、超时、重试上限、凭据持久化及主动清除凭据的方式。 +禁止记录或提交 Wi-Fi 密码。保留 LVGL 锁、非阻塞回调、任务与事件处理器清理 +机制,并评估 Wi-Fi、BLE 和 UI 同时运行的内部 RAM 占用。示例不等于完整的 +生产环境授权或安全设计。 + +运行[验证门禁](build-and-test.zh_CN.md),再遵循 +[真机测试交接流程](../ai-guide.zh_CN.md#主动询问真机测试)。使用上述小程序 +验证:发现设备、成功配网、密码错误与网络不可用、重连与重启、清除凭据、 +反复进入退出配网,以及应用实际需要的网络请求。编译成功不能证明小程序 +兼容性或实机联网正常;未执行的检查列入 `Unverified`。