6 if (len(sys.argv) >= 2 and 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])
13 bus = dbus.SystemBus()
15 manager = dbus.Interface(bus.get_object('net.connman', "/"),
16 'net.connman.Manager')
18 def technology_enable_tethering(path, tech_type, ssid, psk):
19 tech = dbus.Interface(bus.get_object("net.connman", path),
20 "net.connman.Technology")
22 properties = tech.GetProperties()
24 for key in properties.keys():
26 if properties[key] == tech_type:
28 tech.SetProperty("TetheringIdentifier",
31 tech.SetProperty("TetheringPassphrase",
33 print "Enabling %s tethering" % tech_type
34 tech.SetProperty("Tethering", dbus.Boolean(1))
40 technologies = manager.GetTechnologies()
43 for path,_ in technologies:
44 if (len(sys.argv) == 4):
45 tech = technology_enable_tethering(path,
46 sys.argv[1], sys.argv[2], sys.argv[3])
48 tech = technology_enable_tethering(path, sys.argv[1], "", "")
54 print "Failed to enable %s tethering" % (sys.argv[1])