Merge pull request #4 from BlockedPath/main
This commit is contained in:
@@ -14,7 +14,7 @@ This file is for future Claude Code sessions to bootstrap quickly. Read this fir
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
```text
|
||||
main.cpp — setup(), loop(), button polling (left→Space, right→Shift+Tab, mid→cycle), rotation flash
|
||||
display_cfg.h — pin defines, extern object decls
|
||||
ui.{h,cpp} — 3-screen UI (splash, usage, bluetooth); splash is touch-toggled, usage↔bluetooth via mid button
|
||||
@@ -92,11 +92,13 @@ See `~/.claude/projects/.../memory/` files for persistent context (user is an em
|
||||
Bash daemon (`daemon/claude-usage-daemon.sh`) reads OAuth token, polls Anthropic API, sends JSON over BLE GATT. Run with `systemctl --user start claude-usage-daemon`. The unit file's `ExecStart` is the absolute path to the script — repoint it when switching between the worktree and the main checkout.
|
||||
|
||||
**Discovery & resilience:**
|
||||
|
||||
- Connects by name (`"Claude Controller"`) on first run, caches resolved MAC at `~/.config/claude-usage-monitor/ble-address`. ESP32 BLE addresses are factory-burned per-chip, so swapping any board invalidates the cache.
|
||||
- On connect failure: cache is dropped AND device is removed from bluez (`bluetoothctl remove`) so the next scan won't re-pick a dead MAC. Multi-candidate scans pick `head -1` and let the failure cycle converge.
|
||||
- `POLL_INTERVAL=60`, `TICK=5`. Inner loop wakes every 5s to detect disconnects fast; polls Anthropic when 60s elapsed OR when ESP fires a refresh request.
|
||||
|
||||
**GATT characteristics on service `4c41555a-...0001`:**
|
||||
|
||||
- `...0002` RX — daemon writes JSON usage payload here.
|
||||
- `...0003` TX — firmware notifies ack/nack (daemon doesn't subscribe).
|
||||
- `...0004` REQ — firmware fires `0x01` notify in `onSubscribe` if `has_received_data` is false. Daemon subscribes via `setsid bash -c "stdbuf -oL dbus-monitor … | awk …"`; awk drops a flag file the inner loop picks up. See the `feedback_dbus_monitor_pipe` memory for the three subtle gotchas (pipe buffering, busctl-exits race, `wait` blocking on pipeline jobs).
|
||||
|
||||
Reference in New Issue
Block a user