6 if (len(sys.argv) < 4 and sys.argv[1] == "wifi"):
7 print "Usage: %s wifi [SSID] [passphrase]" % (sys.argv[0])
9 elif (len(sys.argv) < 2):
10 print "Usage: %s type" % (sys.argv[0])
12 print "Enabling %s tethering" % (sys.argv[1])
14 bus = dbus.SystemBus()
16 manager = dbus.Interface(bus.get_object('net.connman', "/"),
17 'net.connman.Manager')
19 def technology_enable_tethering(path, tech_type, ssid, psk):
20 tech = dbus.Interface(bus.get_object("net.connman", path),
21 "net.connman.Technology")
23 properties = tech.GetProperties()
25 for key in properties.keys():
27 if properties[key] == tech_type:
29 tech.SetProperty("TetheringIdentifier",
32 tech.SetProperty("TetheringPassphrase",
34 tech.SetProperty("Tethering", dbus.Boolean(1))
36 properties = manager.GetProperties()
38 for key in properties.keys():
39 if key in ["Technologies"]:
40 for path in properties[key]:
41 if (len(sys.argv) == 4):
42 technology_enable_tethering(path, sys.argv[1],
43 sys.argv[2], sys.argv[3])
45 technology_enable_tethering(path, sys.argv[1],