Add handling of BSSAdded and BSSRemoved events
This commit is contained in:
parent
58c26600ca
commit
c9df730b03
1 changed files with 43 additions and 27 deletions
|
@ -32,17 +32,8 @@ def list_interfaces(wpas_obj):
|
|||
def stateChanged(newState, oldState):
|
||||
print "StateChanged(%s -> %s)" % (oldState, newState)
|
||||
|
||||
def scanDone(success):
|
||||
gobject.MainLoop().quit()
|
||||
print "Scan done: success=%s" % success
|
||||
|
||||
res = if_obj.Get(WPAS_DBUS_INTERFACES_INTERFACE, 'BSSs',
|
||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||
|
||||
print "Scanned wireless networks:"
|
||||
for opath in res:
|
||||
print opath
|
||||
net_obj = bus.get_object(WPAS_DBUS_SERVICE, opath)
|
||||
def showBss(bss):
|
||||
net_obj = bus.get_object(WPAS_DBUS_SERVICE, bss)
|
||||
net = dbus.Interface(net_obj, WPAS_DBUS_BSS_INTERFACE)
|
||||
props = net_obj.Get(WPAS_DBUS_BSS_INTERFACE, 'Properties',
|
||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||
|
@ -72,6 +63,25 @@ def scanDone(success):
|
|||
|
||||
print " %s :: ssid='%s' wpa=%s wpa2=%s quality=%d%% rate=%d freq=%d" % (bssid, ssid, wpa, wpa2, qual, maxrate, freq)
|
||||
|
||||
def scanDone(success):
|
||||
gobject.MainLoop().quit()
|
||||
print "Scan done: success=%s" % success
|
||||
|
||||
res = if_obj.Get(WPAS_DBUS_INTERFACES_INTERFACE, 'BSSs',
|
||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||
|
||||
print "Scanned wireless networks:"
|
||||
for opath in res:
|
||||
print opath
|
||||
showBss(opath)
|
||||
|
||||
def bssAdded(bss):
|
||||
print "BSS added: %s" % (bss)
|
||||
showBss(bss)
|
||||
|
||||
def bssRemoved(bss):
|
||||
print "BSS removed: %s" % (bss)
|
||||
|
||||
def main():
|
||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||
global bus
|
||||
|
@ -81,6 +91,12 @@ def main():
|
|||
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")
|
||||
|
|
Loading…
Reference in a new issue