wpas-dbus-new-wps.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 import dbus
00004 import sys, os
00005 import time
00006 import gobject
00007 from dbus.mainloop.glib import DBusGMainLoop
00008 
00009 WPAS_DBUS_SERVICE = "fi.w1.wpa_supplicant1"
00010 WPAS_DBUS_INTERFACE = "fi.w1.wpa_supplicant1"
00011 WPAS_DBUS_OPATH = "/fi/w1/wpa_supplicant1"
00012 
00013 WPAS_DBUS_INTERFACES_INTERFACE = "fi.w1.wpa_supplicant1.Interface"
00014 WPAS_DBUS_WPS_INTERFACE = "fi.w1.wpa_supplicant1.Interface.WPS"
00015 
00016 def propertiesChanged(properties):
00017         if properties.has_key("State"):
00018                 print "PropertiesChanged: State: %s" % (properties["State"])
00019 
00020 def scanDone(success):
00021         print "Scan done: success=%s" % success
00022 
00023 def bssAdded(bss, properties):
00024         print "BSS added: %s" % (bss)
00025 
00026 def bssRemoved(bss):
00027         print "BSS removed: %s" % (bss)
00028 
00029 def wpsEvent(name, args):
00030         print "WPS event: %s" % (name)
00031         print args
00032 
00033 def credentials(cred):
00034         print "WPS credentials: %s" % (cred)
00035 
00036 def main():
00037         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
00038         global bus
00039         bus = dbus.SystemBus()
00040         wpas_obj = bus.get_object(WPAS_DBUS_SERVICE, WPAS_DBUS_OPATH)
00041 
00042         if len(sys.argv) != 2:
00043                 print "Missing ifname argument"
00044                 os._exit(1)
00045 
00046         wpas = dbus.Interface(wpas_obj, WPAS_DBUS_INTERFACE)
00047         bus.add_signal_receiver(scanDone,
00048                                 dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
00049                                 signal_name="ScanDone")
00050         bus.add_signal_receiver(bssAdded,
00051                                 dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
00052                                 signal_name="BSSAdded")
00053         bus.add_signal_receiver(bssRemoved,
00054                                 dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
00055                                 signal_name="BSSRemoved")
00056         bus.add_signal_receiver(propertiesChanged,
00057                                 dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
00058                                 signal_name="PropertiesChanged")
00059         bus.add_signal_receiver(wpsEvent,
00060                                 dbus_interface=WPAS_DBUS_WPS_INTERFACE,
00061                                 signal_name="Event")
00062         bus.add_signal_receiver(credentials,
00063                                 dbus_interface=WPAS_DBUS_WPS_INTERFACE,
00064                                 signal_name="Credentials")
00065 
00066         ifname = sys.argv[1]
00067 
00068         path = wpas.GetInterface(ifname)
00069         if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
00070         if_obj.Set(WPAS_DBUS_WPS_INTERFACE, 'ProcessCredentials',
00071                    dbus.Boolean(1),
00072                    dbus_interface=dbus.PROPERTIES_IFACE)
00073         wps = dbus.Interface(if_obj, WPAS_DBUS_WPS_INTERFACE)
00074         wps.Start({'Role': 'enrollee', 'Type': 'pbc'})
00075 
00076         gobject.MainLoop().run()
00077 
00078 if __name__ == "__main__":
00079         main()
00080 


wpa_supplicant
Author(s): Package maintained by Blaise Gassend
autogenerated on Thu Jan 2 2014 11:26:39