summaryrefslogtreecommitdiff
path: root/test/test-health-sink
diff options
context:
space:
mode:
authorJose Antonio Santos Cadenas <santoscadenas@gmail.com>2010-10-01 09:31:21 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2010-10-06 10:37:08 +0200
commit529b73edef4816e695ab7f3e783a7a9a31cdbf12 (patch)
tree1b19c4e95ef0871e76f47cc18d01347a9c088f44 /test/test-health-sink
parent7de15fe110b4ec91feb7160b4afb014f54db532c (diff)
Update test script and create a new one
Diffstat (limited to 'test/test-health-sink')
-rwxr-xr-xtest/test-health-sink83
1 files changed, 83 insertions, 0 deletions
diff --git a/test/test-health-sink b/test/test-health-sink
new file mode 100755
index 00000000..cb9d434f
--- /dev/null
+++ b/test/test-health-sink
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import dbus
+import dbus.service
+import gobject
+from dbus.mainloop.glib import DBusGMainLoop
+import sys
+
+DBusGMainLoop(set_as_default=True)
+loop = gobject.MainLoop()
+
+bus = dbus.SystemBus()
+
+hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
+ "org.bluez.HealthManager")
+app_path = hdp_manager.CreateApplication({"DataType": dbus.types.UInt16(4103),
+ "Role": "sink"})
+
+print app_path
+
+manager = dbus.Interface(bus.get_object("org.bluez", "/"),
+ "org.bluez.Manager")
+
+adapters = manager.ListAdapters()
+
+i = 1
+for ad in adapters:
+ print "%d. %s" % (i, ad)
+ i = i + 1
+
+print "Select an adapter: ",
+select = None
+while select == None:
+ try:
+ pos = int(sys.stdin.readline()) - 1
+ if pos < 0:
+ raise TypeError
+ select = adapters[pos]
+ except (TypeError, IndexError, ValueError):
+ print "Wrong selection, try again: ",
+ except KeyboardInterrupt:
+ sys.exit()
+
+adapter = dbus.Interface(bus.get_object("org.bluez", select),
+ "org.bluez.Adapter")
+
+devices = adapter.ListDevices()
+
+if len(devices) == 0:
+ print "No devices available"
+ sys.exit()
+
+i = 1
+for dev in devices:
+ print "%d. %s" % (i, dev)
+ i = i + 1
+
+print "Select a device: ",
+select = None
+while select == None:
+ try:
+ pos = int(sys.stdin.readline()) - 1
+ if pos < 0:
+ raise TypeError
+ select = devices[pos]
+ except (TypeError, IndexError, ValueError):
+ print "Wrong selection, try again: ",
+ except KeyboardInterrupt:
+ sys.exit()
+
+print "Connecting to %s" % (select)
+device = dbus.Interface(bus.get_object("org.bluez", select),
+ "org.bluez.HealthDevice")
+
+chan = device.CreateChannel(app_path, "Any")
+
+print chan
+
+print "Push Enter for finishing"
+sys.stdin.readline()
+
+hdp_manager.DestroyApplication(app_path)