Skip to content

Add an opt-in macOS BLE bench transport - #611

Draft
rafael2reis wants to merge 2 commits into
bitcraze:masterfrom
rafael2reis:feat/ble-bench-driver
Draft

rafael2reis wants to merge 2 commits into
bitcraze:masterfrom
rafael2reis:feat/ble-bench-driver

Conversation

@rafael2reis

@rafael2reis rafael2reis commented Oct 25, 2026 •

Copy link
Copy Markdown

Add an opt-in macOS BLE transport for bench inspection and telemetry without Crazyradio. Normal driver registration remains unchanged; init_drivers(enable_ble_driver=True) adds BLE, with Bleak installed only through the optional ble extra.

The driver validates the selected CoreBluetooth UUID/name and GATT profile, drains startup messages, and checks byte-exact 8/20/31-byte echo before cflib setup. It uses documented UP/DOWN framing, bounded queues and timeouts, health echoes, and a dedicated event-loop thread. BLE retry timing is adjusted without changing other transports. Log initialization avoids a global reset and cleanup targets only blocks successfully created by this session.

This initial version is always bench-only: flight/supervisor commands, parameter writes, raw-memory operations and bootloader payloads are blocked. There is no URI switch to enable flight. TOC/parameter reads and bounded TOC-backed logging are allowed. A short-circuit before retry scheduling prevents blocked requests from creating retry timers.

Validation:

  • Full cflib suite: 214 tests passed on Python 3.14.5.
  • Repository pre-commit checks passed.
  • The tests use a fake backend and do not require installed Bleak or Bluetooth hardware.
  • Real macOS 15.7.4 / Apple Silicon + Crazyflie 2.1: all 1–31 byte echo lengths, full log/parameter TOCs and values, three connections, 40 battery samples and confirmed STOP/DELETE cleanup. First uncached initialization was about 250 s; cached reconnects about 93 s. These are observations, not timing guarantees.

Corrected nRF UP framing is required; see bitcraze/crazyflie2-nrf-firmware#127. macOS is the only hardware-tested platform. The URI currently uses a CoreBluetooth UUID; Linux/Windows addressing, multiple devices and flight are not claimed supported. Service discovery does not authenticate the device. Scanning all registered drivers can still invoke radio and disable BLE on the drone; the BLE-only scanner is documented.

Maintainer feedback is requested on the initial platform scope, mandatory bench policy and location of transport-specific setup/timeout behavior. The separate updater/checksum experiment and hardware identifiers are not included.

This is a draft. Developed with OpenAI Codex assistance; hardware behavior was exercised on the contributor's Mac/Crazyflie. Draft pending contributor and maintainer review.

Review dependency: #613 is the small standalone codec prerequisite (2 files, 112 added lines). This driver branch includes identical codec files until that change is incorporated upstream. The wire codec and mandatory bench packet policy are now separate modules. For a direct comparison of the driver/policy changes without the shared codec, use git diff origin/feat/ble-crtp-codec..origin/feat/ble-bench-driver in the fork clone. The existing PR and commit history are preserved.

Validate GATT and packet integrity, isolate asynchronous BLE IO, and support bounded TOC-based telemetry with mandatory flight/write guards. Preserve existing transports and provide simulated integration tests and documentation.

Assisted-by: OpenAI Codex
Extract a standalone codec prerequisite for focused review. Keep policy in blepolicy, move framing tests into the CRTP suite, and document the dependency without changing the driver wire behavior.

Assisted-by: OpenAI Codex

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.

1 participant