X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Ftest-connman;h=174525a68f03a9fd7136af1e8631a1187b77828f;hb=f188bb9f375dc34491bd944677d92c5184017cca;hp=dff1a257df93e3b2269e13d4fc69e0b282586023;hpb=d071758739ad4961b30259772f4cc1066cea369e;p=framework%2Fconnectivity%2Fconnman.git diff --git a/test/test-connman b/test/test-connman index dff1a25..174525a 100755 --- a/test/test-connman +++ b/test/test-connman @@ -13,7 +13,9 @@ if len(sys.argv) < 2: print "" print " state" print " services" + print " apn [apn]" print " passphrase [passphrase]" + print " autoconnect [autoconnect]" print " connect " print " disconnect " print " remove " @@ -25,6 +27,7 @@ if len(sys.argv) < 2: print "" print " dev " print " dev scan" + print " dev scan_interval " print " dev networks" print " dev connect " print " dev disconnect [network]" @@ -146,6 +149,72 @@ def print_services(services): print "%s %-26s { %s }" % (favorite, name, identifier) +def device_handle(devices, interface): + for path in devices: + device = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Device") + + properties = device.GetProperties() + + if "Interface" not in properties.keys(): + continue + + if interface != "" and properties["Interface"] != interface: + continue + + if command == "scan": + if properties["Type"] in ["wifi", "wimax"]: + interface = properties["Interface"] + print "Scan for device %s" % (interface) + device.ProposeScan() + else: + print "No scanning for device %s" % (interface) + elif command == "scan_interval" and value != "": + device.SetProperty("ScanInterval", dbus.UInt16(value)) + elif command in ["networks", "net"]: + if "Networks" in properties.keys(): + print_networks(properties["Networks"]) + else: + print "Device has no networks" + elif command in ["connect", "conn"] and value != "": + if "Networks" in properties.keys(): + select_network(properties["Networks"], value) + else: + print "Device can't connect networks" + elif command in ["connect", "conn"]: + print "Need to specify network" + elif command in ["disconnect", "disc"] and value != "": + if "Networks" in properties.keys(): + disconnect_network(properties["Networks"], value) + else: + print "Device has no networks" + elif command in ["discconnect", "disc"]: + if "Networks" in properties.keys(): + disconnect_network(properties["Networks"], "") + else: + print "Device has no networks" + elif command == "powered" and value != "": + if value == "on": + powered = dbus.Boolean(1) + elif value == "off": + powered = dbus.Boolean(0) + else: + powered = dbus.Boolean(value) + device.SetProperty("Powered", powered) + elif command == "powered": + interface = properties["Interface"] + if properties["Powered"] == dbus.Boolean(1): + powered = "on" + else: + powered = "off" + print "Device %s is powered %s" % (interface, powered) + elif command == "list" or command == "": + print_properties(path, properties) + else: + print "Unknown command" + + + if sys.argv[1] == "state": properties = manager.GetProperties() @@ -156,6 +225,37 @@ elif sys.argv[1] in ["services", "list", "show"]: print_services(properties["Services"]) +elif sys.argv[1] in ["apn"]: + if (len(sys.argv) < 3): + print "Need at least service parameter" + sys.exit(1) + + path = "/profile/default/" + sys.argv[2] + + service = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Service") + + if (len(sys.argv) > 3): + apn = sys.argv[3] + + service.SetProperty("APN", apn); + + print "APN %s set for %s" % (apn, sys.argv[2]) + else: + properties = service.GetProperties() + + if "Name" in properties.keys(): + name = properties["Name"] + else: + name = "{" + properties["Type"] + "}" + + if "APN" in properties.keys(): + apn = properties["APN"] + else: + apn = "not set" + + print "APN for %s is %s" % (name, apn) + elif sys.argv[1] in ["passphrase", "pass"]: if (len(sys.argv) < 3): print "Need at least service parameter" @@ -187,6 +287,38 @@ elif sys.argv[1] in ["passphrase", "pass"]: print "Passphrase for %s is %s" % (name, passphrase) +elif sys.argv[1] in ["autoconnect", "autoconn"]: + if (len(sys.argv) < 3): + print "Need at least service parameter" + sys.exit(1) + + path = "/profile/default/" + sys.argv[2] + + service = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Service") + + if (len(sys.argv) > 3): + flag = sys.argv[3].strip().lower() + autoconnect = dbus.Boolean(flag not in ['false', 'f', 'n', '0']) + + service.SetProperty("AutoConnect", autoconnect); + + print "Auto connect %s for %s" % (autoconnect, sys.argv[2]) + else: + properties = service.GetProperties() + + if "Name" in properties.keys(): + name = properties["Name"] + else: + name = "{" + properties["Type"] + "}" + + if "AutoConnect" in properties.keys(): + autoconnect = properties["AutoConnect"] + else: + autoconnect = dbus.Boolean(0) + + print "Auto connect %s for %s" % (autoconnect, name) + elif sys.argv[1] in ["connect", "conn"]: if (len(sys.argv) < 3): print "Need at least service parameter" @@ -284,63 +416,13 @@ elif sys.argv[1] == "dev": if len(sys.argv) > 4: value = sys.argv[4] - for path in properties["Devices"]: - device = dbus.Interface(bus.get_object("org.moblin.connman", path), - "org.moblin.connman.Device") - - properties = device.GetProperties() + for path in properties["Technologies"]: + technology = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Technology") - if interface != "" and properties["Interface"] != interface: - continue + properties = technology.GetProperties() - if command == "scan": - if properties["Type"] in ["wifi", "wimax"]: - interface = properties["Interface"] - print "Scan for device %s" % (interface) - device.ProposeScan() - else: - print "No scanning for device %s" % (interface) - elif command in ["networks", "net"]: - if "Networks" in properties.keys(): - print_networks(properties["Networks"]) - else: - print "Device has no networks" - elif command in ["connect", "conn"] and value != "": - if "Networks" in properties.keys(): - select_network(properties["Networks"], value) - else: - print "Device can't connect networks" - elif command in ["connect", "conn"]: - print "Need to specify network" - elif command in ["disconnect", "disc"] and value != "": - if "Networks" in properties.keys(): - disconnect_network(properties["Networks"], value) - else: - print "Device has no networks" - elif command in ["discconnect", "disc"]: - if "Networks" in properties.keys(): - disconnect_network(properties["Networks"], "") - else: - print "Device has no networks" - elif command == "powered" and value != "": - if value == "on": - powered = dbus.Boolean(1) - elif value == "off": - powered = dbus.Boolean(0) - else: - powered = dbus.Boolean(value) - device.SetProperty("Powered", powered) - elif command == "powered": - interface = properties["Interface"] - if properties["Powered"] == dbus.Boolean(1): - powered = "on" - else: - powered = "off" - print "Device %s is powered %s" % (interface, powered) - elif command == "list" or command == "": - print_properties(path, properties) - else: - print "Unknown command" + device_handle(properties["Devices"], interface) else: print "Unknown command"