aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/examples
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2010-01-01 20:34:15 (GMT)
committerJouni Malinen <j@w1.fi>2010-01-01 20:34:15 (GMT)
commit1701996209e87edb51495390eb123193e42740db (patch)
tree936f155152cca7cf8cfdab698fbde5fd273d7448 /wpa_supplicant/examples
parentd8d8c6d02af3ebefd185b1be962015fb99fb5a5f (diff)
downloadhostap-1701996209e87edb51495390eb123193e42740db.zip
hostap-1701996209e87edb51495390eb123193e42740db.tar.gz
hostap-1701996209e87edb51495390eb123193e42740db.tar.bz2
dbus: Add example script for running WPS PBC
Diffstat (limited to 'wpa_supplicant/examples')
-rwxr-xr-xwpa_supplicant/examples/wpas-dbus-new-wps.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/wpa_supplicant/examples/wpas-dbus-new-wps.py b/wpa_supplicant/examples/wpas-dbus-new-wps.py
new file mode 100755
index 0000000..870b1c5
--- /dev/null
+++ b/wpa_supplicant/examples/wpas-dbus-new-wps.py
@@ -0,0 +1,78 @@
+#!/usr/bin/python
+
+import dbus
+import sys, os
+import time
+import gobject
+from dbus.mainloop.glib import DBusGMainLoop
+
+WPAS_DBUS_SERVICE = "fi.w1.wpa_supplicant1"
+WPAS_DBUS_INTERFACE = "fi.w1.wpa_supplicant1"
+WPAS_DBUS_OPATH = "/fi/w1/wpa_supplicant1"
+
+WPAS_DBUS_INTERFACES_INTERFACE = "fi.w1.wpa_supplicant1.Interface"
+WPAS_DBUS_WPS_INTERFACE = "fi.w1.wpa_supplicant1.Interface.WPS"
+
+def stateChanged(newState, oldState):
+ print "StateChanged(%s -> %s)" % (oldState, newState)
+
+def scanDone(success):
+ print "Scan done: success=%s" % success
+
+def bssAdded(bss, properties):
+ print "BSS added: %s" % (bss)
+
+def bssRemoved(bss):
+ print "BSS removed: %s" % (bss)
+
+def wpsEvent(name, args):
+ print "WPS event: %s" % (name)
+ print args
+
+def credentials(cred):
+ print "WPS credentials: %s" % (cred)
+
+def main():
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+ global bus
+ bus = dbus.SystemBus()
+ wpas_obj = bus.get_object(WPAS_DBUS_SERVICE, WPAS_DBUS_OPATH)
+
+ if len(sys.argv) != 2:
+ print "Missing ifname argument"
+ os._exit(1)
+
+ wpas = dbus.Interface(wpas_obj, WPAS_DBUS_INTERFACE)
+ bus.add_signal_receiver(scanDone,
+ dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
+ signal_name="ScanDone")
+ bus.add_signal_receiver(bssAdded,
+ dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
+ signal_name="BSSAdded")
+ bus.add_signal_receiver(bssRemoved,
+ dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
+ signal_name="BSSRemoved")
+ bus.add_signal_receiver(stateChanged,
+ dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
+ signal_name="StateChanged")
+ bus.add_signal_receiver(wpsEvent,
+ dbus_interface=WPAS_DBUS_WPS_INTERFACE,
+ signal_name="Event")
+ bus.add_signal_receiver(credentials,
+ dbus_interface=WPAS_DBUS_WPS_INTERFACE,
+ signal_name="Credentials")
+
+ ifname = sys.argv[1]
+
+ path = wpas.GetInterface(ifname)
+ global if_obj
+ if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
+ global iface
+ wps = dbus.Interface(if_obj, WPAS_DBUS_WPS_INTERFACE)
+ wps.Start({'Role': 'enrollee', 'Type': 'pbc'})
+
+ gobject.MainLoop().run()
+
+if __name__ == "__main__":
+ main()
+