Add --hci-id argument to python_ble_proxy#746
Open
2myaus wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to add a --hci-id <id> option to the Python matter-ble-proxy CLI, aligning it with the existing Node.js noble-based proxy by allowing selection of a specific Bluetooth adapter (e.g., hci0).
Changes:
- Adds
--hci-idto the Python BLE proxy CLI argument parser. - Extends the Bleak scanning backend to support selecting a BlueZ adapter via
BleakScanner(..., bluez={adapter: ...}).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| python_ble_proxy/matter_ble_proxy/cli.py | Adds --hci-id and threads it into the CLI entrypoint (currently not fully wired into the scanner). |
| python_ble_proxy/matter_ble_proxy/bleak_backend.py | Adds adapter-selection support to BleakScanSource via BlueZ scanner args. |
Comment on lines
+40
to
+45
| parser.add_argument( | ||
| "--hci-id", | ||
| default=None, | ||
| type=int, | ||
| help="Bluetooth adapter HCI ID (e.g., 0 for hci0)", | ||
| ) |
Note the OS/BLE backend limitation in the --hci-id argument description, and only pass bluez_args to BleakScanner if a hci id was provided
Comment on lines
+59
to
+68
| # Bleak only supports specifying a hci device on Linux with BlueZ; | ||
| # per https://github.com/hbldh/bleak/discussions/867 | ||
| if self._hci_device is not None: | ||
| bluez_args: BlueZScannerArgs = {"adapter": f"hci{self._hci_device}"} | ||
| self._scanner = BleakScanner( | ||
| detection_callback=self._on_detection, | ||
| bluez=bluez_args, | ||
| ) | ||
| else: | ||
| self._scanner = BleakScanner(detection_callback=self._on_detection) |
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.
This adds the
--hci-id <id>argument to the python matter-ble-proxy package.The argument is available on the nodejs noble-ble-proxy, but previously not on the python package