Include security setting for network selection
[connman] / test / connect-network
1 #!/usr/bin/python
2
3 import sys
4 import dbus
5
6 if (len(sys.argv) < 2):
7         print "Usage: %s <network>" % (sys.argv[0])
8         sys.exit(1)
9
10 bus = dbus.SystemBus()
11
12 manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
13                                         "org.moblin.connman.Manager")
14
15 properties = manager.GetProperties()
16
17 for path in properties["Devices"]:
18         device = dbus.Interface(bus.get_object("org.moblin.connman", path),
19                                                 "org.moblin.connman.Device")
20
21         properties = device.GetProperties()
22
23         if properties["Type"] not in ["wifi", "wimax",
24                                         "bluetooth", "cellular"]:
25                 continue;
26
27         for path in properties["Networks"]:
28                 network = dbus.Interface(bus.get_object("org.moblin.connman", path),
29                                                 "org.moblin.connman.Network")
30
31                 properties = network.GetProperties()
32
33                 dev = path[path.rfind("/") + 1:]
34
35                 if dev == sys.argv[1] or properties["Name"] == sys.argv[1]:
36                         print "Connecting %s" % (path)
37                         network.Connect()