0

I would like to find out what are the available objects and interfaces in the bluez dbus bus. I wrote a simple python script to list all the bus names in the dbus session.

import dbus
for service in dbus.SystemBus().list_names():
    print(service)

However, I am only interested in the interfaces inside bluez /org/bluez. How can a python script be written to list down the interfaces inside /org/bluez?

I am using Ubuntu 14.04 and python 2.7

guagay_wk
  • 26,337
  • 54
  • 186
  • 295

1 Answers1

1

You can try this:

system_bus = dbus.SystemBus()
objectManager = system_bus.get_object('org.bluez', '/')
om_iface = dbus.Interface(objectManager, 'org.freedesktop.DBus.ObjectManager')

ifacelist = om_iface.GetManagedObjects()

Where ifacelist is a Dict of {ObjectPath, Dictof{String, Variant}}}

Jorge Martinez
  • 1,221
  • 8
  • 16
  • 1
    I got the following error. What are some possibilities of what went wrong? Thanks. `dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "GetManagedObjects" with signature "" on interface "org.freedesktop.DBus.ObjectManager" doesn't exist` – guagay_wk May 15 '15 at 01:48
  • Which version of bluez do you have? – Jorge Martinez May 15 '15 at 05:10
  • Ubuntu 14.04 is using Bluez 4.XX. I think it is 4.101 http://www.ubuntuupdates.org/package/core/trusty/main/base/bluez – guagay_wk May 15 '15 at 05:13
  • 1
    Oops my solution works with bluez 5. See http://www.bluez.org/bluez-5-api-introduction-and-porting-guide/ – Jorge Martinez May 15 '15 at 05:15