Skip to content

Bluetooth menu - #235

Open
sastraxi wants to merge 4 commits into
mainfrom
feat/bluetooth-menu
Open

Bluetooth menu#235
sastraxi wants to merge 4 commits into
mainfrom
feat/bluetooth-menu

Conversation

@sastraxi

@sastraxi sastraxi commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Adds a bluetooth sub-menu inside of the Wi-Fi menu (now renamed Wi-Fi & Devices).

image

Requires the pistomp-bluetooth package (see TreeFallSound/pi-gen-pistomp#40). Alternatively, manually unblock via rfkill and add the -E bluetooth daemon option.

Author checklist

  • Initial on-device testing
  • Exhaustive on-device testing
  • Remove plan markdown

sastraxi and others added 4 commits August 7, 2026 15:03
Pair, connect, and forget BLE-MIDI devices from the LCD. Reached from a
"Bluetooth..." footer button on the Wi-Fi menu, shown only when the board
has an adapter — Pi 3/4 hand the BT UART to DIN MIDI, so those users see
no mention of it.

modalapi/bluetooth/ mirrors modalapi/wifi/: a dbus-fast client owning an
asyncio thread, an org.bluez.Agent1 (NoInputNoOutput — without a
registered agent headless pairing cannot complete at all), stateless
verbs, and a BluetoothManager driving the shared CommandQueue.

Three findings from the hardware investigation shape the design:

- BlueZ purges unpaired LE device objects the instant discovery stops, so
  discovery is held open for as long as the nearby list is on screen and
  Pair() is issued against a live object while it runs. Discovery is a
  start/stop pair, not a blocking scan like wifi's.
- Trusting a device makes bluez auto-connect on sight, which then makes
  our own Pair() return InProgress. So: pair first, trust second, and
  treat InProgress as "wait for the running attempt", not a failure.
- Some devices (the EV-1-WL) refuse bonding, so a plain Disconnect drops
  them back to unpaired. The root list is therefore the union of bluez's
  paired set and our own known-device store, and a known-but-absent row
  says "press its button" rather than "Disconnected".

The menu also detects a bluetoothd running without -E and offers to
install pistomp-bluetooth, rather than pairing into a void that produces
no ALSA seq port.

CommandQueue moves to common/ so bluetooth doesn't depend on wifi. Menu
gains footer buttons and a real width parameter; max_width was dead code
(its clamp reassigned the same hardcoded 240). Existing menus keep that
width, the Bluetooth menu is wider.

HID input (pistomp/hid_controller.py) is deliberately not in this change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread docs/bluetooth-menu.md
- `Modhandler.poll_bluetooth()` next to `poll_wifi`, called from the `period % 200`
branch of `modalapistomp.py`

## HID input

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this has not been implemented. This is an exploration of how e.g. wireless presenters could be used to switch pedalboards / snapshots

Comment thread docs/bluetooth-menu.md
Comment on lines +377 to +387
### Not needed — do not carry these over

| `feat/bluetooth` change | Why not |
|---|---|
| `bluetooth-main.conf` (374 lines) | `main.conf` is a **dpkg conffile**; shipping a copy means owning it forever and taking a conffile conflict on every bluez upgrade. `-E` in the drop-in gets the same result with no ownership. |
| `BLUETOOTH_ENABLED` in `pistomp.conf` | The menu owns enable/disable at runtime. The flag is also first-boot-only, so it silently does nothing when edited later — a trap, not a feature. |
| `firstboot.sh` conditional enable/disable | Falls out with the flag. |
| `rfkill` package (+ the `00-packages-nr` comment) | The drop-in's `ExecStartPre` unblocks via sysfs, keyed on `type` = `bluetooth` so it doesn't depend on the rfkill index. |
| separate `bluetooth-rfkill-unblock.conf` | Folded into the single drop-in. |
| anything touching `hciuart.service` | `pi-bluetooth` is not installed, so the unit does not exist and the call is a no-op swallowed by `|| true`. Pi 5 attaches BT over serdev (`hci_uart` + `btbcm`, `hci0 Bus: UART`). |
| `debpkgs/mod-ui/debian/changelog` | Unrelated (session recording) — it rode along on the branch. |

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparison with previous BT draft impl

@rreichenbach rreichenbach left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Didn't actually try it.

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