ADR-052:Tauri 桌面前端 — RuView 硬件管理与可视化¶
| 字段 | 值 |
|---|---|
| 状态 | 提议中 |
| 日期 | 2026-03-06 |
| 决策者 | ruv |
| 依赖于 | ADR-012(ESP32 CSI 网格)、ADR-039(边缘智能)、ADR-040(WASM 可编程感知)、ADR-044(预配增强)、ADR-166(安全加固,由 ADR-050 重新编号)、ADR-051(服务器分解) |
| 问题 | #177 |
上下文¶
RuView 目前要求用户通过多个彼此不相连的工具来管理 WiFi DensePose 部署:
| 任务 | 当前工具 | 痛点 |
|---|---|---|
| 刷写固件 | esptool.py CLI |
需要 Python、pip 以及正确的芯片/波特率标志 |
| 预配 NVS | provision.py CLI |
13 个以上标志,无 GUI,无回读 |
| OTA 更新 | curl POST :8032/ota |
手动 HTTP,需构造 PSK 请求头 |
| WASM 模块 | curl 到 :8032/wasm/* |
无法查看模块状态 |
| 启动感知服务器 | cargo run 或二进制文件 |
手动配置端口,无日志查看器 |
| 查看感知数据 | 位于 localhost:8080 的浏览器 |
独立窗口,无硬件上下文 |
| 网格拓扑 | 心智模型 | 无法可视化 TDM 时隙、同步和健康状态 |
| 节点发现 | 手动跟踪 IP | 无 mDNS/UDP 广播发现 |
目前没有一个工具能够提供整个部署的统一视图——从 ESP32 硬件到感知流水线再到姿态可视化。部署多节点网格的现场操作人员不得不在终端、浏览器和串口监视器之间来回切换。
为什么需要桌面应用¶
基于浏览器的 UI 无法访问串口(用于刷写)、原始 UDP 套接字(用于节点发现)或本地文件系统(用于固件二进制文件)。硬件管理需要桌面应用程序。Tauri v2 是自然选择,因为:
- Rust 后端 — 可直接与现有 Rust 工作区(
v2/)集成。诸如wifi-densepose-hardware(串口解析)、wifi-densepose-config和wifi-densepose-sensing-server等 crate 可以作为库依赖链接。 - 小体积二进制文件 — Tauri 打包系统 webview,而不是捆绑 Chromium(相比 Electron 可节省约 150 MB)。
- 跨平台 — 同一代码库支持 Windows、macOS、Linux。
- 安全模型 — Tauri 基于能力的权限系统限制前端只能访问明确允许的 Rust 命令。
为什么不用 Electron / Flutter / 原生¶
| 选项 | 被拒绝原因 |
|---|---|
| Electron | 150+ MB 捆绑包,无 Rust 集成,重复 webview |
| Flutter | 无串口插件,Dart 到 Rust 的 FFI 使用笨拙 |
| 原生(GTK/Qt) | 平台特定 UI 代码,无法复用 Web 组件 |
| 仅 Web(PWA) | 无法访问串口或原始 UDP |
决策¶
在 Rust 工作区中新增一个 crate,构建 Tauri v2 桌面应用程序。前端使用 TypeScript、React 和 Vite。Rust 后端暴露 Tauri 命令,将前端桥接到串口、UDP 套接字、HTTP 管理端点和感知服务器进程。
1. 工作区集成¶
向工作区添加一个新 crate:
v2/
Cargo.toml # Add "crates/wifi-densepose-desktop" to members
crates/
wifi-densepose-desktop/ # NEW — Tauri app crate
Cargo.toml
tauri.conf.json
capabilities/
default.json # Tauri v2 capability permissions
icons/ # App icons (all platforms)
src/
main.rs # Tauri entry point
lib.rs # Command module re-exports
commands/
mod.rs
discovery.rs # Node discovery commands
flash.rs # Firmware flashing commands
ota.rs # OTA update commands
wasm.rs # WASM module management commands
server.rs # Sensing server lifecycle commands
provision.rs # NVS provisioning commands
serial.rs # Serial port enumeration
state.rs # Tauri managed state
discovery/
mod.rs
mdns.rs # mDNS service discovery
udp_broadcast.rs # UDP broadcast probe
flash/
mod.rs
espflash.rs # Rust-native ESP32 flashing (via espflash crate)
esptool.rs # Fallback: bundled esptool.py wrapper
frontend/
package.json
tsconfig.json
vite.config.ts
index.html
src/
main.tsx
App.tsx
routes.tsx
hooks/
useNodes.ts # Node discovery and status polling
useServer.ts # Sensing server state
useWebSocket.ts # WS connection to sensing server
stores/
nodeStore.ts # Zustand store for discovered nodes
serverStore.ts # Sensing server process state
settingsStore.ts # User preferences (dark mode, ports)
pages/
Dashboard.tsx # Hardware management overview
NodeDetail.tsx # Single node detail + config
FlashFirmware.tsx # Firmware flashing wizard
WasmModules.tsx # WASM module manager
SensingView.tsx # Live sensing data visualization
MeshTopology.tsx # Multi-node mesh topology view
Settings.tsx # App settings and preferences
components/
NodeCard.tsx # Node status card (health, version, signal)
NodeList.tsx # Discovered node list
FirmwareProgress.tsx # Flash/OTA progress indicator
LogViewer.tsx # Scrolling log output
SignalChart.tsx # Real-time CSI signal chart
PoseOverlay.tsx # Pose skeleton overlay
MeshGraph.tsx # D3/force-graph mesh topology
SerialPortSelect.tsx # Serial port dropdown
ProvisionForm.tsx # NVS provisioning form
lib/
tauri.ts # Typed Tauri invoke wrappers
types.ts # Shared TypeScript types
2. Rust 后端 — Tauri 命令¶
2.1 节点发现¶
// commands/discovery.rs
/// Discover ESP32 CSI nodes on the local network.
/// Strategy 1: mDNS — nodes announce _ruview._tcp service
/// Strategy 2: UDP broadcast probe on port 5005 (CSI aggregator port)
/// Strategy 3: HTTP health check sweep on port 8032 (OTA server)
#[tauri::command]
async fn discover_nodes(timeout_ms: u64) -> Result<Vec<DiscoveredNode>, String>;
/// Get detailed status from a specific node via HTTP.
/// Calls GET /ota/status on port 8032.
#[tauri::command]
async fn get_node_status(ip: String) -> Result<NodeStatus, String>;
/// Subscribe to node health updates (periodic polling).
#[tauri::command]
async fn watch_nodes(interval_ms: u64, state: State<'_, AppState>) -> Result<(), String>;
DiscoveredNode 结构体:
#[derive(Serialize, Deserialize, Clone)]
pub struct DiscoveredNode {
pub ip: String,
pub mac: Option<String>,
pub hostname: Option<String>,
pub node_id: u8,
pub firmware_version: Option<String>,
pub tdm_slot: Option<u8>,
pub tdm_total: Option<u8>,
pub edge_tier: Option<u8>,
pub uptime_secs: Option<u64>,
pub discovery_method: DiscoveryMethod, // Mdns | UdpProbe | HttpSweep
pub last_seen: chrono::DateTime<chrono::Utc>,
}
2.2 固件刷写¶
// commands/flash.rs
/// List available serial ports with chip detection.
#[tauri::command]
async fn list_serial_ports() -> Result<Vec<SerialPortInfo>, String>;
/// Flash firmware binary to an ESP32 via serial port.
/// Uses the `espflash` crate for Rust-native flashing (no Python dependency).
/// Falls back to bundled esptool.py if espflash fails.
/// Emits progress events via Tauri event system.
#[tauri::command]
async fn flash_firmware(
port: String,
firmware_path: String,
chip: Chip, // Esp32, Esp32s3, Esp32c3
baud: Option<u32>,
app_handle: AppHandle,
) -> Result<FlashResult, String>;
/// Read firmware info from a connected ESP32 (chip type, flash size, MAC).
#[tauri::command]
async fn read_chip_info(port: String) -> Result<ChipInfo, String>;
刷写进度通过 Tauri 事件发出:
#[derive(Serialize, Clone)]
pub struct FlashProgress {
pub phase: FlashPhase, // Connecting | Erasing | Writing | Verifying
pub progress_pct: f32, // 0.0 - 100.0
pub bytes_written: u64,
pub bytes_total: u64,
pub speed_bps: u64,
}
2.3 OTA 更新¶
// commands/ota.rs
/// Push firmware to a node via HTTP OTA (port 8032).
/// Includes PSK authentication per ADR-166.
#[tauri::command]
async fn ota_update(
node_ip: String,
firmware_path: String,
psk: Option<String>,
app_handle: AppHandle,
) -> Result<OtaResult, String>;
/// Get OTA status from a node (current version, partition info).
#[tauri::command]
async fn ota_status(node_ip: String, psk: Option<String>) -> Result<OtaStatus, String>;
/// Batch OTA update — push firmware to multiple nodes sequentially.
/// Skips nodes already running the target version.
#[tauri::command]
async fn ota_batch_update(
nodes: Vec<String>, // IPs
firmware_path: String,
psk: Option<String>,
app_handle: AppHandle,
) -> Result<Vec<OtaResult>, String>;
2.4 WASM 模块管理¶
// commands/wasm.rs
/// List WASM modules loaded on a node.
/// Calls GET /wasm/list on port 8032.
#[tauri::command]
async fn wasm_list(node_ip: String) -> Result<Vec<WasmModule>, String>;
/// Upload a WASM module to a node.
/// Calls POST /wasm/upload on port 8032 with binary payload.
#[tauri::command]
async fn wasm_upload(
node_ip: String,
wasm_path: String,
app_handle: AppHandle,
) -> Result<WasmUploadResult, String>;
/// Start/stop a WASM module on a node.
#[tauri::command]
async fn wasm_control(
node_ip: String,
module_id: String,
action: WasmAction, // Start | Stop | Unload
) -> Result<(), String>;
2.5 感知服务器生命周期¶
// commands/server.rs
/// Start the sensing server as a managed child process.
/// The server binary is either bundled with the Tauri app (sidecar)
/// or discovered on PATH.
#[tauri::command]
async fn start_server(
config: ServerConfig,
state: State<'_, AppState>,
app_handle: AppHandle,
) -> Result<(), String>;
/// Stop the managed sensing server process.
#[tauri::command]
async fn stop_server(state: State<'_, AppState>) -> Result<(), String>;
/// Get sensing server status (running/stopped, PID, ports, uptime).
#[tauri::command]
async fn server_status(state: State<'_, AppState>) -> Result<ServerStatus, String>;
#[derive(Serialize, Deserialize, Clone)]
pub struct ServerConfig {
pub http_port: u16, // Default: 8080
pub ws_port: u16, // Default: 8765
pub udp_port: u16, // Default: 5005
pub static_dir: Option<String>, // Path to UI static files
pub model_dir: Option<String>, // Path to ML models
pub log_level: String, // trace, debug, info, warn, error
}
感知服务器作为 Tauri sidecar 二进制文件打包。Tauri v2 支持通过 tauri.conf.json 中的 externalBin 使用 sidecar 二进制文件:
2.6 NVS 配置¶
// commands/provision.rs
/// Provision NVS configuration to an ESP32 via serial port.
/// Replaces the Python provision.py script with a Rust-native implementation.
/// Generates NVS partition binary and flashes it to the NVS partition offset.
#[tauri::command]
async fn provision_node(
port: String,
config: NvsConfig,
app_handle: AppHandle,
) -> Result<ProvisionResult, String>;
/// Read current NVS configuration from a connected ESP32.
/// Reads the NVS partition and parses key-value pairs.
#[tauri::command]
async fn read_nvs(port: String) -> Result<NvsConfig, String>;
#[derive(Serialize, Deserialize, Clone)]
pub struct NvsConfig {
pub wifi_ssid: Option<String>,
pub wifi_password: Option<String>,
pub target_ip: Option<String>,
pub target_port: Option<u16>,
pub node_id: Option<u8>,
pub tdm_slot: Option<u8>,
pub tdm_total: Option<u8>,
pub edge_tier: Option<u8>,
pub presence_thresh: Option<u16>,
pub fall_thresh: Option<u16>,
pub vital_window: Option<u16>,
pub vital_interval_ms: Option<u16>,
pub top_k_count: Option<u8>,
pub hop_count: Option<u8>,
pub channel_list: Option<Vec<u8>>,
pub dwell_ms: Option<u32>,
pub power_duty: Option<u8>,
pub wasm_max_modules: Option<u8>,
pub wasm_verify: Option<bool>,
pub wasm_pubkey: Option<Vec<u8>>,
pub ota_psk: Option<String>,
}
3. 前端架构¶
3.1 技术栈¶
| 层 | 选择 | 理由 |
|---|---|---|
| 框架 | React 19 | 组件模型、生态系统、团队熟悉度 |
| 构建 | Vite 6 | 快速 HMR,支持 Tauri 插件 |
| 状态 | Zustand | 轻量、无样板代码,可配合 Tauri 事件使用 |
| 路由 | React Router v7 | 基于文件的路由,类型安全 |
| UI 组件 | shadcn/ui + Tailwind CSS | 可访问、可定制,无运行时 CSS-in-JS |
| 图表 | Recharts or visx | 实时信号可视化 |
| 拓扑图 | D3 力导向 | Mesh 网络可视化 |
| 串行 UI | 自定义 | Tauri 命令集成 |
| 图标 | Lucide React | 风格一致,可 tree-shake |
3.2 页面布局¶
+------------------------------------------+
| RuView [Settings] [?] |
+-------+----------------------------------+
| | |
| Nav | Dashboard / Active Page |
| | |
| [D] | +--------+ +--------+ +------+ |
| [F] | | Node 1 | | Node 2 | | +Add | |
| [W] | +--------+ +--------+ +------+ |
| [S] | |
| [M] | Server Status: Running |
| [T] | +--------------------------+ |
| | | Live Signal / Pose View | |
| | +--------------------------+ |
+-------+----------------------------------+
| Status Bar: 3 nodes | Server: :8080 |
+------------------------------------------+
Nav items:
[D] Dashboard — overview of all nodes and server
[F] Flash — firmware flashing wizard
[W] WASM — edge module management
[S] Sensing — live sensing data view
[M] Mesh — topology visualization
[T] Settings — ports, paths, preferences
3.3 仪表盘页面¶
仪表盘是主要落地页,显示:
- 节点网格 — 为每个发现的 ESP32 节点显示卡片:
- IP 地址和主机名
- 固件版本(如有可用更新则显示更新指示)
- 节点 ID 和 TDM 时隙分配
- 边缘处理层级(raw / stats / vitals)
- 信号质量指示(最近 CSI 帧年龄)
- 健康状态(在线/离线/降级)
-
快速操作:OTA 更新、配置、查看日志
-
感知服务器面板 — 启动/停止按钮、端口配置、日志尾部
-
发现控制 — 扫描按钮、自动发现开关、网络范围过滤器
3.4 刷写固件页面¶
向导式流程:
- 选择端口 — 已检测到的串行端口下拉列表,包含芯片信息
- 选择固件 — 用于
.bin文件的文件选择器,或从内置构建中选择 - 配置 — 芯片类型、波特率、刷写模式
- 刷写 — 带阶段指示的进度条(连接、擦除、写入、校验)
- 配置 — 可选 NVS 配置表单(WiFi、目标 IP、TDM、边缘层级)
- 验证 — 显示启动日志的串行监视器,成功/失败指示
3.5 WASM 模块管理器页面¶
| 列 | 内容 |
|---|---|
| 模块 ID | 由节点自动分配 |
| 名称 | 上传的 .wasm 文件名 |
| 大小 | 模块大小(KB) |
| 状态 | 运行中 / 已停止 / 错误 |
| 节点 | 其运行的 ESP32 节点 |
| 操作 | 启动 / 停止 / 卸载 / 查看日志 |
上传面板:拖放 .wasm 文件,选择目标节点,上传按钮。
3.6 感知视图页面¶
通过 iframe 嵌入现有 Web UI(ui/),指向感知服务器的静态文件路由,或构建原生 React 组件以连接相同的 WebSocket API。优先采用原生方式,因为它允许:
- 与节点状态侧边栏更紧密集成
- 硬件管理与可视化之间共享状态
- 离线访问录制数据
关键可视化组件: - CSI 热图 — 随时间变化的子载波幅度 - 信号场 — 二维信号强度可视化 - 姿态骨架 — 检测到的人体关键点及连接 - 生命体征 — 实时呼吸频率和心率图表 - 活动分类 — 当前活动标签及置信度
3.7 Mesh 拓扑页面¶
显示力导向图: - 节点显示为圆形(颜色 = 健康状态,大小 = 边缘层级) - 可互相发现的节点之间的边 - 每个节点上的 TDM 时隙标签 - 同步状态指示(同步 / 漂移 / 丢失) - 点击节点可导航到其详情页
4. 平台特定注意事项¶
4.1 macOS¶
- 串行驱动签名:CP210x 和 CH340 驱动需要在“系统偏好设置 > 安全性”中由用户批准
- 应用签名:Tauri 应用必须签名并公证,才能分发到 App Store 之外
- USB 权限:除安装驱动外无需特殊权限
- CoreWLAN:感知服务器可以使用 CoreWLAN 进行 WiFi 扫描(ADR-025);桌面应用继承此能力
4.2 Windows¶
- COM 端口访问:Windows 分配 COM 端口号;应用通过 Windows 注册表或
SetupDiAPI 列出它们 - 驱动安装:必须安装 USB 转串行驱动(CP210x、CH340、FTDI);应用可检测缺失驱动并链接到下载
- 防火墙:感知服务器的 UDP 监听器可能触发 Windows 防火墙提示;应用应预配置规则或引导用户
- 代码签名:SmartScreen 信任需要 EV 证书;未签名应用会触发警告
4.3 Linux¶
- udev 规则:ESP32 串行端口(
/dev/ttyUSB*、/dev/ttyACM*)需要 udev 规则才能非 root 访问。应用捆绑了99-ruview-esp32.rules文件并提供安装选项: - AppImage/deb/rpm:Tauri 支持全部三种打包格式
- Wayland 与 X11:Tauri 使用 webkit2gtk,两者均可运行
5. 桌面 Crate 的 Cargo.toml¶
[package]
name = "wifi-densepose-desktop"
version.workspace = true
edition.workspace = true
description = "Tauri desktop frontend for RuView WiFi DensePose"
license.workspace = true
authors.workspace = true
[lib]
name = "wifi_densepose_desktop"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-shell = "2" # Sidecar process management
tauri-plugin-dialog = "2" # File picker dialogs
tauri-plugin-fs = "2" # Filesystem access
tauri-plugin-process = "2" # Process management
tauri-plugin-notification = "2" # Desktop notifications
# Workspace crates
wifi-densepose-hardware = { workspace = true }
wifi-densepose-config = { workspace = true }
wifi-densepose-core = { workspace = true }
# Serial port access
serialport = { workspace = true }
# ESP32 flashing (Rust-native, replaces esptool.py)
espflash = "3"
# Network discovery
mdns-sd = "0.11" # mDNS/DNS-SD service discovery
# HTTP client for OTA and WASM management
reqwest = { version = "0.12", features = ["json", "multipart", "stream"] }
# Async runtime
tokio = { workspace = true }
# Serialization
serde = { workspace = true }
serde_json = { workspace = true }
# Logging
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
# Time
chrono = { version = "0.4", features = ["serde"] }
6. Tauri 配置¶
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-config-schema/schema.json",
"productName": "RuView",
"version": "0.3.0",
"identifier": "net.ruv.ruview",
"build": {
"frontendDist": "../frontend/dist",
"devUrl": "http://localhost:5173",
"beforeDevCommand": "cd frontend && npm run dev",
"beforeBuildCommand": "cd frontend && npm run build"
},
"app": {
"windows": [
{
"title": "RuView - WiFi DensePose",
"width": 1280,
"height": 800,
"minWidth": 900,
"minHeight": 600
}
]
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"externalBin": ["sensing-server"],
"linux": {
"deb": { "depends": ["libwebkit2gtk-4.1-0"] },
"appimage": { "bundleMediaFramework": true }
},
"windows": {
"wix": { "language": "en-US" }
}
}
}
7. Tauri v2 能力(权限)¶
{
"identifier": "default",
"description": "RuView default capability set",
"windows": ["main"],
"permissions": [
"core:default",
"shell:allow-execute",
"shell:allow-open",
"dialog:allow-open",
"dialog:allow-save",
"fs:allow-read",
"fs:allow-write",
"process:allow-exit",
"notification:default"
]
}
8. 开发工作流¶
# Prerequisites
cargo install tauri-cli@^2
cd v2/crates/wifi-densepose-desktop/frontend
npm install
# Development (hot-reload frontend + Rust rebuild)
cd v2/crates/wifi-densepose-desktop
cargo tauri dev
# Production build
cargo tauri build
# Build sensing-server sidecar (must be done before tauri build)
cargo build --release -p wifi-densepose-sensing-server
# Copy to sidecar location:
# target/release/sensing-server -> crates/wifi-densepose-desktop/binaries/sensing-server-{arch}
9. 持久节点注册表¶
仅靠发现是短暂的——节点在广播时出现,在不广播时消失。一个持久本地注册表将发现转变为调和。
模式:
CREATE TABLE nodes (
mac TEXT PRIMARY KEY, -- e.g. "AA:BB:CC:DD:EE:FF"
last_ip TEXT, -- last known IP
last_seen INTEGER NOT NULL, -- Unix timestamp
firmware TEXT, -- e.g. "0.3.1"
chip TEXT DEFAULT 'esp32s3', -- esp32, esp32s3, esp32c3
mesh_role TEXT DEFAULT 'node', -- 'coordinator' | 'node' | 'aggregator'
tdm_slot INTEGER, -- assigned TDM slot index
capabilities TEXT, -- JSON: {"wasm": true, "ota": true, "csi": true}
friendly_name TEXT, -- user-assigned label
notes TEXT -- free-form notes
);
行为:
- 在发现广播时,向注册表执行 upsert(更新
last_ip、last_seen、firmware) - 仪表盘显示所有已注册节点,并调暗最近未看到的节点
- 用户可以按 MAC/IP 手动添加节点(适用于没有 mDNS 的网络)
- 将注册表导出/导入为 JSON,用于跨机器的设备群管理
- 随时间跟踪节点健康历史(正常运行时间、上次 OTA、错误计数)
这意味着桌面应用在重启之间记住网格,这对于节点可能暂时离线的现场部署至关重要。
10. OTA 安全门 — 滚动更新¶
网格部署无法容忍所有节点同时重启。OTA 子系统包含一种滚动更新模式,以保持感知连续性:
#[derive(Serialize, Deserialize)]
pub struct BatchOtaConfig {
/// Update strategy
pub strategy: OtaStrategy,
/// Max nodes updating concurrently
pub max_concurrent: usize,
/// Delay between batches (seconds)
pub batch_delay_secs: u64,
/// Abort if any node fails
pub fail_fast: bool,
}
#[derive(Serialize, Deserialize)]
pub enum OtaStrategy {
/// Update one node at a time, wait for it to rejoin mesh
Sequential,
/// Update non-adjacent TDM slots to maintain coverage
TdmSafe,
/// Update all nodes simultaneously (development only)
Parallel,
}
TdmSafe 策略:
- 按 TDM 时隙索引对节点排序
- 先更新偶数时隙节点(时隙 0、2、4...)
- 等待每个节点重启并重新加入网格(通过信标验证)
- 然后更新奇数时隙节点(时隙 1、3、5...)
- 任何时刻相邻节点都不会同时离线
UI 流程:
- 用户选择目标固件 + 目标节点
- 应用显示更新前差异(每个节点的当前版本与新版本)
- 每个节点都有进度条,状态为:
queued → uploading → rebooting → verifying → done - 中止按钮会停止剩余更新,但不会回滚已完成的更新
- 更新后健康检查确认所有节点都在感知
11. 插件架构(未来)¶
这款桌面工具正悄然成为 RuView 的控制平面。一旦它管理发现、固件、OTA、WASM、感知和网格拓扑,插件扩展性就成为必然:
- 固件管理 今天 → 集群编排 明天
- WASM 上传 今天 → 边缘模块市场 明天
- 感知视图 今天 → 活动分类仪表盘 明天
Tauri 命令表面应围绕这一发展轨迹进行设计:
- 命令按限界上下文分组(已完成)
- 每个上下文都可以通过加载额外的 Tauri 插件进行扩展
- 节点注册表成为所有插件的单一事实来源
- 事件总线(Tauri 的
emit/listen)提供跨插件通信
这并不意味着在阶段 1 中构建插件系统。它意味着保持架构对此开放:没有硬编码视图,状态通过注册表流动,命令具有类型且经过版本化。
12. 安全注意事项¶
-
PSK 存储:OTA PSK 令牌通过
tauri-plugin-stronghold或平台原生凭据存储保存在操作系统钥匙串中,绝不保存在明文配置文件中。 -
串口访问:Tauri 的能力系统会限制前端可以调用的命令。串口访问只能通过类型化的
flash_firmware和provision_node命令使用,而不是原始串口 I/O。 -
网络请求:OTA 和 WASM 管理命令只与本地网络中的节点通信。除更新检查(可选)外,应用不会发起外部网络请求。
-
固件校验:在烧录前,应用会校验固件二进制文件头(ESP32 镜像魔数、分区表偏移),以防止变砖。
-
WASM 签名验证:桌面应用可以使用本地存储的 Ed25519 密钥对在上传前对 WASM 模块进行签名,以补充节点侧验证(ADR-040)。
13. 实施阶段¶
| 阶段 | 范围 | 工作量 | 优先级 |
|---|---|---|---|
| 阶段 1:骨架 | Tauri 项目脚手架、工作区集成、带 React 的基础窗口 | 1 周 | P0 |
| 阶段 2:发现 | 串口列表、UDP/mDNS 节点发现、带节点卡片的仪表盘 | 1 周 | P0 |
| 阶段 3:烧录 | espflash 集成、带进度事件的固件烧录向导 | 1 周 | P0 |
| 阶段 4:服务器 | 侧车感知服务器启动/停止、日志查看器、状态面板 | 1 周 | P1 |
| 阶段 5:OTA | 带 PSK 认证的 HTTP OTA、批量更新、版本比较 | 1 周 | P1 |
| 阶段 6:配置 | 通过串口进行 NVS 读写、配置表单、mesh 配置文件 | 1 周 | P1 |
| 阶段 7:WASM | 模块上传/列表/启动/停止、拖放、按模块日志 | 1 周 | P2 |
| 阶段 8:感知 | WebSocket 集成、实时信号图表、姿态叠加 | 2 周 | P2 |
| 阶段 9:Mesh 视图 | 力导向拓扑图、TDM 时隙可视化、同步状态 | 1 周 | P2 |
| 阶段 10:打磨 | 应用签名、自动更新、udev 规则安装器、入门向导 | 1 周 | P3 |
单个开发者的总预估工作量:约 11 周。
影响¶
积极影响¶
- 单一操作界面 — 在一个应用中完成所有硬件管理、感知和可视化
- 无 Python 依赖 — 使用 Rust 原生
espflash替代esptool.py进行固件烧录 - 替代 6 个以上 CLI 工具 — 烧录、配置、OTA、WASM 管理、服务器控制、可视化
- 对非开发人员友好 — GUI 替代 CLI 标志和 curl 命令
- 跨平台 — 一套代码库支持 Windows、macOS、Linux
- 工作区集成 — 与感知服务器共享类型、配置和硬件 crate
- 二进制体积小 — 约 15-20 MB,而 Electron 等效应用约 150 MB
消极影响¶
- 新增前端依赖 — 在 Rust 工作区中引入 Node.js/npm 构建步骤
- Tauri 版本变动 — Tauri v2 较新;其 API 稳定性尚未在大规模使用中验证
- Linux 上的 webkit2gtk — 依赖系统 webview 版本;旧发行版可能带有过时的 webkit
- espflash 限制 —
espflashcrate 可能不支持esptool.py处理的所有芯片变体或烧录模式;需要回退到捆绑的 Python - 维护面扩大 — 新增约 5,000 行 TypeScript 和约 2,000 行 Rust
风险¶
| 风险 | 可能性 | 影响 | 缓解措施 |
|---|---|---|---|
| espflash 无法烧录所有 ESP32 变体 | 中 | 高 | 捆绑 esptool.py 作为回退 sidecar |
| Tauri v2 破坏性变更 | 低 | 中 | 固定到特定 Tauri 版本;在专用 PR 中更新 |
| 在 macOS Sequoia 及更高版本上串口访问失败 | 中 | 中 | 在最新 macOS 上测试;记录驱动程序要求 |
| Linux 上 webkit2gtk 版本不匹配 | 中 | 低 | 在 deb/rpm 依赖中设置最低版本 |
| 侧车感知服务器启动失败 | 低 | 中 | 检测失败并显示手动启动说明 |
参考资料¶
- Tauri v2 文档:https://v2.tauri.app/
- espflash crate:https://crates.io/crates/espflash
- mdns-sd crate:https://crates.io/crates/mdns-sd
- ADR-012:ESP32 CSI 传感器 Mesh
- ADR-039:ESP32 边缘智能
- ADR-040:WASM 可编程感知
- ADR-044:配置工具增强
- ADR-166:质量工程 — 安全加固(从 ADR-050 重新编号)
- ADR-051:感知服务器分解
firmware/esp32-csi-node/— ESP32 固件源码firmware/esp32-csi-node/provision.py— 当前配置脚本v2/crates/wifi-densepose-sensing-server/— 感知服务器v2/crates/wifi-densepose-hardware/— 硬件 crateui/— 现有 Web UI
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 wi/RuView