Skip to content

Commit

Permalink
Obtaining the device path from BlueZ instead of creating it by hand.
Browse files Browse the repository at this point in the history
Hopefully fixes #150
  • Loading branch information
hbldh committed Jun 30, 2020
1 parent c267f9a commit 39fba6a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Changed
* Using CBManagerState constants from pyobj instead of integers.
* Improved handling of the txdbus connection to avoid hanging of disconnection
clients in BlueZ backend. Fixes #216, #219 & #221.
* #150 hints at the device path not being possible to create as is done in the `get_device_object_path` method.
Now, we try to get it from BlueZ first. Otherwise, use the old fallback.

Removed
~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion bleak/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-

__version__ = "0.6.5a7"
__version__ = "0.6.5a8"
13 changes: 11 additions & 2 deletions bleak/backends/bluezdbus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,23 @@ async def connect(self, **kwargs) -> bool:
timeout = kwargs.get("timeout", self._timeout)
discovered = await discover(timeout=timeout, device=self.device, loop=self.loop)

# Issue 150 hints at the device path not being possible to create as
# is done in the `get_device_object_path` method. Try to get it from
# BlueZ instead.
# Otherwise, use the old fallback and hope for the best.
bluez_devices = list(filter(lambda d: d.address.lower() == self.address.lower(), discovered))
if bluez_devices:
self._device_path = bluez_devices[0].details["path"]
else:
# TODO: Better to always get path from BlueZ backend...
self._device_path = get_device_object_path(self.device, self.address)

self._reactor = get_reactor(self.loop)

# Create system bus
self._bus = await txdbus_connect(self._reactor, busAddress="system").asFuture(
self.loop
)
# TODO: Build this device path differently. Need to get it from BlueZ backend for proper path...
self._device_path = get_device_object_path(self.device, self.address)

def _services_resolved_callback(message):
iface, changed, invalidated = message.body
Expand Down

0 comments on commit 39fba6a

Please sign in to comment.