Add the device match check to find devices.

Leave the example only in the section it is used.
This commit is contained in:
Danny Staple
2023-01-19 23:04:02 +00:00
parent 7907a3fecf
commit ccb94f4091
5 changed files with 5 additions and 113 deletions
+5 -1
View File
@@ -7,7 +7,11 @@ async def run():
devices = await bleak.BleakScanner.discover(service_uuids=[ble_uuid])
print(f"Found {len(devices)} devices")
print([device.name for device in devices])
ble_device_info = [device for device in devices if device.name==ble_name][0]
matching_devices = [device for device in devices if device.name==ble_name]
if len(matching_devices) == 0):
print(f"Could not find robot at {ble_name}")
return
ble_device_info = matching_devices[0]
print(f"Found robot {ble_device_info.name}...")
asyncio.run(run())