fix(esp_prov): update devices tuple usage due to API deprecations

- a recent commit fixed the API deprecations,
and the BLEDevice object now needs to be accessed through a tuple.
- thus the changes were made in the code wherein the object was used,
but updating the usage in the condition when de
vname is not None got skipped.
This commit is contained in:
harshal.patil 2023-08-22 14:44:38 +05:30
parent 7f85830a3b
commit 37303266f0
No known key found for this signature in database
GPG Key ID: 5B5EC97C35B9A2E5

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD # SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
@ -84,16 +84,16 @@ class BLE_Bleak_Client:
devices = list(discovery.values()) devices = list(discovery.values())
self.devname = devices[select - 1][0].name self.devname = devices[select - 1][0].name
found_device = devices[select - 1][0] found_device = devices[select - 1]
else: else:
for d in devices: for d in devices:
if d.name == self.devname: if d[0].name == self.devname:
found_device = d found_device = d
if not found_device: if not found_device:
raise RuntimeError('Device not found') raise RuntimeError('Device not found')
uuids = devices[select - 1][1].service_uuids uuids = found_device[1].service_uuids
# There should be 1 service UUID in advertising data # There should be 1 service UUID in advertising data
# If bluez had cached an old version of the advertisement data # If bluez had cached an old version of the advertisement data
# the list of uuids may be incorrect, in which case connection # the list of uuids may be incorrect, in which case connection
@ -103,7 +103,7 @@ class BLE_Bleak_Client:
self.srv_uuid_adv = uuids[0] self.srv_uuid_adv = uuids[0]
print('Connecting...') print('Connecting...')
self.device = bleak.BleakClient(found_device.address) self.device = bleak.BleakClient(found_device[0].address)
await self.device.connect() await self.device.connect()
# must be paired on Windows to access characteristics; # must be paired on Windows to access characteristics;
# cannot be paired on Mac # cannot be paired on Mac