summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-08-19 22:51:56 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-08-19 22:51:56 +0000
commita7e524bb7f1e230ed8e69ddcc42875704b98eaef (patch)
treedbe1ae51fc56959b0628be393e20a8c5631b6d5c
parent9e04d7e6d1015f8fe60289a347bade858fa0fa09 (diff)
modules/admin-full: use driver supported values in txpower control
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua56
1 files changed, 44 insertions, 12 deletions
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
index 3bfa6d28ae..bbf2232c24 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
@@ -19,6 +19,18 @@ arg[1] = arg[1] or ""
m = Map("wireless", translate("networks"), translate("a_w_networks1"))
+
+local iw = nil
+local tx_powers = nil
+
+m.uci:foreach("wireless", "wifi-iface",
+ function(s)
+ if s.device == arg[1] and s.ifname and not iw then
+ iw = luci.sys.wifi.getiwinfo(s.ifname)
+ tx_powers = iw.txpwrlist or { }
+ end
+ end)
+
s = m:section(NamedSection, arg[1], "wifi-device", translate("device") .. " " .. arg[1])
s.addremove = false
@@ -57,14 +69,28 @@ end
------------------- MAC80211 Device ------------------
if hwtype == "mac80211" then
- s:taboption("general", Value, "txpower", translate("a_w_txpwr"), "dBm").rmempty = true
+ tp = s:taboption("general",
+ (#tx_powers > 0) and ListValue or Value,
+ "txpower", translate("a_w_txpwr"), "dBm")
+
+ tp.rmempty = true
+ for _, p in ipairs(iw.txpwrlist) do
+ tp:value(p.dbm, "%i dBm (%i mW)" %{ p.dbm, p.mw })
+ end
end
------------------- Madwifi Device ------------------
if hwtype == "atheros" then
- s:taboption("general", Value, "txpower", translate("a_w_txpwr"), "dBm").rmempty = true
+ tp = s:taboption("general",
+ (#tx_powers > 0) and ListValue or Value,
+ "txpower", translate("a_w_txpwr"), "dBm")
+
+ tp.rmempty = true
+ for _, p in ipairs(iw.txpwrlist) do
+ tp:value(p.dbm, "%i dBm (%i mW)" %{ p.dbm, p.mw })
+ end
mode = s:taboption("advanced", ListValue, "hwmode", translate("mode"))
mode:value("", translate("wifi_auto"))
@@ -102,7 +128,14 @@ end
------------------- Broadcom Device ------------------
if hwtype == "broadcom" then
- s:taboption("advanced", Value, "txpower", translate("a_w_txpwr"), "dBm").rmempty = true
+ tp = s:taboption("general",
+ (#tx_powers > 0) and ListValue or Value,
+ "txpower", translate("a_w_txpwr"), "dBm")
+
+ tp.rmempty = true
+ for _, p in ipairs(iw.txpwrlist) do
+ tp:value(p.dbm, "%i dBm (%i mW)" %{ p.dbm, p.mw })
+ end
mp = s:taboption("macfilter", ListValue, "macfilter", translate("wifi_macpolicy"))
mp:value("", translate("disable"))
@@ -152,6 +185,14 @@ s:tab("advanced", translate("a_w_advanced", "Advanced Settings"))
s:taboption("general", Value, "ssid", translate("wifi_essid"))
+mode = s:taboption("general", ListValue, "mode", translate("mode"))
+mode.override_values = true
+mode:value("ap", translate("a_w_ap"))
+mode:value("sta", translate("a_w_client"))
+mode:value("adhoc", translate("a_w_adhoc"))
+
+bssid = s:taboption("general", Value, "bssid", translate("wifi_bssid"))
+
network = s:taboption("general", Value, "network", translate("network"), translate("a_w_network1"))
network.rmempty = true
network:value("")
@@ -174,15 +215,6 @@ function network.write(self, section, value)
end
-mode = s:taboption("general", ListValue, "mode", translate("mode"))
-mode.override_values = true
-mode:value("ap", translate("a_w_ap"))
-mode:value("sta", translate("a_w_client"))
-mode:value("adhoc", translate("a_w_adhoc"))
-
-bssid = s:taboption("general", Value, "bssid", translate("wifi_bssid"))
-
-
-------------------- MAC80211 Interface ----------------------
if hwtype == "mac80211" then