Replies: 5 comments
-
It sounds like what you want is BleakScanner.find_device_by_filter(). FYI, filtering by address doesn't work on macOS, so if you were trying to make something that works cross platform, you should consider filters on something from the advertisement data instead. |
Beta Was this translation helpful? Give feedback.
-
That's equivalent to what I do at the moment - I was hoping to offload the
filtering to BlueZ
Pete Barlow
…On Wed, 8 Nov 2023, 00:02 David Lechner, ***@***.***> wrote:
It sounds like what you want is BleakScanner.find_device_by_filter()
<https://bleak.readthedocs.io/en/latest/api/scanner.html#bleak.BleakScanner.find_device_by_filter>
.
FYI, filtering by address doesn't work on macOS, so if you were trying to
make something that works cross platform, you should consider filters on
something from the advertisement data instead.
—
Reply to this email directly, view it on GitHub
<#1447 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADXMVZYOYRKWFP6BJJ3FCKDYDLDXRAVCNFSM6AAAAAA7A6SMUWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBQGUZTONZRHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
If the device in question has a service UUID in the advertising data, you ca use the |
Beta Was this translation helpful? Give feedback.
-
Unsure if this is relevant to this issue - but I found that on bluez the
Example: import asyncio
from bleak import BleakScanner, AdvertisementData, BLEDevice
SERVICE_UUID = "0e140000-0af1-4582-a242-773e63054c68"
async def detection_callback(device: BLEDevice, advertisement_data: AdvertisementData):
print(f"Found device: {device.address} (device.name)")
print(f"Matches service UUID: {SERVICE_UUID in advertisement_data.service_uuids}")
async def discover():
scanner = BleakScanner(
detection_callback=detection_callback,
use_bdaddr=False,
service_uuids=[SERVICE_UUID],
)
await scanner.start()
await asyncio.sleep(20)
asyncio.run(discover()) Results:
This doesn't happen on Windows in my tests. |
Beta Was this translation helpful? Give feedback.
-
Not relevant, so i moved it to a new issue. |
Beta Was this translation helpful? Give feedback.
-
bluetoothctl -v
) in case of Linux: bluetoothctl: 5.66Description
Trying to only scan for devices from a particular manufacturer, so I used what I thought was the correct argument to the scanner:
async with BleakScanner(callback, bluez={"Pattern": "A4:C1:38"}) as scanner:
A4:C1:38 is the start of the MAC addresses that I am iterested in. However all devices seem to be passed back to the callback
Beta Was this translation helpful? Give feedback.
All reactions