Created
January 17, 2017 15:32
-
-
Save CynaCons/8eb02540f87af5594fac489a9dca32c1 to your computer and use it in GitHub Desktop.
Simple Python BLE example with python-glib and Bluez5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
time.sleep(10); | |
adapter_proxy.StopDiscovery(dbus_interface="org.bluez.Adapter1") | |
#Introspect the adapter | |
introspection = adapter_proxy.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable") | |
#Print the introspection. See the AdvancedProxyExample for xml pretty printing. | |
print(introspection) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment