gpt4 book ai didi

python - 启动 bluez-simple-agent 时出现异常错误 : Already Exists

转载 作者:行者123 更新时间:2023-12-01 05:23:30 34 4
gpt4 key购买 nike

我在 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()

如何解决这个问题?

最佳答案

Agent 对象已经存在于 bluez 中,创建另一个会导致此错误,如果您在 ubuntu 上,请杀死 bluetooth-applet(可以在 ps 中找到),完成后您将能够通过 cmd 提示符使用 simple-agent

关于python - 启动 bluez-simple-agent 时出现异常错误 : Already Exists,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21851996/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com