altdesktop / python-dbus-next

🚌 The next great DBus library for Python with asyncio support
https://python-dbus-next.readthedocs.io/en/latest/
MIT License
187 stars 58 forks source link

Method "Connect" with signature "" on interface "org.bluez.Device1" doesn't exist #117

Open RobinRamael opened 2 years ago

RobinRamael commented 2 years ago

Hi,

I'm trying to use dbus-next to call the Connect method on the org.bluez.Device1 interface, and to get the properties on that interface. While this works with the old synchronous dbus bindings, and the specified object path and Connect method show up in d-feet and other dbus querying tools, I can't get call_connect, nor call_get_all("org.bluez.Device1) to work as expected:

import asyncio

from dbus_next import BusType
from dbus_next.aio import MessageBus

async def main():
    bus = await MessageBus(bus_type=BusType.SYSTEM).connect()

    intr = await bus.introspect("org.bluez", "/org/bluez/hci0/dev_38_18_4C_E9_00_D8")

    obj = bus.get_proxy_object("org.bluez", "/org/bluez/dev_38_18_4C_E9_00_D8", intr)

    device = obj.get_interface("org.bluez.Device1")
    device_props = obj.get_interface("org.freedesktop.DBus.Properties")

    assert 'call_connect' in device.__dict__
    # this crashes:
    print(await device.call_connect())
    # ...
      # File "/home/robin/devel/forkbeard/dbus_bt.py", line 18, in main
      #   print(await device.call_connect())
      # File "/nix/store/hzm87m47fyim0jkkip3nq50kllwmkcgj-python3-3.9.9-env/lib/python3.9/site-packages/dbus_next/aio/proxy_object.py", line 92, in method_fn
      #   BaseProxyInterface._check_method_return(msg, intr_method.out_signature)
      # File "/nix/store/hzm87m47fyim0jkkip3nq50kllwmkcgj-python3-3.9.9-env/lib/python3.9/site-packages/dbus_next/proxy_object.py", line 62, in _check_method_return
      #   raise DBusError._from_message(msg)
    # dbus_next.errors.DBusError: Method "Connect" with signature "" on interface "org.bluez.Device1" doesn't exist

    # and so does this:
    print(await device_props.call_get_all("org.bluez.Device1"))
    # ...
      # File "/home/robin/devel/forkbeard/dbus_bt.py", line 28, in main
      #   print(await device_props.call_get_all("org.bluez.Device1"))
      # File "/nix/store/hzm87m47fyim0jkkip3nq50kllwmkcgj-python3-3.9.9-env/lib/python3.9/site-packages/dbus_next/aio/proxy_object.py", line 92, in method_fn
      #   BaseProxyInterface._check_method_return(msg, intr_method.out_signature)
      # File "/nix/store/hzm87m47fyim0jkkip3nq50kllwmkcgj-python3-3.9.9-env/lib/python3.9/site-packages/dbus_next/proxy_object.py", line 62, in _check_method_return
      #   raise DBusError._from_message(msg)
    # dbus_next.errors.DBusError: Method "GetAll" with signature "s" on interface "org.freedesktop.DBus.Properties" doesn't exist

asyncio.run(main())

While dfeet shows:

screenshot-2022-05-04_11:25:58

Since I'm new to this library and dbus in general, the error probably lies with me, but I've been looking for a while and can't seem to figure it out.

In any case, thank you for your work on this library :)