Skip to content

Commit 0a2adfd

Browse files
committed
Move HCI setup to new adafruit_airlift library
1 parent 116a4ae commit 0a2adfd

File tree

2 files changed

+8
-122
lines changed

2 files changed

+8
-122
lines changed

adafruit_ble/__init__.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -156,13 +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 _bleio.adapter:
160-
# Try setting up an onboard HCI BLE adapter.
161-
from adafruit_ble import hci # pylint: disable=import-outside-toplevel
162-
163-
adapter = hci.create_adapter()
164-
_bleio.set_adapter(adapter) # pylint: disable=no-member
165-
self._adapter = adapter
159+
"""If no adapter is supplied, use the built-in _bleio.adapter, if available.
160+
If not, see if there's an onboard HCI adapter available that could be used.
161+
"""
162+
if adapter is None and _bleio.adapter is None:
163+
raise RuntimeError("No adapter available")
164+
self._adapter = adapter or _bleio.adapter
166165
self._current_advertisement = None
167166
self._connection_cache = {}
168167

@@ -190,6 +189,7 @@ def start_advertising(
190189
if scan_response:
191190
scan_response_bytes = bytes(scan_response)
192191

192+
# pylint: disable=unexpected-keyword-arg
193193
# Remove after 5.x is no longer supported.
194194
if (
195195
sys.implementation.name == "circuitpython"
@@ -351,4 +351,4 @@ def address_bytes(self):
351351
@property
352352
def advertising(self):
353353
"""The advertising state"""
354-
return self._adapter.advertising
354+
return self._adapter.advertising # pylint: disable=no-member

adafruit_ble/hci.py

-114
This file was deleted.

0 commit comments

Comments
 (0)