--- /dev/null
+#!/usr/bin/python
+
+import dbus
+
+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")
+
+ properties = element.GetProperties()
+ if (properties["Type"] != "network"):
+ continue
+
+ if (properties["Connected"] == dbus.Boolean(1)):
+ print "Disconnecting %s" % (path)
+ element.Disconnect()
#!/usr/bin/python
+import sys
import dbus
-bus = dbus.SystemBus()
-
-manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
- 'org.moblin.connman.Manager')
+if (len(sys.argv) < 2):
+ print "Usage: %s <network>" % (sys.argv[0])
+ sys.exit(1)
-interfaces = manager.ListInterfaces()
+bus = dbus.SystemBus()
-for path in interfaces:
- print "[ %s ]" % (path)
+manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
+ "org.moblin.connman.Manager")
- interface = dbus.Interface(bus.get_object('org.moblin.connman', path),
- 'org.moblin.connman.Interface')
+elements = manager.ListElements()
- properties = interface.GetProperties()
+for path in elements:
+ element = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Element")
- if (properties["Type"] == "80211"):
- networks = interface.ListNetworks()
- for i in networks:
- network = dbus.Interface(bus.get_object('org.moblin.connman', i),
- 'org.moblin.connman.Network')
+ properties = element.GetProperties()
+ if (properties["Type"] != "network"):
+ continue
- if (network.GetIdentifier() == "ConnMan Testing"):
- print " Selecting network %s" % (i)
- interface.SelectNetwork(i)
- else:
- print " No networks"
+ if (properties["Connected"] == dbus.Boolean(1)):
+ continue
- print
+ if (properties["Identifier"] == sys.argv[1]):
+ print "Connecting %s" % (path)
+ element.Connect()