|
Packit |
34410b |
#!/usr/bin/python
|
|
Packit |
34410b |
|
|
Packit |
34410b |
from __future__ import absolute_import, print_function, unicode_literals
|
|
Packit |
34410b |
|
|
Packit |
34410b |
from optparse import OptionParser, make_option
|
|
Packit |
34410b |
import sys
|
|
Packit |
34410b |
import time
|
|
Packit |
34410b |
import dbus
|
|
Packit |
34410b |
import bluezutils
|
|
Packit |
34410b |
import dbus.mainloop.glib
|
|
Packit |
34410b |
try:
|
|
Packit |
34410b |
from gi.repository import GObject
|
|
Packit |
34410b |
except ImportError:
|
|
Packit |
34410b |
import gobject as GObject
|
|
Packit |
34410b |
|
|
Packit |
34410b |
bus = dbus.SystemBus()
|
|
Packit |
34410b |
|
|
Packit |
34410b |
option_list = [
|
|
Packit |
34410b |
make_option("-i", "--device", action="store",
|
|
Packit |
34410b |
type="string", dest="dev_id"),
|
|
Packit |
34410b |
]
|
|
Packit |
34410b |
parser = OptionParser(option_list=option_list)
|
|
Packit |
34410b |
|
|
Packit |
34410b |
(options, args) = parser.parse_args()
|
|
Packit |
34410b |
|
|
Packit |
34410b |
adapter_path = bluezutils.find_adapter(options.dev_id).object_path
|
|
Packit |
34410b |
server = dbus.Interface(bus.get_object("org.bluez", adapter_path),
|
|
Packit |
34410b |
"org.bluez.NetworkServer1")
|
|
Packit |
34410b |
|
|
Packit |
34410b |
service = "nap"
|
|
Packit |
34410b |
|
|
Packit |
34410b |
if (len(args) < 1):
|
|
Packit |
34410b |
bridge = "tether"
|
|
Packit |
34410b |
else:
|
|
Packit |
34410b |
bridge = args[0]
|
|
Packit |
34410b |
|
|
Packit |
34410b |
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
|
Packit |
34410b |
|
|
Packit |
34410b |
mainloop = GObject.MainLoop()
|
|
Packit |
34410b |
|
|
Packit |
34410b |
server.Register(service, bridge)
|
|
Packit |
34410b |
|
|
Packit |
34410b |
print("Server for %s registered for %s" % (service, bridge))
|
|
Packit |
34410b |
|
|
Packit |
34410b |
print("Press CTRL-C to disconnect")
|
|
Packit |
34410b |
|
|
Packit |
34410b |
mainloop.run()
|