hbldh / bleak

A cross platform Bluetooth Low Energy Client for Python using asyncio
MIT License
1.74k stars 292 forks source link

Service UUID filter does not apply to dict of discovered devices. #1576

Closed dlech closed 4 months ago

dlech commented 4 months ago

So, service_uuid filtering does work in Windows? I try to filter on: service_uuids = ['0000fef3-0000-1000-8000-00805f9b34fb'] like this:

...
service_uuids = ['0000fef3-0000-1000-8000-00805f9b34fb']
# Without filter
async with Scanner(service_uuids=None) as scanner:
    await asyncio.sleep(10)
    self.show_scan_result(
        scanner.discovered_devices_and_advertisement_data
    )
# With filter
async with Scanner(service_uuids=service_uuids) as scanner:
    await asyncio.sleep(10)
    self.show_scan_result(
        scanner.discovered_devices_and_advertisement_data
    )
...

(where show_scan_results is a method to display the results). However, I can't see a difference in the devices beeing found, and some of them don't have the service uuid in their AdvertisementData. Tested with 0.21.1 and 0.22.1 on Windows 10.

Am I doing something wrong or do I misunderstand the concept of service UUID filtering?

Originally posted by @MarkusPiotrowski in https://github.com/hbldh/bleak/issues/1534#issuecomment-2123497252

dlech commented 4 months ago

In https://github.com/hbldh/bleak/pull/1559, we missed that the filter should also apply to the list of discovered devices. Currently, it only applies to the detection callback.