# dreampiggy/nearby-recovery-eacs architecture

> Architecture diagram of the GitHub repository dreampiggy/nearby-recovery-eacs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dreampiggy/nearby-recovery-eacs
- Repository: https://github.com/dreampiggy/nearby-recovery-eacs

## Overview

这是一个 macOS Nearby Recovery 研究原型，包含三个独立命令行客户端：观察 BLE 广播、认证探测或读取恢复配置，以及在严格匹配配置后发送一次 EACS 命令。用户根据扫描结果手动选择设备；客户端之间没有自动调用关系。README 还记录了设备端 EACS 状态转换及一次实机结果，但这些固件逻辑不在仓库中。关系仅依据 README；未提供源代码摘录，因此不推断客户端内部实现。

Main entry points: [`src/nearby_basicconfig.m`](https://github.com/dreampiggy/nearby-recovery-eacs/blob/main/src/nearby_basicconfig.m) (配置读取客户端), [`src/nearby_eacs.m`](https://github.com/dreampiggy/nearby-recovery-eacs/blob/main/src/nearby_eacs.m) (EACS 客户端), [`src/nearby_probe.m`](https://github.com/dreampiggy/nearby-recovery-eacs/blob/main/src/nearby_probe.m) (BLE 广播探测)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_observation["广播观察"]
  node_probe["BLE 广播探测<br/>[nearby_probe.m]"]
end

subgraph group_configuration["认证与配置"]
  node_basicconfig["配置读取客户端"]
end

subgraph group_erase["独立抹除"]
  node_eacs_client["EACS 客户端<br/>[nearby_eacs.m]"]
  node_command_dispatch["EACS 命令分派"]
  node_obliterate_mark["擦除标记"]
  node_cleanup_reboot["清理并重启"]
  node_device_erase["系统擦除"]
  node_activation_lock["所有者激活锁"]
end

node_user(("操作者"))
node_nearby_ble["Nearby BLE"]
node_recovery_device["恢复设备"]
node_setupkit["私有 SetupKit"]

node_user -->|"运行扫描"| node_probe
node_probe -->|"观察广播"| node_nearby_ble
node_user -->|"运行探测或读取"| node_basicconfig
node_basicconfig -->|"执行 BLE 激活"| node_setupkit
node_basicconfig -->|"认证并读取配置"| node_recovery_device
node_user -->|"运行抹除"| node_eacs_client
node_eacs_client -->|"执行 BLE 激活"| node_setupkit
node_eacs_client -->|"校验配置并发送 EACS"| node_recovery_device
node_recovery_device -->|"分派命令"| node_command_dispatch
node_command_dispatch -->|"触发擦除标记"| node_obliterate_mark
node_obliterate_mark -->|"成功后清理重启"| node_cleanup_reboot
node_cleanup_reboot -->|"重启后执行擦除"| node_device_erase
node_device_erase -->|"进入激活锁"| node_activation_lock

click node_probe "https://github.com/dreampiggy/nearby-recovery-eacs/blob/main/src/nearby_probe.m"
click node_basicconfig "https://github.com/dreampiggy/nearby-recovery-eacs/blob/main/src/nearby_basicconfig.m"
click node_eacs_client "https://github.com/dreampiggy/nearby-recovery-eacs/blob/main/src/nearby_eacs.m"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_probe toneBlue
class node_basicconfig toneAmber
class node_eacs_client,node_command_dispatch,node_obliterate_mark,node_cleanup_reboot,node_device_erase,node_activation_lock toneMint
class node_user,node_nearby_ble,node_recovery_device,node_setupkit toneIndigo
```

## Components

### 广播观察

- [BLE 广播探测](https://github.com/dreampiggy/nearby-recovery-eacs/blob/main/src/nearby_probe.m): `src/nearby_probe.m`

### 认证与配置

- [配置读取客户端](https://github.com/dreampiggy/nearby-recovery-eacs/blob/main/src/nearby_basicconfig.m): `src/nearby_basicconfig.m`

### 独立抹除

- [EACS 客户端](https://github.com/dreampiggy/nearby-recovery-eacs/blob/main/src/nearby_eacs.m): `src/nearby_eacs.m`
- **EACS 命令分派**
- **擦除标记**
- **清理并重启**
- **系统擦除**
- **所有者激活锁**

### Other components

- **操作者**
- **Nearby BLE**
- **恢复设备**
- **私有 SetupKit**

## Connections

- 操作者 → BLE 广播探测: 运行扫描 (evidence: `README.md`)
- BLE 广播探测 → Nearby BLE: 观察广播 (evidence: `README.md`)
- 操作者 → 配置读取客户端: 运行探测或读取 (evidence: `README.md`)
- 配置读取客户端 → 私有 SetupKit: 执行 BLE 激活 (evidence: `README.md`)
- 配置读取客户端 → 恢复设备: 认证并读取配置 (evidence: `README.md`)
- 操作者 → EACS 客户端: 运行抹除 (evidence: `README.md`)
- EACS 客户端 → 私有 SetupKit: 执行 BLE 激活 (evidence: `README.md`)
- EACS 客户端 → 恢复设备: 校验配置并发送 EACS (evidence: `README.md`)
- 恢复设备 → EACS 命令分派: 分派命令 (evidence: `README.md`)
- EACS 命令分派 → 擦除标记: 触发擦除标记 (evidence: `README.md`)
- 擦除标记 → 清理并重启: 成功后清理重启 (evidence: `README.md`)
- 清理并重启 → 系统擦除: 重启后执行擦除 (evidence: `README.md`)
- 系统擦除 → 所有者激活锁: 进入激活锁 (evidence: `README.md`)
