mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-04 01:24:42 +08:00
a163324e1a
Trivially add the numbering suffix to org.bluez.Adapter according to the proposal for BlueZ 5.
40 lines
1.0 KiB
Python
Executable File
40 lines
1.0 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
from gi.repository import GObject
|
|
|
|
import dbus
|
|
import dbus.mainloop.glib
|
|
import bluezutils
|
|
|
|
def interfaces_added(path, interfaces):
|
|
if interfaces.get("org.bluez.Adapter1") != None:
|
|
print("Adapter with path %s added" % (path))
|
|
|
|
def interfaces_removed(path, interfaces):
|
|
if "org.bluez.Adapter1" in interfaces:
|
|
print("Adapter with path %s removed" % (path))
|
|
|
|
if __name__ == "__main__":
|
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
|
|
|
bus = dbus.SystemBus()
|
|
|
|
bus.add_signal_receiver(interfaces_added, bus_name="org.bluez",
|
|
dbus_interface="org.freedesktop.DBus.ObjectManager",
|
|
signal_name="InterfacesAdded")
|
|
|
|
bus.add_signal_receiver(interfaces_removed, bus_name="org.bluez",
|
|
dbus_interface="org.freedesktop.DBus.ObjectManager",
|
|
signal_name="InterfacesRemoved")
|
|
|
|
try:
|
|
path = bluezutils.find_adapter().object_path
|
|
print("Adapter found at path %s" % (path))
|
|
except:
|
|
print("No adapter found")
|
|
|
|
mainloop = GObject.MainLoop()
|
|
mainloop.run()
|