diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-09-06 01:33:29 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-09-06 01:33:29 +0200 |
commit | 028ea961e350c8cdec87204d12cb83e64372380e (patch) | |
tree | 4669c648598ae35a2c7bd4282d71f01c3b7c615b /test | |
parent | 5ddbcfcefc63331ee0c2ad2ee5cae338ad490d24 (diff) |
Fix org.bluez.Serial interface
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-serial | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/test-serial b/test/test-serial new file mode 100755 index 00000000..73561cc1 --- /dev/null +++ b/test/test-serial @@ -0,0 +1,43 @@ +#!/usr/bin/python + +import sys +import time +import dbus + +bus = dbus.SystemBus() + +manager = dbus.Interface(bus.get_object("org.bluez", "/"), + "org.bluez.Manager") + +adapter = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()), + "org.bluez.Adapter") + +if (len(sys.argv) < 2): + print "Usage: %s <address> [service]" % (sys.argv[0]) + sys.exit(1) + +address = sys.argv[1] + +if (len(sys.argv) < 3): + service = "spp" +else: + service = sys.argv[2] + +path = adapter.FindDevice(address) + +serial = dbus.Interface(bus.get_object("org.bluez", path), + "org.bluez.Serial") + +node = serial.Connect(service) + +print "Connected %s to %s" % (device, address) + +print "Press CTRL-C to disconnect" + +try: + time.sleep(1000) + print "Terminating connection" +except: + pass + +serial.Disconnect(node) |