summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hcid/Makefile.am2
-rwxr-xr-xhcid/simple-agent47
2 files changed, 48 insertions, 1 deletions
diff --git a/hcid/Makefile.am b/hcid/Makefile.am
index dda695b6..638a7524 100644
--- a/hcid/Makefile.am
+++ b/hcid/Makefile.am
@@ -58,7 +58,7 @@ AM_YFLAGS = -d
CLEANFILES = lexer.c parser.c parser.h
EXTRA_DIST = hcid.8 hcid.conf.5 hcid.conf dbus-api.txt \
- list-devices test-device service-record.dtd \
+ list-devices test-device simple-agent service-record.dtd \
service-did.xml service-spp.xml service-opp.xml service-ftp.xml
MAINTAINERCLEANFILES = Makefile.in
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")