diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-03-14 19:56:30 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-03-14 19:56:30 +0000 |
commit | 80fba068672cb76956f1b40629d775026cb290c3 (patch) | |
tree | 067003b1363aa533ded71e36ac9d412761eb0d37 /hcid/simple-agent | |
parent | 763087507a0b8e3df8b186c74ec35036e313b8a3 (diff) |
Add first draft of a simple agent implementation for the new API
Diffstat (limited to 'hcid/simple-agent')
-rwxr-xr-x | hcid/simple-agent | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/hcid/simple-agent b/hcid/simple-agent new file mode 100755 index 00000000..d6cc9482 --- /dev/null +++ b/hcid/simple-agent @@ -0,0 +1,47 @@ +#!/usr/bin/python + +import gobject + +import dbus +import dbus.service +import dbus.mainloop.glib + +class Agent(dbus.service.Object): + @dbus.service.method("org.bluez.Agent", + in_signature='', out_signature='') + def Release(self): + print("Release") + mainloop.quit() + + @dbus.service.method("org.bluez.Agent", + in_signature='o', out_signature='s') + def RequestPasskey(self, device): + print("RequestPasskey (" + device + ")") + return "1234" + + @dbus.service.method("org.bluez.Agent", + in_signature='', out_signature='') + def Cancel(self): + print("Cancel") + +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') + path = manager.DefaultAdapter() + adapter = dbus.Interface(bus.get_object('org.bluez', path), + 'org.bluez.Adapter') + + path = "/test/agent" + object = Agent(bus, path) + + adapter.RegisterAgent(path) + print("Agent registered") + + mainloop = gobject.MainLoop() + mainloop.run() + + #adapter.UnregisterAgent(path) + #print("Agent unregistered") |