Skip to content

Instantly share code, notes, and snippets.

@infirit
Last active December 6, 2016 15:29
Show Gist options
  • Select an option

  • Save infirit/d7750963235267cd3d41 to your computer and use it in GitHub Desktop.

Select an option

Save infirit/d7750963235267cd3d41 to your computer and use it in GitHub Desktop.
GDBus bluez adapter example
from gi.repository import Gio, GLib, GObject
proxy = Gio.DBusProxy.new_sync(
Gio.bus_get_sync(Gio.BusType.SYSTEM),
Gio.DBusProxyFlags.NONE,
None,
'org.bluez',
'/org/bluez/hci0',
'org.freedesktop.DBus.Properties')
def on_property_changed(proxy, sender, signal_name, param):
interface = param[0]
key, value = param[1].popitem()
path = proxy.get_object_path()
print('Got key "%s" with value "%s" on interface "%s" on path "%s"' % (key, value, interface, path))
sig = proxy.connect("g-signal", on_property_changed)
print(proxy.Get("(ss)", "org.bluez.Adapter1", "Alias"))
loop = GObject.MainLoop()
loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment