Skip to content

Serve a companion over BLE from the workbench - #787

Open
A13xB0 wants to merge 2 commits into
mainfrom
feat-256-ble-serve
Open

A13xB0 wants to merge 2 commits into
mainfrom
feat-256-ble-serve

Conversation

@A13xB0

@A13xB0 A13xB0 commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

For #256.

  • bench.serve with kind ble (or serve BLE in the companion bench) serves the node over TCP, then runs the BlueZ peripheral against that port. The script is embedded in the binary. The peripheral exits when the port closes, so bench.drop also stops advertising. The endpoint shows as ble, with the advertised name as its address. Linux with BlueZ only, and it needs python3 with dbus and gi.

Two bugs in tools/ble/nus_peripheral.py would have stopped any real app working:

  • Framing. It passed the node's serial framing (> + LE16 length) straight through, split into 20-byte notifications. Over BLE, MeshCore and its clients carry exactly one frame per notification and one per write, with no prefix (SerialBLEInterface; MeshCIM's ble_mesh_transport.dart). It now deframes the node's output and frames each write with < + length. Covered by --selftest.
  • Timeout. The connect timeout stayed on the socket, so the read pump died after five quiet seconds.

Tested on this machine's adapter: --check registers, and a live test serves a native companion over BLE, sees the endpoint, drops it, and sees the peripheral go.

Not done: a phone actually connecting. That needs a second device. Pointing MeshCIM at MSIM-<node> is the check. Option A (MeshCore's own BLE transport in the emulator) and the WiFi transport stay open on the issue.

bench.serve kind=ble serves the node over TCP and runs the embedded
BlueZ peripheral against the port; it exits when the port closes.

The peripheral now deframes the node's '>' + length output into one
notification per frame and frames each write with '<' + length, as
MeshCore's BLE transport and its clients do. It also cleared the
connect timeout, which had ended the read pump after five quiet
seconds.

For #256.

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