Method "DefaultAdapter" with signature "" on interface "org.bluez.Manager" doesn't exist in raspberry pi 3

Question:

I wanted to use dbus in the raspberry pi with this simple script

bus = dbus.SystemBus()
obj = bus.get_object('org.bluez', '/')
print "object"
print obj
manager = dbus.Interface(obj,'org.bluez.Manager')
obj = bus.get_object('org.bluez',manager.DefaultAdapter())
print "Manager"
print manager
print "object"
print obj

But when i am try to run that code i am getting

Traceback (most recent call last):
  File "/home/pi/Desktop/hangul-recog/tools/DisableICT.py", line 350, in <module>
    ge = Paint()
  File "/home/pi/Desktop/hangul-recog/tools/DisableICT.py", line 125, in __init__
    self.test()
  File "/home/pi/Desktop/hangul-recog/tools/DisableICT.py", line 280, in test
    obj = bus.get_object('org.bluez',manager.DefaultAdapter())
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "DefaultAdapter" with signature "" on interface "org.bluez.Manager" doesn't exist

I am using bluez 5.43 version. I have checked for the solution but no luck.

What should i do?

Thanks in advance.

Asked By: Anik Islam Abhi

||

Answers:

I had the same issue with org.bluez.Manager

There is also org.freedesktop.DBus.ObjectManager. This should get you those objects (from https://github.com/Douglas6/blueplayer/blob/master/blueplayer.py):

import dbus

SERVICE_NAME = "org.bluez"
OBJECT_IFACE =  "org.freedesktop.DBus.ObjectManager"
ADAPTER_IFACE = SERVICE_NAME + ".Adapter1"
DEVICE_IFACE = SERVICE_NAME + ".Device1"
PROPERTIES_IFACE = "org.freedesktop.DBus.Properties"
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.freedesktop.DBus.ObjectManager")
objects = manager.GetManagedObjects()
for path, ifaces in objects.iteritems():
    adapter = ifaces.get(ADAPTER_IFACE)
    if adapter is None:
        continue
    obj = bus.get_object(SERVICE_NAME, path)
    adapter = dbus.Interface(obj, ADAPTER_IFACE)
Answered By: Jamie Hlusko