Skip to content

Add an optional NimBLE control transport - #158

Open
Funkelfetisch wants to merge 1 commit into
MoonModules:mainfrom
Funkelfetisch:codex/moonlight-ble-transport
Open

Funkelfetisch wants to merge 1 commit into
MoonModules:mainfrom
Funkelfetisch:codex/moonlight-ble-transport

Conversation

@Funkelfetisch

@Funkelfetisch Funkelfetisch commented Oct 25, 2026 •

Copy link
Copy Markdown

Controllers outside Wi-Fi range need an encrypted control channel. This adds an optional native NimBLE peripheral with a bounded 512-byte line reassembler, GATT identity/state/command attributes, pairing and bond support, and non-blocking scheduler exchange. Desktop, Teensy and BLE-disabled ESP32 builds share the unavailable-target implementation.

This is the transport step: the caller owns startup, identity and request dispatch. Shipping firmware defaults stay unchanged; state-document dispatch and scheduled group commands follow separately. The change is based on abcdaec9 and stays within the contribution limit: 399 added lines across ten files.

Validation:

  • GCC 13 Debug: 2,832 C++ cases, 179,292 assertions; maximum-size/fragmented input, backpressure, NUL, overflow, batching and disconnect reset are covered.
  • Desktop production target and 17 scenarios pass; 18 hardware scenarios are skipped.
  • ESP-IDF 6.1 / ESP32-S3 builds pass with BLE disabled and with NimBLE enabled in a local generated sdkconfig. No shipping sdkconfig fragment is changed.
  • All 139 specs, code ratchets, header documentation and strict documentation build pass. Clang 20 function-effects measurement is unavailable on this GCC host. Vale's repository-wide ratchet reports existing NegatedHeading/SelfReference drift in files byte-identical to upstream; the added-lines check only flags the standard Just Works association-model name as an advisory.
  • Before extraction, the HELIO integration on an ESP32-S3/222-pixel RGBW device passed Android bonded/encrypted commands, three Wi-Fi-off/on cycles, and a saved-Wi-Fi-off reboot followed by bonded BLE reconnection/control and BLE restoration of Wi-Fi. R/G/B/native warm white/mixed RGB were camera-checked; 31 animation clips completed with scene restoration. Several integration scenes reduced their layer buffer under RAM pressure, so those clips do not establish full-resolution optical acceptance; that separate core/product issue is being pinned and corrected. That bench image uses f030e3f8 plus the integration; this standalone transport-only application was not flashed. The extraction shares fallback definitions and splits parser/identity validation; hardware results are not claimed for a byte-identical PR image.

Current-upstream hardware follow-up: an ESP32-S3 N8/no-PSRAM product build on abcdaec9 containing this unchanged transport commit f5a244a9 is now installed by application OTA. The existing Android bond reconnects and executes encrypted RGBW commands; three Wi-Fi-off/on cycles, including commands without LAN, pass without restart or a panic record. Actual embedded-dashboard checks at 390/1280 pixels also pass. This exercises the transport commit in the private product integration; the standalone transport-only test image remains compile-only. The saved-off reboot result above belongs to the earlier prototype; that reboot is not repeated on the new image while USB recovery is disconnected.

LE Secure Connections uses the Just Works association model without MITM protection. Hardware integration evidence covers one controller, not measured multi-device timing. KPI data was collected without live serial capture; GCC Debug measurements are not a comparison against an equivalent committed reference build, and generated metrics are excluded per contribution policy.

Codex authored and extracted this contribution at Veit's explicit request after the BLE bench passed. No independent human review is claimed.

Allow encrypted control requests without an IP connection through a bounded BLE peripheral transport. The caller owns startup, public identity and request dispatch.

KPI: 256lights | Desktop:7603KB | tick:5136/29/8/9/70/123/9/13/9/1/104us(FPS:194/34482/125000/111111/14285/8130/111111/76923/111111/1000000/9615) | src:345(88512) | test:258(60816) | functions-over:346
Commit: src +334/-0 lines | test +58/-0 lines | duplicated lines 3285 -> 3285 (+0)

Core:
- Add a 512-byte line reassembler with backpressure and rejected-input recovery, plus a native NimBLE peripheral with encrypted attributes, persistent-bond support and non-blocking scheduler exchange.
- Share unavailable-target definitions across desktop, Teensy and BLE-disabled ESP32 builds.

Tests:
- Pass 2,832 GCC 13 Debug C++ cases and 179,292 assertions, including fragmented writes, maximum length, overflow, NUL, batching and reset; 17 desktop scenarios pass, 18 hardware scenarios skip.
- Compile ESP32-S3 with BLE disabled and with a validation-only NimBLE-enabled generated sdkconfig; shipping defaults remain unchanged.

Docs/CI:
- Document the optional transport, GATT identifiers, framing and security contract; strict docs and header-documentation checks pass.

Reviews:
- Self-review split parser/start validation and shared platform stubs to preserve the existing complexity and duplication counts; no independent human review is claimed.
- GCC cannot measure Clang 20 function effects. Vale reports pre-existing NegatedHeading/SelfReference drift in files byte-identical to upstream; added lines have only its advisory on the standard Just Works association-model name.
- KPI figures are this GCC Debug host's measurements and are not a comparison with an equivalent committed reference build; generated metrics are excluded under contribution policy. Live device KPI capture was disabled.
- Codex authored and extracted this contribution at Veit's explicit request. Hardware integration testing used the HELIO prototype before extraction, not this standalone transport-only application.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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