summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hcid/Makefile.am3
-rwxr-xr-xhcid/test-discovery42
2 files changed, 44 insertions, 1 deletions
diff --git a/hcid/Makefile.am b/hcid/Makefile.am
index 638a7524..9c3ee058 100644
--- a/hcid/Makefile.am
+++ b/hcid/Makefile.am
@@ -58,7 +58,8 @@ 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 simple-agent service-record.dtd \
+ list-devices test-discovery 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/test-discovery b/hcid/test-discovery
new file mode 100755
index 00000000..6605d6a4
--- /dev/null
+++ b/hcid/test-discovery
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+
+import gobject
+
+import dbus
+import dbus.mainloop.glib
+
+def device_found(address, properties):
+ print '[ ' + address + ' ]'
+
+ for key in properties.keys():
+ value = properties[key]
+ if (key == "Class"):
+ print ' %s = 0x%06x' % (key, value)
+ else:
+ print ' %s = %s' % (key, value)
+
+def discovery_completed():
+ mainloop.quit()
+
+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')
+
+ bus.add_signal_receiver(device_found,
+ dbus_interface = 'org.bluez.Adapter',
+ signal_name = 'DeviceFound')
+
+ bus.add_signal_receiver(discovery_completed,
+ dbus_interface = 'org.bluez.Adapter',
+ signal_name = 'DiscoveryCompleted')
+
+ adapter.DiscoverDevices()
+
+ mainloop = gobject.MainLoop()
+ mainloop.run()