Skip to content

Commit 70b2f69

Browse files
authored
feat: allow BluetoothManager to be created with defaults (#129)
1 parent 7548f6a commit 70b2f69

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/habluetooth/manager.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ADAPTER_PASSIVE_SCAN,
2323
AdapterDetails,
2424
BluetoothAdapters,
25+
get_adapters,
2526
)
2627
from bluetooth_data_tools import monotonic_time_coarse
2728

@@ -138,8 +139,8 @@ class BluetoothManager:
138139

139140
def __init__(
140141
self,
141-
bluetooth_adapters: BluetoothAdapters,
142-
slot_manager: BleakSlotManager,
142+
bluetooth_adapters: BluetoothAdapters | None = None,
143+
slot_manager: BleakSlotManager | None = None,
143144
) -> None:
144145
"""Init bluetooth manager."""
145146
self._cancel_unavailable_tracking: asyncio.TimerHandle | None = None
@@ -164,8 +165,8 @@ def __init__(
164165
self._adapter_sources: dict[str, str] = {}
165166
self._allocations: dict[str, HaBluetoothSlotAllocations] = {}
166167
self._sources: dict[str, BaseHaScanner] = {}
167-
self._bluetooth_adapters = bluetooth_adapters
168-
self.slot_manager = slot_manager
168+
self._bluetooth_adapters = bluetooth_adapters or get_adapters()
169+
self.slot_manager = slot_manager or BleakSlotManager()
169170
self._cancel_allocation_callbacks = (
170171
self.slot_manager.register_allocation_callback(
171172
self._async_slot_manager_changed

0 commit comments

Comments
 (0)