8 WPAS_DBUS_SERVICE
= "fi.w1.wpa_supplicant1"
9 WPAS_DBUS_INTERFACE
= "fi.w1.wpa_supplicant1"
10 WPAS_DBUS_OPATH
= "/fi/w1/wpa_supplicant1"
12 WPAS_DBUS_INTERFACES_INTERFACE
= "fi.w1.wpa_supplicant1.Interface"
13 WPAS_DBUS_INTERFACES_OPATH
= "/fi/w1/wpa_supplicant1/Interfaces"
14 WPAS_DBUS_BSS_INTERFACE
= "fi.w1.wpa_supplicant1.Interface.BSS"
17 net_obj
= bus
.get_object(WPAS_DBUS_SERVICE
, bss
)
18 net
= dbus
.Interface(net_obj
, WPAS_DBUS_BSS_INTERFACE
)
19 props
= net_obj
.GetAll(WPAS_DBUS_BSS_INTERFACE
,
20 dbus_interface
=dbus
.PROPERTIES_IFACE
)
22 props
= net_obj
.Get(WPAS_DBUS_BSS_INTERFACE
, 'Properties',
23 dbus_interface
=dbus
.PROPERTIES_IFACE
)
26 # Convert the byte-array for SSID and BSSID to printable strings
28 for item
in props
['BSSID']:
29 bssid
= bssid
+ ":%02x" % item
31 ssid
= byte_array_to_string(props
["SSID"])
34 if props
.has_key("WPAIE"):
37 if props
.has_key("RSNIE"):
40 if props
.has_key("Frequency"):
41 freq
= props
["Frequency"]
42 caps
= props
["Capabilities"]
43 qual
= props
["Quality"]
44 level
= props
["Level"]
45 noise
= props
["Noise"]
46 maxrate
= props
["MaxRate"] / 1000000
48 print " %s :: ssid='%s' wpa=%s wpa2=%s quality=%d%% rate=%d freq=%d" % (bssid
, ssid
, wpa
, wpa2
, qual
, maxrate
, freq
)
50 def scanDone(success
):
51 gobject
.MainLoop().quit()
52 print "Scan done: success=%s" % success
54 res
= if_obj
.Get(WPAS_DBUS_INTERFACES_INTERFACE
, 'BSSs',
55 dbus_interface
=dbus
.PROPERTIES_IFACE
)
56 props
= if_obj
.GetAll(WPAS_DBUS_INTERFACES_INTERFACE
,
57 dbus_interface
=dbus
.PROPERTIES_IFACE
)
60 print "Scanned wireless networks:"
66 bus
= dbus
.SystemBus()
67 wpas_obj
= bus
.get_object("fi.w1.wpa_supplicant1",
68 "/fi/w1/wpa_supplicant1")
69 props
= wpas_obj
.GetAll("fi.w1.wpa_supplicant1",
70 dbus_interface
=dbus
.PROPERTIES_IFACE
)
71 print "GetAll(fi.w1.wpa_supplicant1, /fi/w1/wpa_supplicant1):"
74 if len(sys
.argv
) != 2:
79 wpas
= dbus
.Interface(wpas_obj
, "fi.w1.wpa_supplicant1")
80 path
= wpas
.GetInterface(ifname
)
81 if_obj
= bus
.get_object("fi.w1.wpa_supplicant1", path
)
82 props
= if_obj
.GetAll("fi.w1.wpa_supplicant1.Interface",
83 dbus_interface
=dbus
.PROPERTIES_IFACE
)
85 print "GetAll(fi.w1.wpa_supplicant1.Interface, %s):" % (path
)
88 props
= if_obj
.GetAll("fi.w1.wpa_supplicant1.Interface.WPS",
89 dbus_interface
=dbus
.PROPERTIES_IFACE
)
91 print "GetAll(fi.w1.wpa_supplicant1.Interface.WPS, %s):" % (path
)
94 res
= if_obj
.Get("fi.w1.wpa_supplicant1.Interface", 'BSSs',
95 dbus_interface
=dbus
.PROPERTIES_IFACE
)
97 bss_obj
= bus
.get_object("fi.w1.wpa_supplicant1", res
[0])
98 props
= bss_obj
.GetAll("fi.w1.wpa_supplicant1.Interface.BSS",
99 dbus_interface
=dbus
.PROPERTIES_IFACE
)
101 print "GetAll(fi.w1.wpa_supplicant1.Interface.BSS, %s):" % (res
[0])
104 res
= if_obj
.Get("fi.w1.wpa_supplicant1.Interface", 'Networks',
105 dbus_interface
=dbus
.PROPERTIES_IFACE
)
107 net_obj
= bus
.get_object("fi.w1.wpa_supplicant1", res
[0])
108 props
= net_obj
.GetAll("fi.w1.wpa_supplicant1.Interface.Network",
109 dbus_interface
=dbus
.PROPERTIES_IFACE
)
111 print "GetAll(fi.w1.wpa_supplicant1.Interface.Network, %s):" % (res
[0])
114 if __name__
== "__main__":