From ec074d16918ca19054ea01660015de5537710811 Mon Sep 17 00:00:00 2001 From: Devan Lai Date: Wed, 12 May 2021 15:40:14 -0700 Subject: [PATCH 1/3] winrt: replace get_discovered_devices Bring the winrt backend in line with other backends now that get_discovered_devices is replaced by discovered_devices. --- bleak/backends/winrt/scanner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bleak/backends/winrt/scanner.py b/bleak/backends/winrt/scanner.py index 619ac803..1812220c 100644 --- a/bleak/backends/winrt/scanner.py +++ b/bleak/backends/winrt/scanner.py @@ -172,7 +172,8 @@ def set_scanning_filter(self, **kwargs): # TODO: Handle AdvertisementFilter parameters self._advertisement_filter = kwargs["AdvertisementFilter"] - async def get_discovered_devices(self) -> List[BLEDevice]: + @property + def discovered_devices(self) -> List[BLEDevice]: found = [] for event_args in list(self._devices.values()): new_device = self._parse_event_args(event_args) From 3f2a3399b5e5459c6dfcfa36643021e6756390de Mon Sep 17 00:00:00 2001 From: Devan Lai Date: Wed, 12 May 2021 15:41:16 -0700 Subject: [PATCH 2/3] winrt: fix assert on 128-bit service UUID Convert to bytes before passing in data to the UUID constructor --- bleak/backends/winrt/scanner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bleak/backends/winrt/scanner.py b/bleak/backends/winrt/scanner.py index 1812220c..507691c2 100644 --- a/bleak/backends/winrt/scanner.py +++ b/bleak/backends/winrt/scanner.py @@ -99,7 +99,7 @@ def _received_handler( # 0x21 is service data with 128-bit UUID for section in event_args.advertisement.get_sections_by_type(0x21): data = bytearray(CryptographicBuffer.copy_to_byte_array(section.data)) - service_data[str(UUID(bytes=data[15::-1]))] = data[16:] + service_data[str(UUID(bytes=bytes(data[15::-1])))] = data[16:] # Use the BLEDevice to populate all the fields for the advertisement data to return advertisement_data = AdvertisementData( From 8999f64747556100cbc29808f573c8711b514a2c Mon Sep 17 00:00:00 2001 From: Devan Lai Date: Wed, 12 May 2021 15:42:15 -0700 Subject: [PATCH 3/3] winrt: fix advertisement filter typo --- bleak/backends/winrt/scanner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bleak/backends/winrt/scanner.py b/bleak/backends/winrt/scanner.py index 507691c2..96854446 100644 --- a/bleak/backends/winrt/scanner.py +++ b/bleak/backends/winrt/scanner.py @@ -135,7 +135,7 @@ async def start(self): if self._signal_strength_filter is not None: self.watcher.signal_strength_filter = self._signal_strength_filter if self._advertisement_filter is not None: - self.watcher._advertisement_filter = self._advertisement_filter + self.watcher.advertisement_filter = self._advertisement_filter self.watcher.start()