In this blog we will jump back to use GetManagedObjects method to find the list of Bluetooth devices which are currently present in all the Adapters. This sample in continuation to set property blog will help us understand more about Bluetooth devices and Adapters.
Code:
In this example above we are using GetManagedObjects method in org.freedesktop.DBus.ObjectManager interface to get all the objects for a specific interface. Unlike Properties interface, ObjectManager interface is specific to a service.
To recall,
- org.freedesktop.DBus.Properties – available in all the object paths to manage properties of the interfaces.
- org.freedesktop.DBus.ObjectManager – available in all the services. For example, org.bluez, org.ofono
GetManagedObjects method in this interface is specifically used to get all the objects (objects paths, interfaces, properties, property values) for a service. We are using it for “org.bluez” here.
More importantly, the output format for GetManagedObjects is “(a{oa{sa{sv}}})“. This signature is already explained here, in which we are filtering only the object paths with Device1 interface (Bluetooth devices). We will examine more details about the interface in our next blog for Bluetooth scanning.
After filtering the Device1 interface, all the properties of the device is printed. You can find the list of possible properties for a device here in Bluez tree.
dbus-send:
We can get the same output using dbus-send using the following command,
dbus-send –system –print-reply –type=method_call –dest=’org.bluez’ ‘/’ org.freedesktop.DBus.ObjectManager.GetManagedObjects
3 Comments
[…] far we have seen ways to get Adapter properties, set the properties and also to list the devices using GetManagedObjects. To get started with real Bluetooth operation in action we need to […]
[…] to at least see the Polar sensor, I ran c code written by Parthiban Nallathambi at http://www.linumiz.com: https://www.linumiz.com/bluetooth-list-devices-using-gdbus/. Providing this for credit and […]
[…] to at least see the Polar sensor, I ran c code written by Parthiban Nallathambi at http://www.linumiz.com: https://www.linumiz.com/bluetooth-list-devices-using-gdbus/. Providing this for credit and […]