From dab3eafc0efec635be6ac941266e315dd2be3c3b Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 21 Dec 2012 09:25:03 +0200 Subject: [PATCH] Revert "build: Remove test-network" This reverts commit 9efcb970ce023f9bedbe8160be0226fd14367878. Conflicts: Makefile.tools --- Makefile.tools | 2 +- test/test-network | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 test/test-network diff --git a/Makefile.tools b/Makefile.tools index c0ad7e53c..6be310eca 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -198,7 +198,7 @@ test_scripts += test/sap_client.py test/bluezutils.py \ test/test-discovery test/test-manager test/test-adapter \ test/test-device test/simple-agent \ test/simple-service test/simple-endpoint test/test-sap-server \ - test/test-proximity \ + test/test-proximity test/test-network \ test/test-thermometer test/test-profile test/test-health \ test/test-health-sink test/service-record.dtd \ test/service-did.xml test/service-spp.xml test/service-opp.xml \ diff --git a/test/test-network b/test/test-network new file mode 100755 index 000000000..62d60049a --- /dev/null +++ b/test/test-network @@ -0,0 +1,50 @@ +#!/usr/bin/python + +from __future__ import absolute_import, print_function, unicode_literals + +import sys +import time +import dbus +from optparse import OptionParser, make_option +import bluezutils + +bus = dbus.SystemBus() + +manager = dbus.Interface(bus.get_object("org.bluez", "/"), + "org.bluez.Manager") + +option_list = [ + make_option("-i", "--device", action="store", + type="string", dest="dev_id"), + ] +parser = OptionParser(option_list=option_list) + +(options, args) = parser.parse_args() + +if (len(args) < 1): + print("Usage: %s
[service]" % (sys.argv[0])) + sys.exit(1) + +if (len(args) < 2): + service = "panu" +else: + service = args[1] + +device = bluezutils.find_device(args[0], options.dev_id) + +network = dbus.Interface(bus.get_object("org.bluez", device.object_path), + "org.bluez.Network1") + +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() -- 2.47.3