Skip to content

Instantly share code, notes, and snippets.

@dlech
Created April 7, 2020 23:08
Show Gist options
  • Save dlech/a6f1a6fd910f4858eebd6bb84cc00436 to your computer and use it in GitHub Desktop.
Save dlech/a6f1a6fd910f4858eebd6bb84cc00436 to your computer and use it in GitHub Desktop.
ev3dev-stretch D-Bus BlueZ example
#!/usr/bin/env python3
# ev3dev-stretch
# https://github.com/bluez/bluez/blob/5.43/doc/gatt-api.txt
# https://developer.gnome.org/gio/2.50/GDBusProxy.html
import gi
# gi.require_version("GLib", "2.0")
# gi.require_version("GObject", "2.0")
gi.require_version("Gio", "2.0")
# from gi.repository import GLib
# from gi.repository import GObject
from gi.repository import Gio
object_manager = Gio.DBusObjectManagerClient.new_for_bus_sync(
Gio.BusType.SYSTEM,
Gio.DBusObjectManagerClientFlags.NONE,
"org.bluez",
"/",
)
for obj in object_manager.get_objects():
# device = obj.get_interface("org.bluez.Device1")
# if not device:
# continue
# print(device.get_cached_property("Alias"))
char = obj.get_interface("org.bluez.GattCharacteristic1")
if not char:
continue
print(char.get_cached_property("UUID"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment