Skip to content

Improve controller connection stability and draw throughput - #87

Draft
Woodii1998 wants to merge 9 commits into
mainfrom
codex/optimize-controller-speed-stability
Draft

Improve controller connection stability and draw throughput#87
Woodii1998 wants to merge 9 commits into
mainfrom
codex/optimize-controller-speed-stability

Conversation

@Woodii1998

Copy link
Copy Markdown
Collaborator

What changed

  • Pre-arm serial ACK/probe waiters before writes, bound serial write/drain time, reject unsafe command batches before execution or persistence, and avoid releasing a timed-out request while its write is still draining.
  • Preserve the Bluetooth bond across ordinary resets; reserve virtual-cable unplug for explicit clear-peer, repair 48-byte HID replies and device-address reporting, and keep report counters monotonic.
  • Replace permissive firmware numeric parsing with strict full-token parsing and bounded cursor, wait, palette-slot, and color-grid inputs.
  • Bound disconnected-component planning above 2,048 components, interleave per-color configuration with drawing, remove redundant palette/official C commands while retaining W 500, and reduce interactive preview scale.
  • Persist recovery progress at segment checkpoints using serialized atomic writes; close cleanup/discard/claim races and serialize execution start/resume lifecycle reservations.

Why

The previous implementation had ACK registration and execution-lifecycle check/await races, ordinary resets could discard the host bond, malformed firmware parameters could reach long-running operations, checkerboards entered quadratic component ordering, multicolor plans repeated unnecessary selection commands, and recovery rewrote full JSON on every ACK.

Measured impact

  • 256×256 one-color checkerboard planning: 3,576.20 ms → 45.87 ms (about 78× faster).
  • Removing redundant selection commands saves an estimated 8.75 minutes at 84 colors and 13.31 minutes at 128 colors with the existing 65/45 ms timing profile.
  • Deterministic six-command/two-segment recovery scenario: 8 JSON writes → 4.
  • Studio preview requests now default to scale 2; server input is rounded and clamped to 1–4.

Verification

  • npm run ci:local:quick — desktop 122/122, flasher 8/8, TypeScript checks and production web build passed.
  • /tmp/friendmaker-platformio-venv/bin/platformio run -d firmware/esp32 -e esp32dev_wireless -e esp32dev_wireless_switch2 -e esp32dev_wireless_switch_lite — all three environments passed.
  • Focused recovery suite 24/24 and serial/firmware regression suite 22/22 passed during TDD iterations.
  • git diff --check fab94c6..HEAD and the credential-pattern scan passed.

Hardware follow-ups

  • Verify bond retention for both reset modes and explicit clear-peer timing on physical Switch, Switch Lite, and Switch 2.
  • Confirm reply-0x02 Bluetooth-address byte order and conservative congestion/drain behavior under real L2CAP pressure.
  • Validate standalone official-color recovery state on hardware.
  • This change deliberately keeps W 500, the standard profile's non-waiting send flags, and HID callbacks non-blocking. Truly interruptible long firmware operations and relative palette tracking remain separate HIL work.

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.

1 participant