Repository navigation
bledev v1, part 2: bleak, the BLE REPL, Improv, board_config.ble - #81
Merged
Merged
Conversation
bledev.bleak is the central-only CPython backend. bledev.repl serves the MicroPython REPL over nus behind a WebREPL-style password, from the BLE IRQ so it keeps working at the prompt. bledev.improv is both sides of the Improv Wi-Fi standard. Advertisements can carry service data, which Improv needs. Two mpble fixes the laptop found: notifications that arrive before subscribe() are no longer queued, and an MTU exchanged before MicroPython reports the connection (Windows does this) is no longer lost, which had held every notification to a Windows central at 20 bytes. gatt_central.py and nus_client.py now run on a laptop too.
…stence runs The 19 board_peripherals ble() factories return bledev.mpble.get(), falling back to the raw radio without bledev. MPBLE answers every bluetooth.BLE method, and irq() runs beside aioble's handler; raw advertising no longer trips aioble's peripheral IRQ or leaks its connection record. coex_server.py and tcp_pull.py measure Wi-Fi and BLE on one S3; the numbers and the bleak, REPL and Improv notes are in docs/bledev*.md.
This was referenced Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The second half of bledev v1 (docs/ble.md §3 in the workspace repo), stacked on #78. Merge #78 first; this PR's base is
bledev-core.What you can do with it
bledev.bleak.BleakBLE()is the CPython backend (Windows, Linux, macOS; central only), andnus.connect()works from it.bledev.repl.start(password=...)inmain.py, then connect withbledev.repl.connect(ble, password)or any Nordic UART terminal (send an empty line forPassword:). Opt-in only; nothing starts it at boot.improv.serve(ble)on the board,improv.provision(ble, ssid, password)from a laptop or another board. ESPHome/WLED/Home Assistant speak the same protocol.board_config.bleis a bledev adapter on all 19 boards with able()role, and still answers everybluetooth.BLEmethod, so raw-API code keeps working. Without bledev installed, the factory returns the raw radio as before.Gates, all run on 2026-09-24 against the two S3s (LCD-7 serving, T-Embed or the laptop connecting)
gatt_central.pythrough bleak): PASS. Planted peripheral (skips notification 7): FAIL, as it must.123 * 456= 56088; wrong password (sent with code that would create/pwned) getsAccess denied, a hang-up and no prompt, and/pwnednever appears; Ctrl-C interruptswhile True. PASS, 3/3 repeats plus the final run. Planted "accept any password": FAIL on five checks, including the code running.secrets.pyon the board and provisioned the LCD-7, which had been taken off Wi-Fi first; the LCD-7 reported provisioned withhttp://192.168.1.139/, and the laptop pinged it. PASS, twice.Two mpble bugs the laptop found, both fixed here:
_IRQ_MTU_EXCHANGEDbefore_IRQ_CENTRAL_CONNECTwhen the central exchanges the MTU at once (Windows does). aioble drops it, so the board sent 20-byte notifications on a 247 link. Laptop downstream went from 19 to 49 KB/s with the fix.subscribe()were queued on a board central, against the contract. The over-the-air check for it fails on the old code.Wi-Fi and BLE on one S3 (numbers in
docs/bledev-internals.md): an idle Wi-Fi association roughly halves nus upstream (77-84 KB/s down to 36-62), and a Wi-Fi stream alongside takes it to 22-39; downstream and echo lose about a fifth. BLE's cost to Wi-Fi throughput could not be measured: the LCD-7 sits at -74 to -82 dBm, where Wi-Fi alone varied from 13 to 155 KB/s between runs.Not done:
subscribe: disconnectedon the second connection 1.5 s after the first closed). The four runs since passed.