6 if (len(sys.argv) >= 2 and len(sys.argv) < 4 and sys.argv[1] == "wifi"):
7 print "Usage: %s wifi [SSID] [passphrase] [hidden]" % (sys.argv[0])
9 print "Create the open system access point:"
10 print "%s wifi abcd \"\"" % (sys.argv[0])
11 print "Create the security access point:"
12 print "%s wifi abcd 123456789" % (sys.argv[0])
13 print "Create the hidden access point:"
14 print "%s wifi abcd 123456789 hidden" % (sys.argv[0])
15 print "Create the open and hidden access point:"
16 print "%s wifi abcd \"\" hidden" % (sys.argv[0])
18 elif (len(sys.argv) < 2):
19 print "Usage: %s type" % (sys.argv[0])
22 bus = dbus.SystemBus()
24 manager = dbus.Interface(bus.get_object('net.connman', "/"),
25 'net.connman.Manager')
27 def technology_enable_tethering(path, tech_type, ssid, psk, hidden):
28 tech = dbus.Interface(bus.get_object("net.connman", path),
29 "net.connman.Technology")
31 properties = tech.GetProperties()
33 for key in properties.keys():
35 if properties[key] == tech_type:
37 tech.SetProperty("TetheringIdentifier",
39 tech.SetProperty("TetheringPassphrase",
41 if tech_type == "wifi":
43 if hidden == "hidden":
44 tech.SetProperty("Hidden",dbus.Boolean(1))
46 tech.SetProperty("Hidden",dbus.Boolean(0))
48 tech.SetProperty("Hidden",dbus.Boolean(0))
50 print "Enabling %s tethering" % tech_type
51 tech.SetProperty("Tethering", dbus.Boolean(1))
57 technologies = manager.GetTechnologies()
60 for path,_ in technologies:
61 if (len(sys.argv) == 5):
62 tech = technology_enable_tethering(path,
63 sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
64 elif (len(sys.argv) == 4):
65 tech = technology_enable_tethering(path,
66 sys.argv[1], sys.argv[2], sys.argv[3], "")
68 tech = technology_enable_tethering(path, sys.argv[1], "", "", "")
74 print "Failed to enable %s tethering" % (sys.argv[1])