diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ab51b831..f4024fc7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,6 +13,7 @@ and this project adheres to `Semantic Versioning None: # need to remove callbacks first, otherwise we get TxPower # and RSSI properties removed during stop which causes # incorrect advertisement data callbacks - self._advertisement_callbacks.remove(callback_and_state) + self._advertisement_callbacks[adapter_path].remove( + advertisement_callback + ) self._device_removed_callbacks.remove( device_removed_callback_and_state ) @@ -477,7 +465,9 @@ async def stop() -> None: return stop except BaseException: # if starting scanning failed, don't leak the callbacks - self._advertisement_callbacks.remove(callback_and_state) + self._advertisement_callbacks[adapter_path].remove( + advertisement_callback + ) self._device_removed_callbacks.remove(device_removed_callback_and_state) raise @@ -511,8 +501,7 @@ async def passive_scan( # error message. self._check_adapter(adapter_path) - callback_and_state = CallbackAndState(advertisement_callback, adapter_path) - self._advertisement_callbacks.append(callback_and_state) + self._advertisement_callbacks[adapter_path].append(advertisement_callback) device_removed_callback_and_state = DeviceRemovedCallbackAndState( device_removed_callback, adapter_path @@ -555,7 +544,9 @@ async def stop() -> None: # need to remove callbacks first, otherwise we get TxPower # and RSSI properties removed during stop which causes # incorrect advertisement data callbacks - self._advertisement_callbacks.remove(callback_and_state) + self._advertisement_callbacks[adapter_path].remove( + advertisement_callback + ) self._device_removed_callbacks.remove( device_removed_callback_and_state ) @@ -579,7 +570,9 @@ async def stop() -> None: except BaseException: # if starting scanning failed, don't leak the callbacks - self._advertisement_callbacks.remove(callback_and_state) + self._advertisement_callbacks[adapter_path].remove( + advertisement_callback + ) self._device_removed_callbacks.remove(device_removed_callback_and_state) raise @@ -1041,13 +1034,9 @@ def _run_advertisement_callbacks(self, device_path: str, device: Device1) -> Non Args: device_path: The D-Bus object path of the remote device. device: The current D-Bus properties of the device. - changed: A list of properties that have changed since the last call. """ - for callback, adapter_path in self._advertisement_callbacks: - # filter messages from other adapters - if adapter_path != device["Adapter"]: - continue - + adapter_path = device["Adapter"] + for callback in self._advertisement_callbacks[adapter_path]: callback(device_path, device.copy())