X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=test%2Flist-networks;h=b4462103a532e3d9d53285269c12b05f32fae8b9;hb=f3570489ceb89d349f3212548f40eff98e33ecf0;hp=d3fa34d982ba093aa20af4b6fc9b5561a0bb334c;hpb=5734f815db47e848c34bb84cd05293134652f635;p=connman diff --git a/test/list-networks b/test/list-networks index d3fa34d..b446210 100755 --- a/test/list-networks +++ b/test/list-networks @@ -1,26 +1,50 @@ #!/usr/bin/python import dbus +import string bus = dbus.SystemBus() manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"), "org.moblin.connman.Manager") -elements = manager.ListElements() +properties = manager.GetProperties() -for path in elements: - element = dbus.Interface(bus.get_object("org.moblin.connman", path), - "org.moblin.connman.Element") +def convert_ssid(ssid_list): + ssid = "" + for byte in ssid_list: + if (str(byte) in string.printable): + ssid = ssid + str(byte) + else: + ssid = ssid + "." + return ssid - properties = element.GetProperties() +for path in properties["Devices"]: + device = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Device") - if (properties["Type"] == "device"): - print "[ %s ]" % (path) + properties = device.GetProperties() - if (properties["Type"] == "network"): - if (properties["Connected"] == 1): - state = "*" - else: - state = " " - print " %s %s" % (state, properties["SSID"]) + if (properties["Type"] != "wifi" and properties["Type"] != "wimax"): + continue; + + print "[ %s ]" % (path) + + for path in properties["Networks"]: + network = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Network") + + properties = network.GetProperties() + + print " [ %s ]" % (path) + + for key in properties.keys(): + if (key == "WiFi.SSID"): + ssid = convert_ssid(properties[key]) + print " %s = [ %s ]" % (key, ssid) + elif (key == "Strength"): + print " %s = %d" % (key, properties[key]) + else: + print " %s = %s" % (key, properties[key]) + + print