-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added BleakDeviceNotFoundError #1022
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,12 @@ | |
|
||
import async_timeout | ||
from dbus_fast.aio import MessageBus | ||
from dbus_fast.constants import BusType, ErrorType | ||
from dbus_fast.constants import BusType, ErrorType, MessageType | ||
from dbus_fast.message import Message | ||
from dbus_fast.signature import Variant | ||
|
||
from ... import BleakScanner | ||
from ...exc import BleakDBusError, BleakError | ||
from ...exc import BleakDBusError, BleakError, BleakDeviceNotFoundError | ||
from ..characteristic import BleakGATTCharacteristic | ||
from ..client import BaseBleakClient, NotifyCallback | ||
from ..device import BLEDevice | ||
|
@@ -116,8 +116,8 @@ async def connect(self, dangerous_use_bleak_cache: bool = False, **kwargs) -> bo | |
self._device_info = device.details.get("props") | ||
self._device_path = device.details["path"] | ||
else: | ||
raise BleakError( | ||
"Device with address {0} was not found.".format(self.address) | ||
raise BleakDeviceNotFoundError( | ||
self.address, f"Device with address {self.address} was not found." | ||
) | ||
|
||
manager = await get_global_bluez_manager() | ||
|
@@ -176,6 +176,15 @@ def on_value_changed(char_path: str, value: bytes) -> None: | |
member="Connect", | ||
) | ||
) | ||
if ( | ||
reply is not None | ||
and reply.message_type == MessageType.ERROR | ||
and reply.error_name == ErrorType.UNKNOWN_OBJECT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure about the UnknownObject error? The documentation does not mention it: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. It is a standard D-Bus error. (Searching the issues in this repo for "UnknownObject" reveals quite a few hits) |
||
): | ||
raise BleakDeviceNotFoundError( | ||
self.address, | ||
f"Device with address {self.address} was not found.", | ||
) | ||
assert_reply(reply) | ||
|
||
self._is_connected = True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the messages in there to not break compatibility with programs which check for the text as described in #527 (comment)