diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-09-09 18:02:27 -0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-09-09 18:02:27 -0300 |
commit | 618258d5f4e43ef2fb2f48f3ab395b9ace045019 (patch) | |
tree | 744cfe9420de547926f71908291a4928ed5874ef | |
parent | 7e39048d01729815f50afbb88acc432814b74e50 (diff) |
Add test-network.
-rwxr-xr-x | test/test-network | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/test-network b/test/test-network new file mode 100755 index 00000000..6f75bed6 --- /dev/null +++ b/test/test-network @@ -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 = "panu" +else: + service = sys.argv[2] + +device = adapter.FindDevice(address) + +network = dbus.Interface(bus.get_object("org.bluez", device), + "org.bluez.Network") + +iface = network.Connect(service) + +print "Connected %s to %s" % (device, address) + +print "Press CTRL-C to disconnect" + +try: + time.sleep(1000) + print "Terminating connection" +except: + pass + +network.Disconnect() |