--- test/test-health | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 61 insertions(+), 0 deletions(-) create mode 100755 test/test-health diff --git a/test/test-health b/test/test-health new file mode 100755 index 0000000..2129923 --- /dev/null +++ b/test/test-health @@ -0,0 +1,61 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import dbus +import dbus.service +import gobject +from dbus.mainloop.glib import DBusGMainLoop + +agent_iface = 'org.bluez.HealthAgent' +obj_path = "/org/bluez/test/health/agent" + +DBusGMainLoop(set_as_default=True) +loop = gobject.MainLoop() + +bus = dbus.SystemBus() +manager = dbus.Interface(bus.get_object("org.bluez", "/"), + "org.bluez.Manager") + +hdp = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()), + "org.bluez.HealthAdapter") + +class HDP(dbus.service.Object): + def __init__(self, bus, obj_path): + self.bus = bus + dbus.service.Object.__init__(self, self.bus, obj_path) + @dbus.service.method(agent_iface, in_signature='o', out_signature='', + sender_keyword='sender') + def LinkConnected(self, path, sender=None): + print "Connected new link %s: (sender %s)" % (path, sender) + @dbus.service.method(agent_iface, in_signature='o', out_signature='', + sender_keyword='sender') + def LinkDisconnected(self, path, sender=None): + print "Link %s: disconnected (sender: %s)" % (path, sender) + +session_id = hdp.CreateInstance(dbus.ObjectPath(obj_path), + {"data_spec": dbus.Byte(1, variant_level=1), + "end_points":dbus.Array([{ "role": dbus.String("sink", variant_level=1), + "specs": dbus.Array([{ + "data_type": + dbus.UInt16(4100, variant_level =1), + "description": + dbus.String("Oximeter", + variant_level = 1), + },{ + "data_type": + dbus.UInt16(4103, variant_level =1), + "description": + dbus.String("Blood pressure", + variant_level = 1), + } + ], variant_level=1), + }, + ], variant_level=1)}) + +hdp_obj = HDP(bus, obj_path); + +try: + print "Waiting for connections, push Ctrl+C to stop" + loop.run() +except: + print "Loop interrupted, closing session" -- 1.6.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html