Diff between a5fe71eaccada41eee95853b8eb2b2b160756b48 and dab3eafc0efec635be6ac941266e315dd2be3c3b

Changed Files

File Additions Deletions Status
Makefile.tools +1 -1 modified
test/test-network +50 -0 added

Full Patch

diff --git a/Makefile.tools b/Makefile.tools
index c0ad7e5..6be310e 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 0000000..62d6004
--- /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 <address> [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()