Skip to content

Instantly share code, notes, and snippets.

View CynaCons's full-sized avatar

Constantin Chabirand CynaCons

  • T&S Engineering GmbH
  • Stuttgart, Germany
View GitHub Profile
@CynaCons
CynaCons / Bluez5_SimpleProxyExample.py
Created January 17, 2017 15:32
Simple Python BLE example with python-glib and Bluez5
import dbus
import time
bus = dbus.SystemBus()
#Build a proxy for the Adapter
adapter_proxy = bus.get_object("org.bluez", "/org/bluez/hci0")
#Call the method StartDiscovery from the adapter api then StopDiscovery
adapter_proxy.StartDiscovery(dbus_interface="org.bluez.Adapter1")
@CynaCons
CynaCons / Bluez5_AdancedProxyExample.py
Last active November 23, 2017 01:07
Advanced Python BLE example with python-glib and Bluez5
import dbus
import time
"""
This gist will do the following things :
1. Setup GLib and a MainLoop. MainLoop is required to receive signals from the dbus
2. Define a simple callback function that will be associated to the signal "Properties Changed" for a specific object (Characteristic).
The callback function will be called when the characteristic value is updated or it's property changed.