Bluetooth: replace legacy hcitool with BlueZ DBus API#227
Open
Jonatas-Goncalves wants to merge 2 commits intochrippa:masterfrom
Open
Bluetooth: replace legacy hcitool with BlueZ DBus API#227Jonatas-Goncalves wants to merge 2 commits intochrippa:masterfrom
Jonatas-Goncalves wants to merge 2 commits intochrippa:masterfrom
Conversation
added 2 commits
April 25, 2026 10:32
* Use BlueZ DBus ObjectManager for device discovery. * Replace subprocess calls to hcitool with native dbus communication. * Implement discovery and adapter management via org.bluez interfaces. * Add support for identifying DualSense and newer controller variants. * Modernize Python syntax (f-strings, super()) and improve error handling. * Remove dependency on deprecated bluez-utils (hcitool). * Update socket management and class inheritance to modern Python standards. * Fix crashes on systems where hcitool is not available.
- Implemented UDP telemetry for battery levels on port 54321, allowing integration with external tray monitors. - Added graceful handling for 'BrokenPipeError' when reading Bluetooth MAC addresses via hidraw (fixes crashes on modern kernels). - Added try/except blocks for device grabbing to prevent initialization failures when the kernel driver is already active. - Reduced battery check interval to 5 seconds for more responsive reporting.
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.
Motivation:
hcitool and hciconfig are deprecated in BlueZ 5 and removed from many modern Linux distributions (like openSUSE, Fedora, and Arch).
Changes:
Switched from subprocess to python-dbus.
Implemented StartDiscovery and StopDiscovery via DBus.
Improved device filtering (now catches "DualSense" and "DualShock").
Refactored the main loop to be less aggressive and use time.sleep().