Diff between e91aab1a7de2f79ae6c2e64f82e529fd92c1f6b0 and f2d17bea8d5cc98cf431d796d044e28b65b8a92f

Changed Files

File Additions Deletions Status
Makefile.tools +2 -1 modified
test/test-gatt-profile +60 -0 added

Full Patch

diff --git a/Makefile.tools b/Makefile.tools
index e193be9..330cc6b 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -407,4 +407,5 @@ test_scripts += test/sap_client.py test/bluezutils.py \
 		test/test-heartrate test/test-alert test/test-hfp \
 		test/test-cyclingspeed test/opp-client test/ftp-client \
 		test/pbap-client test/map-client test/example-advertisement \
-		test/example-gatt-server test/example-gatt-client
+		test/example-gatt-server test/example-gatt-client \
+		test/test-gatt-profile
diff --git a/test/test-gatt-profile b/test/test-gatt-profile
new file mode 100755
index 0000000..ad320b1
--- /dev/null
+++ b/test/test-gatt-profile
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+from optparse import OptionParser, make_option
+import os
+import sys
+import uuid
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+try:
+  from gi.repository import GObject
+except ImportError:
+  import gobject as GObject
+import bluezutils
+
+class GattProfile(dbus.service.Object):
+	@dbus.service.method("org.bluez.GattProfile1",
+					in_signature="", out_signature="")
+	def Release(self):
+		print("Release")
+		mainloop.quit()
+
+if __name__ == '__main__':
+	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+	bus = dbus.SystemBus()
+
+	path = bluezutils.find_adapter().object_path
+
+	manager = dbus.Interface(bus.get_object("org.bluez", path),
+				"org.bluez.GattManager1")
+
+	option_list = [
+			make_option("-u", "--uuid", action="store",
+					type="string", dest="uuid",
+					default=None),
+			make_option("-p", "--path", action="store",
+					type="string", dest="path",
+					default="/foo/bar/profile"),
+			]
+
+	opts = dbus.Dictionary({ }, signature='sv')
+
+	parser = OptionParser(option_list=option_list)
+
+	(options, args) = parser.parse_args()
+
+	profile = GattProfile(bus, options.path)
+
+	mainloop = GObject.MainLoop()
+
+	if not options.uuid:
+		options.uuid = str(uuid.uuid4())
+
+	uuids = { options.uuid }
+	manager.RegisterProfile(options.path, uuids, opts)
+
+	mainloop.run()