Skip to content

Commit b6ad8c9

Browse files
authored
Merge pull request #103 from dhalbert/hci
Add HCI support
2 parents 20f21e7 + fb8ca9b commit b6ad8c9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

adafruit_ble/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,12 @@ class BLERadio:
156156
It uses this library's `Advertisement` classes and the `BLEConnection` class."""
157157

158158
def __init__(self, adapter=None):
159-
if not adapter:
160-
adapter = _bleio.adapter
161-
self._adapter = adapter
159+
"""If no adapter is supplied, use the built-in `_bleio.adapter`.
160+
If no built-in adapter is available, raise `RuntimeError`.
161+
"""
162+
if adapter is None and _bleio.adapter is None:
163+
raise RuntimeError("No adapter available")
164+
self._adapter = adapter or _bleio.adapter
162165
self._current_advertisement = None
163166
self._connection_cache = {}
164167

@@ -186,6 +189,7 @@ def start_advertising(
186189
if scan_response:
187190
scan_response_bytes = bytes(scan_response)
188191

192+
# pylint: disable=unexpected-keyword-arg
189193
# Remove after 5.x is no longer supported.
190194
if (
191195
sys.implementation.name == "circuitpython"
@@ -347,4 +351,4 @@ def address_bytes(self):
347351
@property
348352
def advertising(self):
349353
"""The advertising state"""
350-
return self._adapter.advertising
354+
return self._adapter.advertising # pylint: disable=no-member

0 commit comments

Comments
 (0)