Re: Query BLE connected status?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The property is not on the Adapter1 interface but it is found on the
Device1 interface. Also note that you have to check for every object
under /org/bluez/hci0 if that one is connected. I don't think there is
a way to see if an adapter is connected or not. Here is an example of
getting the Connected property of all the devices.

#!/usr/bin/env python3

import dbus
import os
import sys

def get_managed_objects():
    bus = dbus.SystemBus()
    manager = dbus.Interface(bus.get_object("org.bluez", "/"),

"org.freedesktop.DBus.ObjectManager")
    return manager.GetManagedObjects()

def main():
    bus = dbus.SystemBus()

    objects = get_managed_objects()
    for path, ifaces in iter(objects.items()):
        dev = ifaces.get("org.bluez.Device1")
        if dev is None:
            continue

        props = dbus.Interface(bus.get_object("org.bluez", path),
                               "org.freedesktop.DBus.Properties")

        print(path, "Connected:", props.Get("org.bluez.Device1", "Connected"))

if __name__ == '__main__':
    main()

/Tobias
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux