From 82b287dd9286a55471a71e75883224f422841a41 Mon Sep 17 00:00:00 2001 From: ozh Date: Wed, 24 Jun 2026 17:09:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ble):=20BLE=20=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=B8=8E=E5=8D=8F=E8=AE=AE=E6=97=B6=E5=BA=8F?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 从 git 追踪中移除 .idea、.claude/rules、CLAUDE.md、AGENTS.md - 更新 .gitignore,添加 prettier 配置 - BLE 核心模块重构(bleCore/controller/auth/radar/wifi/errors/eventBus/stateWait) - 修复协议时序:订阅 F301 前先读 F501(readMsgOnce) - 设备配置页优化:鉴权失败改用模态弹窗,WiFi 错误持久展示 - 密钥流程已废弃,鉴权失败不阻断后续配网流程 - pages.json 格式化(tab → 空格) --- .claude/rules/frontend.md | 67 ----- .claude/rules/git-workflow.md | 5 - .claude/rules/test.md | 2 - .gitignore | 22 +- .idea/.gitignore | 8 - .idea/modules.xml | 8 - .idea/smarthome.iml | 12 - .idea/vcs.xml | 6 - .vscode/settings.json | 2 - AGENTS.md | 7 - CLAUDE.md | 7 - hooks/useBluetoothDiscovery.js | 10 +- manifest.json | 3 +- pages.json | 144 +++++----- pages/device/config.vue | 40 ++- utils/ble/core/bleCore.js | 475 +++++++++++++++++++-------------- utils/ble/core/controller.js | 241 +++++++++++------ utils/ble/core/errors.js | 28 +- utils/ble/core/eventBus.js | 38 +-- utils/ble/core/stateWait.js | 45 +++- utils/ble/modules/auth.js | 237 ++++++++++------ utils/ble/modules/radar.js | 72 ++--- utils/ble/modules/wifi.js | 44 ++- 23 files changed, 862 insertions(+), 661 deletions(-) delete mode 100644 .claude/rules/frontend.md delete mode 100644 .claude/rules/git-workflow.md delete mode 100644 .claude/rules/test.md delete mode 100644 .idea/.gitignore delete mode 100644 .idea/modules.xml delete mode 100644 .idea/smarthome.iml delete mode 100644 .idea/vcs.xml delete mode 100644 .vscode/settings.json delete mode 100644 AGENTS.md delete mode 100644 CLAUDE.md diff --git a/.claude/rules/frontend.md b/.claude/rules/frontend.md deleted file mode 100644 index 5117624..0000000 --- a/.claude/rules/frontend.md +++ /dev/null @@ -1,67 +0,0 @@ -# Project Overview - -This is a uni-app Vue3 smart home (智慧养老) application using uview-plus component library. - -- Use the new features of es6 -- Use the uniapp framework for small program development -- Added uview-plus component as UI component - -# Build & Run Commands - -Install dependencies with `npm install`. - -This repository does not define npm scripts; builds and previews are normally run through HBuilderX. Use HBuilderX for the active target platform: - -```bash -npm install -``` - -Typical local workflow: -- Open the project in HBuilderX and run to WeChat Mini Program or Android emulator/device. -- Use the built-in packaging flow for release builds. - -# Architecture - -## Module Organization -App entry files live at the repository root: `main.js`, `App.vue`, `pages.json`, and `manifest.json`. Feature pages are under `pages/` (`login`, `index`, `event`, `mine`, `device`). Shared business code is split across `api/`, `constants/`, `hooks/`, and `utils/`. Bluetooth logic is centralized in `utils/ble/`, with subfolders for `core/`, `modules/`, `parsers/`, `protocols/`, and `utils/`. Static assets go in `static/`; design and protocol notes live in `docs/`. - -## BLE Module (`utils/ble/`) -If you are unclear about the functions of the BLE Module, please refer to the `docs/unified-ble-flow.md` file. - -Unified Bluetooth Low Energy module for ED713/ED719 devices. Key files: - -- `core/bleCore.js` - Bluetooth core capabilities (connect/discover/read/write/notify/reconnect) -- `core/controller.js` - Standard flow orchestration (scan→connect→discover→auth) -- `core/packet.js` - A7 packet fragmentation -- `modules/auth.js` - Authentication flow (read MSG + write KEY) -- `modules/wifi.js` - WiFi configuration -- `modules/radar.js` - Radar control (start/stop/params) -- `protocols/profiles.js` - ED713/ED719 device profile differences - -The unified flow: `standardConnectFlow({ deviceId, key })` → `wifi.configureWifi(ssid, password)` → `radar.startRadarStream()` - -Profile differences: -- ED713: radar signature `0x7C`, supports narrow mode -- ED719: radar signature `0x67`, supports fall param 67 - -If modifications are made to the BLE Module, they shall be added to the `docs/unified-ble-flow.md` file!! - -## Authentication (`utils/auth.js`) - -Route guard system with `setupAuthInterceptors()`. Currently `AUTH_ENABLED = false` for development. Routes are defined in `constants/routes.js`. - -## Pages - -- `pages/login/index.vue` - Login page -- `pages/index/index.vue` - Home (tab) -- `pages/event/index.vue` - Events (tab) -- `pages/mine/index.vue` - Profile (tab) -- `pages/device/add.vue` - Add device -- `pages/device/config.vue` - Device config with BLE search + WiFi panel - -## Component Auto-import - -uview-plus components auto-imported via `pages.json` easycom config: `^u-(.*)` → `uview-plus/components/u-$1/u-$1.vue` - -## Coding Style & Naming Conventions -Follow the existing Vue SFC structure: `