-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
For some reason, I randomly hit following error and no clue how it happens.
From error message, I guess it's because of some random events that old version of bleak can't handle properly. I made some minor changes to use the latest bleak and it works well. As my knowledge of entire code base is limited, I'm not sure if it works well for other part of the code. Attached is diff.
Traceback (most recent call last):
File "technic_4x4.py", line 38, in <module>
start(system)
File "/home/fxie/dev/venv/lego/lib/python3.6/site-packages/bricknil-0.9.3-py3.6.egg/bricknil/bricknil.py", line 214, in start
File "/home/fxie/dev/venv/lego/lib/python3.6/site-packages/bricknil-0.9.3-py3.6.egg/bricknil/bleak_interface.py", line 52, in run
File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "/home/fxie/dev/venv/lego/lib/python3.6/site-packages/bricknil-0.9.3-py3.6.egg/bricknil/bleak_interface.py", line 65, in asyncio_loop
File "/home/fxie/dev/venv/lego/lib/python3.6/site-packages/bricknil_bleak-0.3.1-py3.6.egg/bleak/backends/bluezdbus/discovery.py", line 167, in discover
returnSignature='a{sv}').asFuture(loop)
txdbus.error.RemoteError: org.freedesktop.DBus.Error.UnknownObject: Method "GetAll" with signature "s" on interface "org.freedesktop.DBus.Properties" doesn't existDiffs
diff --git a/bricknil/ble_queue.py b/bricknil/ble_queue.py
index b32179a..0e85d20 100644
--- a/bricknil/ble_queue.py
+++ b/bricknil/ble_queue.py
@@ -1,11 +1,11 @@
-# Copyright 2019 Virantha N. Ekanayake
-#
+# Copyright 2019 Virantha N. Ekanayake
+#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -117,9 +117,9 @@ class BLEventQ(Process):
def _check_devices_for(self, devices, name, manufacturer_id, address):
"""Check if any of the devices match what we're looking for
-
+
First, check to make sure the manufacturer_id matches. If the
- manufacturer_id is not present in the BLE advertised data from the
+ manufacturer_id is not present in the BLE advertised data from the
device, then fall back to the name (although this is unreliable because
the name on the device can be changed by the user through the LEGO apps).
@@ -168,11 +168,11 @@ class BLEventQ(Process):
devices = await self.ble.out_queue.get() # Wait for discovered devices
await self.ble.out_queue.task_done()
# Filter out no-matching uuid
- devices = [d for d in devices if str(uart_uuid) in d.uuids]
+ devices = [d for d in devices if str(uart_uuid) in d.metadata['uuids']]
# NOw, extract the manufacturer_id
for device in devices:
- assert len(device.manufacturer_data) == 1
- data = next(iter(device.manufacturer_data.values())) # Get the one and only key
+ assert len(device.metadata['manufacturer_data']) == 1
+ data = next(iter(device.metadata['manufacturer_data'].values())) # Get the one and only key
device.manufacturer_id = data[1]
else:
devices = self.ble.find_devices(service_uuids=[uart_uuid])
@@ -221,7 +221,7 @@ class BLEventQ(Process):
try:
ble_id = uuid.UUID(hub.ble_id) if hub.ble_id else None
except ValueError:
- # In case the user passed in a
+ # In case the user passed in a
self.message_info(f"ble_id {hub.ble_id} is not a parseable UUID, so assuming it's a BLE network addresss")
ble_id = hub.ble_id
@@ -234,7 +234,7 @@ class BLEventQ(Process):
device = await self.ble.out_queue.get()
await self.ble.out_queue.task_done()
hub.ble_id = self.device.address
- self.message_info(f'Device advertised: {device.characteristics}')
+ self.message_info(f'Device advertised: {device.services.characteristics}')
hub.tx = (device, hub.char_uuid) # Need to store device because the char is not an object in Bleak, unlike Bluefruit library
# Hack to fix device name on Windows
if self.device.name == "Unknown" and hasattr(device._requester, 'Name'):
diff --git a/setup.py b/setup.py
index 411f139..df31a47 100644
--- a/setup.py
+++ b/setup.py
@@ -80,7 +80,7 @@ setup (
include_package_data = True,
packages = packages,
install_requires = required + ['pyobjc ; sys.platform == "darwin"',
- 'bricknil-bleak ; sys.platform != "darwin"'],
+ 'bleak ; sys.platform != "darwin"'],
dependency_links = dependency_links,
entry_points = {
'console_scripts': [
Metadata
Metadata
Assignees
Labels
No labels