Upgrade bluez5_37 :Merge the code from private
[platform/upstream/bluez.git] / test / test-nap
1 #!/usr/bin/python
2
3 from __future__ import absolute_import, print_function, unicode_literals
4
5 from optparse import OptionParser, make_option
6 import sys
7 import time
8 import dbus
9 import bluezutils
10 import dbus.mainloop.glib
11 try:
12   from gi.repository import GObject
13 except ImportError:
14   import gobject as GObject
15
16 bus = dbus.SystemBus()
17
18 option_list = [
19                 make_option("-i", "--device", action="store",
20                                 type="string", dest="dev_id"),
21                 ]
22 parser = OptionParser(option_list=option_list)
23
24 (options, args) = parser.parse_args()
25
26 adapter_path = bluezutils.find_adapter(options.dev_id).object_path
27 server = dbus.Interface(bus.get_object("org.bluez", adapter_path),
28                                                 "org.bluez.NetworkServer1")
29
30 service = "nap"
31
32 if (len(args) < 1):
33         bridge = "tether"
34 else:
35         bridge = args[0]
36
37 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
38
39 mainloop = GObject.MainLoop()
40
41 server.Register(service, bridge)
42
43 print("Server for %s registered for %s" % (service, bridge))
44
45 print("Press CTRL-C to disconnect")
46
47 mainloop.run()