Skip to content

Instantly share code, notes, and snippets.

@stories2
Created April 4, 2021 08:15
Show Gist options
  • Save stories2/59b9fdfd82a0515fc6fe41931b445023 to your computer and use it in GitHub Desktop.
Save stories2/59b9fdfd82a0515fc6fe41931b445023 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment