root/trunk/luci/modules/admin-fon/luasrc/model/cbi/fon_wifi/main.lua @ 2038

Revision 2038, 4.6 KB (checked in by matthijs, 14 months ago)

luci: Only allow enabling/disabling WPS when WPA and/or WPA2 is enabled.

Line 
1require("luci.tools.webadmin")
2
3m = Map("fon",
4        translate("public_title", "Public Wireless Settings"),
5        translate("public_desc", "This is the name of the signal the rest of the foneros will connect to. It will be automatically prefixed with the 'FON_' string"))
6
7s = m:section(NamedSection, "public", "public")
8m.events = {"ConfigFON", "HotspotChanged"}
9s:option(Value, "essid", translate("public_essid", "Signal name (SSID)FON_"))
10
11n = Map("fon",
12        translate("private_title", "Private Wireless Settings"),
13        translate("private_desc", "This is the name of the signal for your personal use."))
14
15s = n:section(NamedSection, "private", "private")
16
17s:option(Value, "essid", translate("private_essid", "Name (SSID)"))
18n.events = {"ConfigFON", "ConfigWifi"}
19
20local mode = require("luci.model.uci").cursor():get("fon", "advanced", "bgmode")
21local wanmode = require("luci.model.uci").cursor():get("fon", "wan", "mode")
22local device = require("luci.fon.spot").get_device()
23
24encr = s:option(ListValue, "encryption", translate("encryption", "Authentication"))
25encr.override_values = true
26encr:value("open", translate("wifi_open", "OPEN"))
27if mode ~= "6" then
28        encr:value("wep", translate("wifi_wep", "WEP"))
29end
30encr:value("wpa", translate("wifi_wpa", "WPA"))
31encr:value("wpa2", translate("wifi_wpa2", "WPA2"))
32encr:value("mixed", translate("wifi_mixed", "WPA/WPA2-Mixed"))
33
34key = s:option(Value, "key", translate("wifi_wepkey", "WEP Key"), "Hex 10, Hex 26")
35key:depends("encryption", "wep")
36key.rmempty = true
37
38if mode ~= "6" then
39        algo = s:option(ListValue, "wpa_crypto",  translate("wifi_cipher", "Cipher"))
40        algo:depends("encryption", "wpa")
41        algo:depends("encryption", "wpa2")
42        algo:depends("encryption", "mixed")
43        algo:value("aes", translate("wifi_cipher_aes", "AES"))
44        algo:value("tkip+aes", translate("wifi_cipher_mixed", "Mixed"))
45        algo:value("tkip", translate("wifi_cipher_tkip", "TKIP"))
46        algo.rmempty = true
47        algo.default = "aes"
48end
49
50pass = s:option(Value, "password", translate("wifi_wpa_phrase", "WPA Passphrase"))
51pass:depends("encryption", "wpa")
52pass:depends("encryption", "wpa2")
53pass:depends("encryption", "mixed")
54pass.default = require("luci.model.uci").cursor():get("fon", "private", "default_psk")
55pass.rmempty = true
56
57function pass.cfgvalue(self, section)
58        local val = Value.cfgvalue(self, section)
59        if not val then
60                val = self.default or ""
61                self:write(section, val)
62        end
63        return val
64end
65
66if device == "fonera20n" then
67        wps = s:option(ListValue, "disable_wps", translate("wps", "Wi-Fi Protected Setup (WPS)"))
68        wps.override_values = true
69        wps:value("0", translate("enable", "enable"))
70        wps:value("1", translate("disable", "disable"))
71        wps:depends("encryption", "wpa")
72        wps:depends("encryption", "wpa2")
73        wps:depends("encryption", "mixed")
74end
75
76o = Map("fon",
77        translate("wifi_adv_title", "Advanced Wireless Settings"),
78    translate("wifi_adv_desc", "The values in this page will permit you configure very specific WiFi paramters of La Fonera. All of them are optional."))
79
80s = o:section(NamedSection, "advanced", "advanced")
81o.events = {"ConfigFON", "ConfigWifi", "Offline"}
82
83-- The wifi client channel also determines the channel for the access
84-- point signals, so don't offer channel selection in wifi mode.
85if wanmode ~= "wifi" and wanmode ~= "wifi-bridge" then
86        c = s:option(ListValue, "channel", translate("wifi_channel", "Channel"))
87        c:value("auto", translate("wifi_automatic", "Automatic"))
88        for i = 1,11 do
89                c:value(i, i)
90        end
91end
92
93b = s:option(ListValue, "bgmode", translate("wifi_mode", "b/g Mode"))
94if device == "fonera20" or device == "fonera15ng" then
95        b:value("mixed", translate("wifi_mode_mixed","Mixed b/g"))
96        b:value("b", translate("wifi_mode_b", "b only"))
97        b:value("g", translate("wifi_mode_g", "g only"))
98else
99        b:value("0", translate("wifi_mode_mixed","Mixed b/g"))
100        b:value("9", translate("wifi_mode_mixed_bgn","Mixed b/g/n"))
101        b:value("7", translate("wifi_mode_mixed_gn","Mixed g/n"))
102        b:value("1", translate("wifi_mode_b", "b only"))
103        b:value("4", translate("wifi_mode_g", "g only"))
104        b:value("6", translate("wifi_mode_n", "n only"))
105        r = s:option(ListValue, "ht", translate("wifi_HT", "11N Mode"))
106        r:value("20", translate("wifi_HT20", "HT20"))
107        r:value("40", translate("wifi_HT2040", "HT20/HT40"))
108        -- HT40 mode is only available in n-only mode.
109        r:depends("bgmode", "6")
110        local util = require "luci.util"
111        local c3166 = loadfile((os.getenv("LUCI_SYSROOT") or "") .. "/etc/3166en.db.lua")()
112        c = s:option(ListValue, "country", translate("wifi_country", "Country"))
113        c.default = "ES"
114        for cc, cname in util.vspairs(c3166) do
115                c:value(string.upper(cc), cname)
116        end
117end
118
119p = Template('fon_wifi/wifi_scan_ui')
120
121return m, n, o, p
Note: See TracBrowser for help on using the browser.