/usr/share/doc/bluez-tests/examples/test-gatt-profile is in bluez-tests 5.37-0ubuntu5.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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()
|