Skip to content

E4 Android 双通道:BLE + 网络中继并行(BR-1.1/1.3,队伍码不上网) - #12

Merged
webergithub merged 1 commit into
masterfrom
claude/quirky-gates-p9q3du
Aug 5, 2026
Merged

webergithub merged 1 commit into
masterfrom
claude/quirky-gates-p9q3du

Conversation

@webergithub

Copy link
Copy Markdown
Owner

E4 客户端 Android 侧——跟车"超 BLE 距离即失效"(G-NET-1)在 Android 上闭环。

内容

  • MeshBus.send() 只算一次密文,BLE 发完整信封帧、网络只发 roomId(team)+kind+base64(密文)——队伍码明文绝不出设备(BR-1.2)
  • 收帧共用 dispatchSealed():用本机队伍码解密、MAC 不过即丢,网络侧房间哈希碰撞被自然丢弃
  • NetTransport.kt(OkHttp WebSocket):relay-join 带 roomId+token、指数退避重连、静默降级;relayUrl 空 = 纯蓝牙(BR-1.4,等同今日行为)。用上了此前从未使用的 INTERNET 权限(解决 KI-10)
  • BR-1.3 双通道去重免费:业务层本已幂等(聊天/语音按 mid、位置按设备覆盖、回执用 Set),已文档说明
  • cloudCount 与 BLE peerCount 分开跟踪(BR-1.5 数据层)
  • MeshCrypto.roomId 与 meshcrypto.mjs 对齐

验证

  • mesh-fixture #16:57 项断言全绿(新增 Android roomId 域分离防漂移、NetTransport 只上传密文形状检查)
  • android-native-build #19:含 OkHttp 依赖编译通过并出 APK

未完(诚实边界)

  • iOS 网络通道待决策 D-2(iOS 12 无原生 WebSocket)
  • BR-1.5 "云端 M 台"可视化、真机跨距验收待做

🤖 Generated with Claude Code

https://claude.ai/code/session_01YSg1v3QaS7AYLHz4pfS3zh


Generated by Claude Code

Android now runs the network relay alongside BLE, closing the convoy
distance gap on the Android side. Design keeps the team code off the
wire entirely:
- MeshBus.send() computes the ciphertext once, then sends the full
  [kind|teamLen|team|cipher] frame over BLE AND relays just
  roomId(team)+kind+base64(cipher) over the network — team plaintext
  never leaves the device (BR-1.2)
- Receive path is shared: dispatchSealed() decrypts with the local
  team and drops on MAC failure, so a wrong-room hash collision from
  the network is discarded exactly like a wrong-team BLE frame
- NetTransport.kt (OkHttp WebSocket): relay-join with roomId+token,
  exponential-backoff reconnect, silent degradation — relayUrl empty
  means bluetooth-only, behaviourally identical to today (BR-1.4).
  Now uses the previously-dead INTERNET permission (resolves KI-10)
- BR-1.3 dedup is free: business layer is already idempotent (chat/
  voice by mid, position overwrites by device, acks are a Set), so a
  frame arriving via both channels is harmless — documented, no extra
  dedup layer
- cloudCount tracked separately from BLE peerCount (BR-1.5 data;
  visible UI wiring is the remaining Android piece)

MeshCrypto.roomId added for parity with meshcrypto.mjs. Fixture at 57
assertions: adds Android roomId salt drift check and a NetTransport
'ciphertext-only' shape check.

iOS network channel deferred pending decision D-2 (long-poll HTTPS vs
hand-rolled WebSocket — iOS 12 has no URLSessionWebSocketTask). ③
G-NET-1 marked in-progress.
@webergithub
webergithub merged commit 115ae6f into master Aug 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants