Feat: Peripheral status and integration #140

Merged
zach merged 17 commits from feat/peripheral-integration into main 2026-08-16 18:03:42 +02:00
Showing only changes of commit 33c9432390 - Show all commits
+9 -12
View File
2
@@ -255,7 +255,7 @@ def _start_hotplug_watcher(on_hotplug: Callable[[], None]):
return None return None
debounce_lock = threading.Lock() debounce_lock = threading.Lock()
debounce_state = {"timer": None} debounce_state: dict[str, threading.Timer | None] = {"timer": None}
DEBOUNCE_SECONDS = 0.5 DEBOUNCE_SECONDS = 0.5
def _fire(): def _fire():
@@ -381,6 +381,7 @@ class _ListenerRegistry:
continue continue
listener = ListenerClass(obj, self._touch_and_notify) listener = ListenerClass(obj, self._touch_and_notify)
to_join = None
if obj.isDevice: if obj.isDevice:
ident = None ident = None
@@ -476,7 +477,7 @@ class _ListenerRegistry:
"device" if dev_info.isDevice else "receiver", "device" if dev_info.isDevice else "receiver",
) )
if "to_join" in locals(): if to_join is not None:
try: try:
to_join.join(timeout=1.0) to_join.join(timeout=1.0)
except Exception: except Exception:
@@ -565,9 +566,13 @@ def _iter_open_devices():
for dev_info in base.receivers_and_devices(): for dev_info in base.receivers_and_devices():
try: try:
if dev_info.isDevice: if dev_info.isDevice:
d = device.create_device(base, dev_info) d = device.create_device(base, dev_info) # pyright: ignore[reportArgumentType]
if d is not None:
yield d
else: else:
d = receiver.create_receiver(base, dev_info) d = receiver.create_receiver(base, dev_info) # pyright: ignore[reportArgumentType]
if d is not None:
yield from d
except OSError as e: except OSError as e:
if e.errno == 13: if e.errno == 13:
logger.error( logger.error(
@@ -583,14 +588,6 @@ def _iter_open_devices():
logger.exception("failed opening %s", dev_info) logger.exception("failed opening %s", dev_info)
continue continue
if d is None:
continue
if d.isDevice:
yield d
else:
yield from d
def _to_device_battery(dev, battery) -> DeviceBattery | None: def _to_device_battery(dev, battery) -> DeviceBattery | None:
if battery is None: if battery is None: