Add BlueZ D-Bus backend for Linux desktop Bluetooth support#79
Merged
Conversation
Adds a new optional binding that talks to bluetoothd via the org.bluez
D-Bus API instead of the kernel HCI socket. Useful on desktop Linux
where the system Bluetooth stack owns the adapter and the HCI backend
needs root or fights with bluetoothd / desktop applets.
Backend covers basic GATT central use: scan (with UUID filter),
connect/disconnect, service / characteristic / descriptor discovery,
read, write (with and without response), notify/indicate. Raw HCI
handle I/O, custom scan parameters, and broadcast property changes
are not supported and surface as warnings/errors.
The HCI backend remains the default on Linux. Opt in with either
withBindings('dbus') or NOBLE_BINDINGS=dbus. dbus-next is added as
an optional dependency so non-Linux installs don't pull it.
Pulling dbus-next as an optionalDependency made it (and its transitive optional native dep usocket) install on macOS CI runners. With ~1100 extra lockfile lines and a vendored native install script, npm ci on macos-latest started exiting non-zero, taking the test job and the fail-fast'd Windows jobs with it. The dbus backend is Linux-only by definition, and the binding already prints a clear "Install it with: npm install dbus-next" message when the module is missing. Make users install dbus-next themselves; revert the lockfile churn so non-Linux CI is unaffected. README updated.
|
🎉 This PR is included in version 2.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
This PR adds a new D-Bus backend for noble that enables Bluetooth support on Linux desktop systems using BlueZ's D-Bus interface. This complements the existing HCI socket binding and provides a more stable, user-friendly alternative for desktop Linux environments.
Key Changes
New D-Bus Bindings Module (
lib/dbus/bindings.js): Complete implementation of the noble bindings interface using thedbus-nextlibrary to communicate with BlueZ via D-Bus. Includes:UUID Utilities (
lib/dbus/uuid.js): Helper functions for UUID normalization and expansion between Bluetooth short forms (16-bit, 32-bit) and full 128-bit UUIDs, plus MAC address and D-Bus device path conversions.Comprehensive Test Suite (
test/lib/dbus/bindings.test.js,test/lib/dbus/uuid.test.js): Full test coverage including:Integration: Updated
lib/resolve-bindings.jsto register the new 'dbus' binding type and addeddbus-nextas an optional dependency inpackage.json.Documentation: Updated README.md to document the new D-Bus binding option.
Notable Implementation Details
readHandle,broadcast) by emitting warnings.https://claude.ai/code/session_01MXwXDUiGpmLM3iTUb2GV99