setu सेतु

Accepted ADR 0004 · 2026-11-07

#4. Pair through an interactive bluetoothctl and its agent

#Context

Pairing a device that wants its code confirmed (most phones, speakers and computers with a screen) needs a BlueZ agent to answer "does 482913 match?". bluetoothctl pair <mac> run as a one-shot command registers bluetoothctl's own agent, which asks on a terminal nobody sees: pairing hung until BlueZ gave up, and the user never saw the code.

#Decision

setu pairs through bluetoothctl run interactively with pipes: it makes its agent the default one for the duration (default-agent), sends pair, trust and connect, and reads what bluetoothctl says in a thread. "Confirm passkey", "Passkey" (a code to type on a keyboard) and "Accept pairing" prompts become the pairing card's code and its They match / Cancel buttons; the answer goes back as yes / no. Errors (org.bluez.Error.*, br-connection-*) are turned into plain words. Connect, disconnect, remove and power stay one-shot commands.

A device that wants a PIN typed in on the computer (old headsets and keyboards) isn't handled: setu says so and points to bluetoothctl in a terminal.

#Consequences

All decisionsSource