Created
April 4, 2021 08:15
-
-
Save stories2/59b9fdfd82a0515fc6fe41931b445023 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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