Question

I am using the bluez-simple-agent on Ubuntu and starting it with su -c bluez-simple-agent. After that I am getting an exception like this:

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

A codesnippet of 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()

How can I fix that problem?

Was it helpful?

Solution

Agent object already exist with bluez and creating another will result in this error, if you are on ubuntu, kill bluetooth-applet(can find in ps) , once done you will be able to use simple-agent via cmd prompt

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top