我在Ubuntu上使用bluez-simple-agent并使用su -c bluez-simple-agent启动它。之后我得到了这样的例外:
Traceback (most recent call last): File "/usr/bin/bluez-simple-agent", line 133, in <module>
adapter.RegisterAgent(path, capability) File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in
__call__
return self._proxy_method(*args, **keywords) File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in
__call__
**keywords) File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout) dbus.exceptions.DBusException: org.bluez.Error.AlreadyExists: Already Exists
bluez-simple-agent的代码片段:
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.Manager")
capability = "DisplayYesNo"
parser = OptionParser()
parser.add_option("-c", "--capability", action="store",
type="string", dest="capability")
(options, args) = parser.parse_args()
if options.capability:
capability = options.capability
if len(args) > 0:
path = manager.FindAdapter(args[0])
else:
path = manager.DefaultAdapter()
adapter = dbus.Interface(bus.get_object("org.bluez", path),
"org.bluez.Adapter")
path = "/test/agent"
agent = Agent(bus, path)
mainloop = gobject.MainLoop()
if len(args) > 1:
if len(args) > 2:
device = adapter.FindDevice(args[1])
adapter.RemoveDevice(device)
agent.set_exit_on_release(False)
adapter.CreatePairedDevice(args[1], path, capability,
reply_handler=create_device_reply,
error_handler=create_device_error)
else:
adapter.RegisterAgent(path, capability)
print "Agent registered"
mainloop.run()
我该如何解决这个问题?
答案 0 :(得分:2)
代理对象已经存在bluez并且创建另一个将导致此错误,如果你在ubuntu上,kill bluetooth-applet(可以在ps中找到),一旦完成,你将能够通过cmd提示使用simple-agent < / p>