Closed chadrockey closed 2 years ago
I think I would like to better understand the issue before I start making changes.
The exception this code was trying to catch (UnknownProperty
) is when you request a property but it is not on the interface. This was necessary because some values are optional on BlueZ D-Bus interfaces and this was a simple way to query those values.
The exception you are getting (InvalidArgs
) is reporting something different I believe. dbus_prop_obj.Get(dbus_iface, prop_name)
is reporting that one of the values passed to it is not of the type it expects.
If my hypothesis is correct then I believe it is correct to throw an exception. Could you please report back what the value and type of the two values being passed to dbus_prop_obj.Get
are.
Ah sorry for forgetting that. I’m actually getting it when I try to print device.name in an on_connect function. That’s how I found that original issue via search.
It’s a little line like: print(device.name connected and has device.address), but the .name member is what is causing the issue.
I believe this is the line with the information you requested:
https://github.com/ukBaz/python-bluezero/blob/main/bluezero/device.py#L75
@chadrockey I've done a fix. Did you want to check it. If it is OK I'll merge and do a new release.
Looks like it works! Thanks!
I see this now when the situation happens:
print("Connected to " + str(ble_device.name) + " (" + str(ble_device.address) + ")")
Connected to None (MAC:MAC:MAC:MAC)
Thanks for checking.
FYI: Often ble_device.alias
is a better property to look at rather than name
as BlueZ tends to do a better job of making sure that is a somewhat useful value.
This looks to have been resolved and released so closing
I'm seeing an incomplete solution with an uncaught exception from https://github.com/ukBaz/python-bluezero/pull/286
I'm seeing the issue caused by this line: https://github.com/ukBaz/python-bluezero/blob/main/bluezero/dbus_tools.py#L392
The issue could be resolved by changing the function similar to the following, but I don't understand why I'm seeing a different type of dbus exception. Is it worth catching all of the dbus exceptions and returning the default if there's any error?