-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdevices.py
More file actions
40 lines (30 loc) · 1.33 KB
/
Copy pathdevices.py
File metadata and controls
40 lines (30 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __future__ import absolute_import, unicode_literals
import dbus
ADAPTER_DEV = "hci0"
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.freedesktop.DBus.ObjectManager")
objects = manager.GetManagedObjects()
for path in objects.keys():
print "[ %s ]" % (path)
interfaces = objects[path]
for interface in interfaces.keys():
#jif interface in ["org.freedesktop.DBus.Introspectable", "org.freedesktop.DBus.Properties"]:
#j continue
if interface == 'org.bluez.Adapter1':
print " %s" % (interface)
properties = interfaces[interface]
for key in properties.keys():
print " %s = %s" % (key, properties[key])
# Get the device
adapter = dbus.Interface(bus.get_object("org.bluez", "/org/bluez/" + ADAPTER_DEV),
"org.freedesktop.DBus.Properties")
#adapter = dbus.Interface(bus.get_object("org.bluez", "/org/bluez/hci0"),
# "org.bluez.Adapter1")
# Make sure the device is powered on
adapter.Set("org.bluez.Adapter1", "Powered", dbus.Boolean(1))
#print "Powered ", adapter.Get("org.bluez.Adapter1", "Powered")
# Get the adapter interface for discovery
adapter = dbus.Interface(bus.get_object("org.bluez", "/org/bluez/hci0"),
"org.bluez.Adapter1")
adapter.StartDiscovery()