diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-12-03 22:55:35 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-12-03 22:55:35 +0100 |
commit | 1a3b9647cf270105ddc3d62ade586a776dc93592 (patch) | |
tree | af9f879c63224961ab06fb5d950298d42b8c3bbf /test | |
parent | 51b3dc6f611f7a0b1bbf309a4ac766a696828fff (diff) | |
download | connman-1a3b9647cf270105ddc3d62ade586a776dc93592.tar.gz connman-1a3b9647cf270105ddc3d62ade586a776dc93592.tar.bz2 connman-1a3b9647cf270105ddc3d62ade586a776dc93592.zip |
Use network interface for connecting and disconnecting
Diffstat (limited to 'test')
-rwxr-xr-x | test/disable-network | 35 | ||||
-rwxr-xr-x | test/select-network | 30 |
2 files changed, 37 insertions, 28 deletions
diff --git a/test/disable-network b/test/disable-network index eede449b..beea2f10 100755 --- a/test/disable-network +++ b/test/disable-network @@ -7,19 +7,22 @@ bus = dbus.SystemBus() manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"), "org.moblin.connman.Manager") -elements = manager.ListElements() - -for path in elements: - element = dbus.Interface(bus.get_object("org.moblin.connman", path), - "org.moblin.connman.Element") - - try: - properties = element.GetProperties() - if (properties["Type"] != "network"): - continue - - if (properties["Enabled"] == dbus.Boolean(1)): - print "Disabling %s" % (path) - element.Disable() - except: - pass +properties = manager.GetProperties() + +for path in properties["Devices"]: + device = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Device") + + properties = device.GetProperties() + + 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() + + if (properties["Connected"] == dbus.Boolean(1)): + print "Disconnecting %s" % (path) + network.Disconnect() diff --git a/test/select-network b/test/select-network index 76845469..e7491e8a 100755 --- a/test/select-network +++ b/test/select-network @@ -12,19 +12,25 @@ 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") +for path in properties["Devices"]: + device = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Device") - properties = element.GetProperties() - if (properties["Type"] != "network"): - continue + properties = device.GetProperties() - if (properties["Enabled"] == dbus.Boolean(1)): - continue + print "[ %s ]" % (path) - if (properties["WiFi.Name"] == sys.argv[1]): - print "Enabling %s" % (path) - element.Enable() + for path in properties["Networks"]: + network = dbus.Interface(bus.get_object("org.moblin.connman", path), + "org.moblin.connman.Network") + + properties = network.GetProperties() + + if (properties["Connected"] == dbus.Boolean(1)): + continue + + if (properties["WiFi.Name"] == sys.argv[1]): + print "Connecting %s" % (path) + network.Connect() |