| 1 | require("luci.tools.webadmin") |
|---|
| 2 | |
|---|
| 3 | m = 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 | |
|---|
| 7 | s = m:section(NamedSection, "public", "public") |
|---|
| 8 | m.events = {"ConfigFON", "HotspotChanged"} |
|---|
| 9 | s:option(Value, "essid", translate("public_essid", "Signal name (SSID)FON_")) |
|---|
| 10 | |
|---|
| 11 | n = 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 | |
|---|
| 15 | s = n:section(NamedSection, "private", "private") |
|---|
| 16 | |
|---|
| 17 | s:option(Value, "essid", translate("private_essid", "Name (SSID)")) |
|---|
| 18 | n.events = {"ConfigFON", "ConfigWifi"} |
|---|
| 19 | |
|---|
| 20 | local mode = require("luci.model.uci").cursor():get("fon", "advanced", "bgmode") |
|---|
| 21 | local wanmode = require("luci.model.uci").cursor():get("fon", "wan", "mode") |
|---|
| 22 | local device = require("luci.fon.spot").get_device() |
|---|
| 23 | |
|---|
| 24 | encr = s:option(ListValue, "encryption", translate("encryption", "Authentication")) |
|---|
| 25 | encr.override_values = true |
|---|
| 26 | encr:value("open", translate("wifi_open", "OPEN")) |
|---|
| 27 | if mode ~= "6" then |
|---|
| 28 | encr:value("wep", translate("wifi_wep", "WEP")) |
|---|
| 29 | end |
|---|
| 30 | encr:value("wpa", translate("wifi_wpa", "WPA")) |
|---|
| 31 | encr:value("wpa2", translate("wifi_wpa2", "WPA2")) |
|---|
| 32 | encr:value("mixed", translate("wifi_mixed", "WPA/WPA2-Mixed")) |
|---|
| 33 | |
|---|
| 34 | key = s:option(Value, "key", translate("wifi_wepkey", "WEP Key"), "Hex 10, Hex 26") |
|---|
| 35 | key:depends("encryption", "wep") |
|---|
| 36 | key.rmempty = true |
|---|
| 37 | |
|---|
| 38 | if 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" |
|---|
| 48 | end |
|---|
| 49 | |
|---|
| 50 | pass = s:option(Value, "password", translate("wifi_wpa_phrase", "WPA Passphrase")) |
|---|
| 51 | pass:depends("encryption", "wpa") |
|---|
| 52 | pass:depends("encryption", "wpa2") |
|---|
| 53 | pass:depends("encryption", "mixed") |
|---|
| 54 | pass.default = require("luci.model.uci").cursor():get("fon", "private", "default_psk") |
|---|
| 55 | pass.rmempty = true |
|---|
| 56 | |
|---|
| 57 | function 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 |
|---|
| 64 | end |
|---|
| 65 | |
|---|
| 66 | if 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") |
|---|
| 74 | end |
|---|
| 75 | |
|---|
| 76 | o = 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 | |
|---|
| 80 | s = o:section(NamedSection, "advanced", "advanced") |
|---|
| 81 | o.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. |
|---|
| 85 | if 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 |
|---|
| 91 | end |
|---|
| 92 | |
|---|
| 93 | b = s:option(ListValue, "bgmode", translate("wifi_mode", "b/g Mode")) |
|---|
| 94 | if 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")) |
|---|
| 98 | else |
|---|
| 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 |
|---|
| 117 | end |
|---|
| 118 | |
|---|
| 119 | p = Template('fon_wifi/wifi_scan_ui') |
|---|
| 120 | |
|---|
| 121 | return m, n, o, p |
|---|