summaryrefslogtreecommitdiff
path: root/test/test-health
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-health')
-rwxr-xr-xtest/test-health50
1 files changed, 30 insertions, 20 deletions
diff --git a/test/test-health b/test/test-health
index f7d42418..052a6024 100755
--- a/test/test-health
+++ b/test/test-health
@@ -9,6 +9,12 @@ import gobject
from dbus.mainloop.glib import DBusGMainLoop
import sys
+BUS_NAME = 'org.bluez'
+PATH = '/org/bluez'
+ADAPTER_INTERFACE = 'org.bluez.Adapter1'
+HEALTH_MANAGER_INTERFACE = 'org.bluez.HealthManager1'
+HEALTH_DEVICE_INTERFACE = 'org.bluez.HealthDevice1'
+
DBusGMainLoop(set_as_default=True)
loop = gobject.MainLoop()
@@ -33,8 +39,8 @@ def sig_received(*args, **kwargs):
def enter_mainloop():
- bus.add_signal_receiver(sig_received, bus_name="org.bluez",
- dbus_interface = "org.bluez.HealthDevice",
+ bus.add_signal_receiver(sig_received, bus_name=BUS_NAME,
+ dbus_interface=HEALTH_DEVICE_INTERFACE,
path_keyword="path",
member_keyword="member",
interface_keyword="interface")
@@ -49,8 +55,8 @@ def enter_mainloop():
finally:
print("Exiting, bye")
-hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
- "org.bluez.HealthManager")
+hdp_manager = dbus.Interface(bus.get_object(BUS_NAME, PATH),
+ HEALTH_MANAGER_INTERFACE)
role = None
while role == None:
@@ -58,9 +64,9 @@ while role == None:
try:
sel = int(sys.stdin.readline())
if sel == 1:
- role = "Source"
+ role = "source"
elif sel == 2:
- role = "Sink"
+ role = "sink"
else:
raise ValueError
except (TypeError, ValueError):
@@ -82,16 +88,16 @@ while dtype == None:
sys.exit()
pref = None
-if role == "Source":
+if role == "source":
while pref == None:
try:
print("Select a preferred data channel type 1.",)
print("reliable 2. streaming: ",)
sel = int(sys.stdin.readline())
if sel == 1:
- pref = "Reliable"
+ pref = "reliable"
elif sel == 2:
- pref = "Streaming"
+ pref = "streaming"
else:
raise ValueError
@@ -131,10 +137,15 @@ if not con:
enter_mainloop()
sys.exit()
-manager = dbus.Interface(bus.get_object("org.bluez", "/"),
- "org.bluez.Manager")
+manager = dbus.Interface(bus.get_object(BUS_NAME, "/"),
+ "org.freedesktop.DBus.ObjectManager")
+
+objects = manager.GetManagedObjects()
+adapters = []
-adapters = manager.ListAdapters()
+for path, ifaces in objects.iteritems():
+ if ifaces.has_key(ADAPTER_INTERFACE):
+ adapters.append(path)
i = 1
for ad in adapters:
@@ -154,10 +165,9 @@ while select == None:
except KeyboardInterrupt:
sys.exit()
-adapter = dbus.Interface(bus.get_object("org.bluez", select),
- "org.bluez.Adapter")
+adapter = dbus.Interface(bus.get_object(BUS_NAME, select), ADAPTER_INTERFACE)
-devices = adapter.ListDevices()
+devices = adapter.GetProperties()["Devices"]
if len(devices) == 0:
print("No devices available")
@@ -181,8 +191,8 @@ while select == None:
except KeyboardInterrupt:
sys.exit()
-device = dbus.Interface(bus.get_object("org.bluez", select),
- "org.bluez.HealthDevice")
+device = dbus.Interface(bus.get_object(BUS_NAME, select),
+ HEALTH_DEVICE_INTERFACE)
echo = None
while echo == None:
@@ -207,10 +217,10 @@ if echo:
print("Connecting to device %s" % (select))
-if role == "Source":
- chan = device.CreateChannel(app_path, "Reliable")
+if role == "source":
+ chan = device.CreateChannel(app_path, "reliable")
else:
- chan = device.CreateChannel(app_path, "Any")
+ chan = device.CreateChannel(app_path, "any")
print(chan)