Developing lightweight computation at the DSG edge

Commit 60e7750d authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] Show country selection in qMp easy setup



Closes #461
Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent c11e920a
......@@ -78,7 +78,7 @@ configure() {
log "[Preparing wifi]"
country="$(uci get qmp.wireless.country 2>/dev/null)"
country="${country:-00}"
country="${country:-US}"
log Using countrycode $country
prepare_wifi
......
......@@ -26,6 +26,14 @@ local uciout = luci.model.uci.cursor()
package.path = package.path .. ";/etc/qmp/?.lua"
qmpinfo = require "qmpinfo"
local wdevs = qmpinfo.get_wifi_index()
for _,wdev in ipairs(wdevs) do
mydev = uci:get("qmp",wdev,"device")
end
local iw = luci.sys.wifi.getiwinfo(mydev)
------------
-- Header --
------------
......@@ -325,6 +333,20 @@ for i,v in ipairs(devices.wifi) do
nodedevs_wifi[i] = {v,wmode,wchan}
end
-- Country selection (global, not per-device)
local cl = iw and iw.countrylist
if cl and #cl > 0 then
wcountry = m:field(ListValue, "country", translate("Country"))
wcountry.default = uciout:get("qmp","wireless","country")
for _, s in ipairs(cl) do
wcountry:value(s.alpha2, "%s - %s" %{ s.alpha2, s.name })
end
else
wcountry = m:field(Value, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes."))
end
function nodemode.write(self, section, value)
......@@ -419,6 +441,9 @@ function nodemode.write(self, section, value)
uciout:set("qmp","interfaces","wan_devices",wan_devices)
uciout:set("qmp","interfaces","mesh_devices",mesh_devices)
local country = wcountry:formvalue(section)
uciout:set("qmp", "wireless", "country", country)
uciout:commit("qmp")
apply()
end
......
......@@ -57,7 +57,7 @@ if cl and #cl > 0 then
end
else
s_wireless_main:option(Value, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes2."))
s_wireless_main:option(Value, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes."))
end
-- BSSID
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment