Skip to content

Commit 11c48c1

Browse files
Add option to access Bluetooth addresses on macOS (#51)
1 parent 32be383 commit 11c48c1

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ repos:
9393
entry: env MYPYPATH=src mypy
9494
args: []
9595
additional_dependencies:
96-
- bleak
96+
- bleak>=0.20.0
9797
- bluetooth-numbers
9898
- rich
9999
- textual>=0.14.0

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Requirements file for ReadTheDocs, check .readthedocs.yml.
22
# To build the module reference correctly, make sure every external package
33
# under `install_requires` in `setup.cfg` is also listed here!
4-
bleak>=0.19.0
4+
bleak>=0.20.0
55
bluetooth-numbers>=1.0.0,<2.0
66
furo
77
sphinx>=3.2.1

docs/usage.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ You can find all command-line arguments by running HumBLE Explorer with the ``--
3030
Bluetooth adapter (e.g. hci1 on Linux)
3131
-s {active,passive}, --scanning-mode {active,passive}
3232
Scanning mode (default: active)
33+
-m, --macos-use-address
34+
Use Bluetooth address instead of UUID on macOS
3335
3436
By default, HumBLE Explorer scans for BLE advertisements using your operating system's default Bluetooth adapter. You can change this with the ``-a ADAPTER`` option.
3537

3638
Also, by default HumBLE Explorer does *active scanning*. For every device the program finds, it requests extra information, with a ``SCAN_REQ`` packet directed at that device. The addressed device responds with a ``SCAN_RSP`` advertisement, which is also called *scan response data*. What data is returned for a ``SCAN_RSP`` packet depends on the type of device. It could be its device name, or manufacturer-specific data, or something else. If you want HumBLE Explorer to use *passive scanning*, use the ``-s passive`` option. The program then doesn't send ``SCAN_REQ`` packets, so devices don't respond with scan response data.
3739

40+
On macOS, users normally don't get access to the Bluetooth addresses of devices, but to a UUID. With the `-m` option, you get the actual Bluetooth address.
41+
3842
User interface
3943
--------------
4044

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ package_dir =
5656
# For more information, check out https://semver.org/.
5757
install_requires =
5858
bluetooth-numbers>=1.0.0,<2.0
59-
bleak>=0.19.0
59+
bleak>=0.20.0
6060
importlib-metadata; python_version<"3.8"
6161
textual>=0.14.0
6262

src/humble_explorer/__main__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ def parse_args(args: list[str]) -> Namespace:
6868
default="active",
6969
choices=("active", "passive"),
7070
)
71+
parser.add_argument(
72+
"-m",
73+
"--macos-use-address",
74+
action="store_true",
75+
help="Use Bluetooth address instead of UUID on macOS",
76+
)
77+
7178
return parser.parse_args(args)
7279

7380

src/humble_explorer/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def __init__(self, cli_args: Namespace) -> None:
6767
self.scanner_kwargs["bluez"] = BlueZScannerArgs(
6868
filters={"DuplicateData": True}
6969
)
70+
elif system() == "Darwin":
71+
self.scanner_kwargs["cb"] = {"use_bdaddr": cli_args.macos_use_address}
7072

7173
# Configure Bluetooth adapter
7274
self.scanner_kwargs["adapter"] = cli_args.adapter

0 commit comments

Comments
 (0)