Skip to content

blissha: resolve adapter by MAC via BlueZ D-Bus, not sysfs - #2

Merged
viggfred merged 2 commits into
mainfrom
fix/adapter-dbus-resolve
Jul 7, 2026
Merged

blissha: resolve adapter by MAC via BlueZ D-Bus, not sysfs#2
viggfred merged 2 commits into
mainfrom
fix/adapter-dbus-resolve

Conversation

@viggfred

@viggfred viggfred commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Pinning a blind to an adapter by its Bluetooth MAC failed on Ubuntu 26.04 with "no bluetooth adapter found", even for the correct, present controller. The resolver read the address from /sys/class/bluetooth/hciN/address, but that kernel/BlueZ no longer exposes an address file under the adapter's sysfs dir, so every adapter was skipped. (It would also fail in a container that mounts the D-Bus socket but not host sysfs.)

Resolve the MAC through BlueZ over D-Bus instead (ObjectManager → org.bluez.Adapter1.Address), which is authoritative and matches how the bridge already drives the adapters. The sysfs read is kept as a fallback for older systems where D-Bus enumeration isn't available. Matching remains case-insensitive (it always was — EqualFold), so this was never a case issue.

Adds unit tests for the sysfs matcher (fixture dir) and the object-path→hciN helper; the live D-Bus path is exercised on-device.

Viggo Fredriksen added 2 commits July 7, 2026 00:19
Pinning a blind to an adapter by its Bluetooth MAC failed on Ubuntu 26.04 with
"no bluetooth adapter found", even for the correct, present controller. The
resolver read the address from /sys/class/bluetooth/hciN/address, but that
kernel/BlueZ no longer exposes an `address` file under the adapter's sysfs dir,
so every adapter was skipped. (It would also fail in a container that mounts the
D-Bus socket but not host sysfs.)

Resolve the MAC through BlueZ over D-Bus instead (ObjectManager →
org.bluez.Adapter1.Address), which is authoritative and matches how the bridge
already drives the adapters. The sysfs read is kept as a fallback for older
systems where D-Bus enumeration isn't available. Matching remains
case-insensitive (it always was — EqualFold), so this was never a case issue.

Adds unit tests for the sysfs matcher (fixture dir) and the object-path→hciN
helper; the live D-Bus path is exercised on-device.
With one dongle per room, the two blinds scanned concurrently on different
adapters and the second blind never connected: it failed with "scan was stopped
unexpectedly" and then "Operation already in progress" on every retry.

Root cause is in tinygo/x/bluetooth (v0.15.0) Linux scanning: Scan watches the
org.bluez.Adapter1 "Discovering" property but does not filter by adapter path,
so when one adapter's scan finds its device and stops discovery, a scan running
concurrently on a *different* adapter sees Discovering=false, aborts, and leaks
its StartDiscovery — leaving that adapter stuck "in progress".

Use a single shared scan mutex for all blinds (instead of one per adapter) so
only one BLE scan runs at a time across every adapter. Connects still run in
parallel and scans are brief, so the practical cost is negligible. Docs updated;
the ScanMutex contract now documents the cross-adapter hazard.
@viggfred
viggfred merged commit 936d971 into main Jul 7, 2026
2 checks passed
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