+-- 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
+local _, net
+for _, net in ipairs(wdev:get_wifinets()) do
+ if net:mode() == "sta" and net:id() ~= wnet:id() then
+ has_sta = net
+ break
+ end
+end
+
+if has_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())
+else
+ ch = s:taboption("general", Value, "channel", translate("Channel"))
+ ch:value("auto", translate("auto"))
+ for _, f in ipairs(iw and iw.freqlist or luci.sys.wifi.channels()) do
+ if not f.restricted then
+ ch:value(f.channel, "%i (%.3f GHz)" %{ f.channel, f.mhz / 1000 })
+ end
+ end
+end
+
+------------------- MAC80211 Device ------------------
+
+if hwtype == "mac80211" then
+ tp = s:taboption("general",
+ (#tx_power_list > 0) and ListValue or Value,
+ "txpower", translate("Transmit Power"), "dBm")
+
+ tp.rmempty = true
+ tp.default = tx_power_cur
+
+ function tp.cfgvalue(...)
+ return txpower_current(Value.cfgvalue(...), tx_power_list)
+ end
+
+ for _, p in ipairs(tx_power_list) do
+ tp:value(p.driver_dbm, "%i dBm (%i mW)"
+ %{ p.display_dbm, p.display_mw })
+ end
+
+ mode = s:taboption("advanced", ListValue, "hwmode", translate("Mode"))
+ mode:value("", translate("auto"))
+ if hw_modes.b then mode:value("11b", "802.11b") end
+ if hw_modes.g then mode:value("11g", "802.11g") end
+ if hw_modes.a then mode:value("11a", "802.11a") end
+
+ if htcaps then
+ if hw_modes.g and hw_modes.n then mode:value("11ng", "802.11g+n") end
+ if hw_modes.a and hw_modes.n then mode:value("11na", "802.11a+n") end
+
+ htmode = s:taboption("advanced", ListValue, "htmode", translate("HT mode"))
+ htmode:depends("hwmode", "11na")
+ htmode:depends("hwmode", "11ng")
+ htmode:value("HT20", "20MHz")
+ htmode:value("HT40-", translate("40MHz 2nd channel below"))
+ htmode:value("HT40+", translate("40MHz 2nd channel above"))
+
+ --htcapab = s:taboption("advanced", DynamicList, "ht_capab", translate("HT capabilities"))
+ --htcapab:depends("hwmode", "11na")
+ --htcapab:depends("hwmode", "11ng")
+ end
+
+ local cl = iw and iw.countrylist
+ if cl and #cl > 0 then
+ cc = s:taboption("advanced", ListValue, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes."))
+ cc.default = tostring(iw and iw.country or "00")
+ for _, c in ipairs(cl) do
+ cc:value(c.alpha2, "%s - %s" %{ c.alpha2, c.name })
+ end
+ else
+ s:taboption("advanced", Value, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes."))
+ end
+
+ s:taboption("advanced", Value, "distance", translate("Distance Optimization"),
+ translate("Distance to farthest network member in meters."))
+
+ s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
+ s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
+end
+
+
+------------------- Madwifi Device ------------------
+
+if hwtype == "atheros" then
+ tp = s:taboption("general",
+ (#tx_power_list > 0) and ListValue or Value,
+ "txpower", translate("Transmit Power"), "dBm")
+
+ tp.rmempty = true
+ tp.default = tx_power_cur
+
+ function tp.cfgvalue(...)
+ return txpower_current(Value.cfgvalue(...), tx_power_list)
+ end
+
+ for _, p in ipairs(tx_power_list) do
+ tp:value(p.driver_dbm, "%i dBm (%i mW)"
+ %{ p.display_dbm, p.display_mw })
+ end
+
+ mode = s:taboption("advanced", ListValue, "hwmode", translate("Mode"))
+ mode:value("", translate("auto"))
+ if hw_modes.b then mode:value("11b", "802.11b") end
+ if hw_modes.g then mode:value("11g", "802.11g") end
+ if hw_modes.a then mode:value("11a", "802.11a") end
+ if hw_modes.g then mode:value("11bg", "802.11b+g") end
+ if hw_modes.g then mode:value("11gst", "802.11g + Turbo") end
+ if hw_modes.a then mode:value("11ast", "802.11a + Turbo") end
+ mode:value("fh", translate("Frequency Hopping"))
+
+ s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false
+
+ if not nsantenna then
+ ant1 = s:taboption("advanced", ListValue, "txantenna", translate("Transmitter Antenna"))
+ ant1.widget = "radio"
+ ant1.orientation = "horizontal"
+ ant1:depends("diversity", "")
+ ant1:value("0", translate("auto"))
+ ant1:value("1", translate("Antenna 1"))
+ ant1:value("2", translate("Antenna 2"))
+
+ ant2 = s:taboption("advanced", ListValue, "rxantenna", translate("Receiver Antenna"))
+ ant2.widget = "radio"
+ ant2.orientation = "horizontal"
+ ant2:depends("diversity", "")
+ ant2:value("0", translate("auto"))
+ ant2:value("1", translate("Antenna 1"))
+ ant2:value("2", translate("Antenna 2"))
+
+ else -- NanoFoo
+ local ant = s:taboption("advanced", ListValue, "antenna", translate("Transmitter Antenna"))
+ ant:value("auto")
+ ant:value("vertical")
+ ant:value("horizontal")
+ ant:value("external")
+ end
+
+ s:taboption("advanced", Value, "distance", translate("Distance Optimization"),
+ translate("Distance to farthest network member in meters."))
+ s:taboption("advanced", Value, "regdomain", translate("Regulatory Domain"))
+ s:taboption("advanced", Value, "country", translate("Country Code"))
+ s:taboption("advanced", Flag, "outdoor", translate("Outdoor Channels"))
+
+ --s:option(Flag, "nosbeacon", translate("Disable HW-Beacon timer"))
+end
+
+
+
+------------------- Broadcom Device ------------------
+
+if hwtype == "broadcom" then
+ tp = s:taboption("general",
+ (#tx_power_list > 0) and ListValue or Value,
+ "txpower", translate("Transmit Power"), "dBm")
+
+ tp.rmempty = true
+ tp.default = tx_power_cur
+
+ function tp.cfgvalue(...)
+ return txpower_current(Value.cfgvalue(...), tx_power_list)
+ end
+
+ for _, p in ipairs(tx_power_list) do
+ tp:value(p.driver_dbm, "%i dBm (%i mW)"
+ %{ p.display_dbm, p.display_mw })
+ end
+
+ mode = s:taboption("advanced", ListValue, "hwmode", translate("Mode"))
+ mode:value("11bg", "802.11b+g")
+ mode:value("11b", "802.11b")
+ mode:value("11g", "802.11g")
+ mode:value("11gst", "802.11g + Turbo")
+
+ ant1 = s:taboption("advanced", ListValue, "txantenna", translate("Transmitter Antenna"))
+ ant1.widget = "radio"
+ ant1:depends("diversity", "")
+ ant1:value("3", translate("auto"))
+ ant1:value("0", translate("Antenna 1"))
+ ant1:value("1", translate("Antenna 2"))
+
+ ant2 = s:taboption("advanced", ListValue, "rxantenna", translate("Receiver Antenna"))
+ ant2.widget = "radio"
+ ant2:depends("diversity", "")
+ ant2:value("3", translate("auto"))
+ ant2:value("0", translate("Antenna 1"))
+ ant2:value("1", translate("Antenna 2"))
+
+ s:taboption("advanced", Flag, "frameburst", translate("Frame Bursting"))
+
+ s:taboption("advanced", Value, "distance", translate("Distance Optimization"))
+ --s:option(Value, "slottime", translate("Slot time"))
+
+ s:taboption("advanced", Value, "country", translate("Country Code"))
+ s:taboption("advanced", Value, "maxassoc", translate("Connection Limit"))
+end
+
+
+--------------------- HostAP Device ---------------------
+
+if hwtype == "prism2" then
+ s:taboption("advanced", Value, "txpower", translate("Transmit Power"), "att units").rmempty = true
+
+ s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false
+
+ s:taboption("advanced", Value, "txantenna", translate("Transmitter Antenna"))
+ s:taboption("advanced", Value, "rxantenna", translate("Receiver Antenna"))
+end
+
+
+----------------------- Interface -----------------------
+
+s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configuration"))
+ifsection = s
+s.addremove = false