From fadfc64e16d738f521d974ce24fd3e361dfa1cae Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 4 May 2015 19:07:33 +0200 Subject: [PATCH] gluon-luci-wifi-config: don't use luci.sys.wifi.getiwinfo() Directly using libiwinfo is more reliable. --- .../lua/luci/model/cbi/admin/wifi-config.lua | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/package/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua b/package/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua index 720346d3..591e944e 100644 --- a/package/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua +++ b/package/gluon-luci-wifi-config/files/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua @@ -1,5 +1,6 @@ local uci = luci.model.uci.cursor() local fs = require 'nixio.fs' +local iwinfo = require 'iwinfo' local function find_phy_by_path(path) @@ -17,9 +18,9 @@ local function find_phy_by_macaddr(macaddr) end end -local function txpower_list(iw) - local list = iw.txpwrlist or { } - local off = tonumber(iw.txpower_offset) or 0 +local function txpower_list(phy) + local list = iwinfo.nl80211.txpwrlist(phy) or { } + local off = tonumber(iwinfo.nl80211.txpower_offset(phy)) or 0 local new = { } local prev = -1 local _, val @@ -93,22 +94,19 @@ for _, radio in ipairs(radios) do end if phy then - local iw = luci.sys.wifi.getiwinfo(phy) - if iw then - local txpowers = txpower_list(iw) + local txpowers = txpower_list(phy) - if #txpowers > 1 then - local tp = p:option(ListValue, radio .. '_txpower', translate("Transmission power")) - tp.rmempty = true - tp.default = uci:get('wireless', radio, 'txpower') or 'default' + if #txpowers > 1 then + local tp = p:option(ListValue, radio .. '_txpower', translate("Transmission power")) + tp.rmempty = true + tp.default = uci:get('wireless', radio, 'txpower') or 'default' - tp:value('default', translate("(default)")) + tp:value('default', translate("(default)")) - table.sort(txpowers, function(a, b) return a.driver_dbm > b.driver_dbm end) + table.sort(txpowers, function(a, b) return a.driver_dbm > b.driver_dbm end) - for _, entry in ipairs(txpowers) do - tp:value(entry.driver_dbm, "%i dBm (%i mW)" % {entry.display_dbm, entry.display_mw}) - end + for _, entry in ipairs(txpowers) do + tp:value(entry.driver_dbm, "%i dBm (%i mW)" % {entry.display_dbm, entry.display_mw}) end end end