X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=test%2Flist-networks;h=e8fb00a584f7263645c42592b380e8f7a07fae32;hb=a9c1d0a135e77025b9810eeb5653283b0b5278c3;hp=72a9ad18ed3145753697396e7fee0c4747eb48cd;hpb=df6b76be817b02329dd8eaa538fd9849e342d872;p=connman diff --git a/test/list-networks b/test/list-networks index 72a9ad1..e8fb00a 100755 --- a/test/list-networks +++ b/test/list-networks @@ -1,22 +1,54 @@ #!/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"): - print " %s" % (properties["SSID"]) + try: + if properties["Type"] not in ["wifi", "wimax", + "bluetooth", "cellular"]: + continue + except: + 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 in ["Strength", "Priority"]: + print " %s = %d" % (key, properties[key]) + else: + print " %s = %s" % (key, properties[key]) + + print