Home | History | Annotate | Download | only in test
      1 #!/usr/bin/python
      2 
      3 import sys
      4 import time
      5 import dbus
      6 from optparse import OptionParser, make_option
      7 
      8 bus = dbus.SystemBus()
      9 
     10 manager = dbus.Interface(bus.get_object("org.bluez", "/"),
     11 						"org.bluez.Manager")
     12 
     13 option_list = [
     14 		make_option("-i", "--device", action="store",
     15 				type="string", dest="dev_id"),
     16 		]
     17 parser = OptionParser(option_list=option_list)
     18 
     19 (options, args) = parser.parse_args()
     20 
     21 if options.dev_id:
     22 	adapter_path = manager.FindAdapter(options.dev_id)
     23 else:
     24 	adapter_path = manager.DefaultAdapter()
     25 
     26 server = dbus.Interface(bus.get_object("org.bluez", adapter_path),
     27 						"org.bluez.NetworkServer")
     28 
     29 service = "nap"
     30 
     31 if (len(args) < 1):
     32 	bridge = "tether"
     33 else:
     34 	bridge = args[0]
     35 
     36 server.Register(service, bridge)
     37 
     38 print "Server for %s registered for %s" % (service, bridge)
     39 
     40 print "Press CTRL-C to disconnect"
     41 
     42 try:
     43 	time.sleep(1000)
     44 	print "Terminating connection"
     45 except:
     46 	pass
     47 
     48 server.Unregister(service)
     49