wifi.lua: Add support for toggling WPS button.
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / wifi.lua
index 4ae2f77..f6becf0 100644 (file)
@@ -22,7 +22,7 @@ arg[1] = arg[1] or ""
 
 m = Map("wireless", "",
        translate("The <em>Device Configuration</em> section covers physical settings of the radio " ..
-               "hardware such as channel, transmit power or antenna selection which is shared among all " ..
+               "hardware such as channel, transmit power or antenna selection which are shared among all " ..
                "defined wireless networks (if the radio hardware is multi-SSID capable). Per network settings " ..
                "like encryption or operation mode are grouped in the <em>Interface Configuration</em>."))
 
@@ -147,21 +147,27 @@ local hwtype = wdev:get("type")
 -- NanoFoo
 local nsantenna = wdev:get("antenna")
 
--- Check whether there is a client interface on the same radio,
--- if yes, lock the channel choice as the station will dicatate the freq
-local has_sta = nil
+-- Check whether there are client interfaces on the same radio,
+-- if yes, lock the channel choice as these stations will dicatate the freq
+local found_sta = nil
 local _, net
-for _, net in ipairs(wdev:get_wifinets()) do
-       if net:mode() == "sta" and net:id() ~= wnet:id() then
-               has_sta = net
-               break
+if wnet:mode() ~= "sta" then
+       for _, net in ipairs(wdev:get_wifinets()) do
+               if net:mode() == "sta" then
+                       if not found_sta then
+                               found_sta = {}
+                               found_sta.channel = net:channel()
+                               found_sta.names = {}
+                       end
+                       found_sta.names[#found_sta.names+1] = net:shortname()
+               end
        end
 end
 
-if has_sta then
+if found_sta then
        ch = s:taboption("general", DummyValue, "choice", translate("Channel"))
-       ch.value = translatef("Locked to channel %d used by %s",
-               has_sta:channel(), has_sta:shortname())
+       ch.value = translatef("Locked to channel %d used by: %s",
+               found_sta.channel, table.concat(found_sta.names, ", "))
 else
        ch = s:taboption("general", Value, "channel", translate("Channel"))
        ch:value("auto", translate("auto"))
@@ -192,7 +198,16 @@ if hwtype == "mac80211" then
 
        mode = s:taboption("advanced", ListValue, "hwmode", translate("Band"))
 
-       if hw_modes.n then
+       if hw_modes.ac then
+               if hw_modes.ac then mode:value("11a", "5GHz (802.11n+ac)") end
+
+               htmode = s:taboption("advanced", ListValue, "htmode", translate("VHT mode (802.11ac)"))
+               htmode:value("", translate("disabled"))
+               htmode:value("VHT20", "20MHz")
+               htmode:value("VHT40", "40MHz")
+               htmode:value("VHT80", "80MHz")
+
+       elseif hw_modes.n then
                if hw_modes.g then mode:value("11g", "2.4GHz (802.11g+n)") end
                if hw_modes.a then mode:value("11a", "5GHz (802.11a+n)") end
 
@@ -960,4 +975,18 @@ if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
        password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
 end
 
+if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
+       local wpasupplicant = fs.access("/usr/sbin/wpa_supplicant")
+       local hostcli = fs.access("/usr/sbin/hostapd_cli")
+       if hostcli and wpasupplicant then
+               wps = s:taboption("encryption", Flag, "wps_pushbutton", translate("Enable WPS pushbutton, requires WPA(2)-PSK"))
+               wps.enabled = "1"
+               wps.disabled = "0"
+               wps.rmempty = false
+               wps:depends("encryption", "psk")
+               wps:depends("encryption", "psk2")
+               wps:depends("encryption", "psk-mixed")
+       end
+end
+
 return m