Created
April 5, 2016 14:45
-
-
Save fmntf/10c24edb2fa741d682edad969076e792 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import time | |
import dbus | |
from optparse import OptionParser, make_option | |
bus = dbus.SystemBus() | |
manager = dbus.Interface(bus.get_object("org.bluez", "/"), | |
"org.bluez.Manager") | |
option_list = [ | |
make_option("-i", "--device", action="store", | |
type="string", dest="dev_id"), | |
] | |
parser = OptionParser(option_list=option_list) | |
(options, args) = parser.parse_args() | |
if options.dev_id: | |
adapter_path = manager.FindAdapter(options.dev_id) | |
else: | |
adapter_path = manager.DefaultAdapter() | |
server = dbus.Interface(bus.get_object("org.bluez", adapter_path), | |
"org.bluez.NetworkServer") | |
service = "nap" | |
if (len(args) < 1): | |
bridge = "tether" | |
else: | |
bridge = args[0] | |
server.Register(service, bridge) | |
print "Server for %s registered for %s" % (service, bridge) | |
print "Press CTRL-C to disconnect" | |
try: | |
time.sleep(1000) | |
print "Terminating connection" | |
except: | |
pass | |
server.Unregister(service) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get an error at line 24, we are trying to set up a two Raspberry Pi system and the tutorial at https://www.udoo.org/docs-neo/Wireless_Communication/Bluetooth%20NAP.html seems like it would help, but this is the last step and nothing else is working.
The error is "DBusException: Method "DefaultAdapter" with signature "" on interface "org.bluez.Manager" doesn't exist"
Can you help us? Thanks!