diff options
Diffstat (limited to 'applications/luci-app-travelmate/luasrc')
5 files changed, 75 insertions, 15 deletions
diff --git a/applications/luci-app-travelmate/luasrc/controller/travelmate.lua b/applications/luci-app-travelmate/luasrc/controller/travelmate.lua index 0f7583497f..14b8d77ff6 100644 --- a/applications/luci-app-travelmate/luasrc/controller/travelmate.lua +++ b/applications/luci-app-travelmate/luasrc/controller/travelmate.lua @@ -3,7 +3,6 @@ module("luci.controller.travelmate", package.seeall) -local fs = require("nixio.fs") local util = require("luci.util") local i18n = require("luci.i18n") local templ = require("luci.template") @@ -15,7 +14,8 @@ function index() entry({"admin", "services", "travelmate"}, firstchild(), _("Travelmate"), 40).dependent = false entry({"admin", "services", "travelmate", "tab_from_cbi"}, cbi("travelmate/overview_tab", {hideresetbtn=true, hidesavebtn=true}), _("Overview"), 10).leaf = true entry({"admin", "services", "travelmate", "stations"}, template("travelmate/stations"), _("Wireless Stations"), 20).leaf = true - entry({"admin", "services", "travelmate", "logfile"}, call("logread"), _("View Logfile"), 30).leaf = true + entry({"admin", "services", "travelmate", "apqr"}, template("travelmate/ap_qr"), _("AP QR-Codes"), 30).leaf = true + entry({"admin", "services", "travelmate", "logfile"}, call("logread"), _("View Logfile"), 40).leaf = true entry({"admin", "services", "travelmate", "advanced"}, firstchild(), _("Advanced"), 100) entry({"admin", "services", "travelmate", "advanced", "configuration"}, cbi("travelmate/configuration_tab"), _("Edit Travelmate Configuration"), 110).leaf = true entry({"admin", "services", "travelmate", "advanced", "cfg_wireless"}, cbi("travelmate/cfg_wireless_tab"), _("Edit Wireless Configuration"), 120).leaf = true diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua index 4fec920f76..860ce2295b 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua @@ -8,9 +8,9 @@ local util = require("luci.util") local nw = require("luci.model.network").init() local fw = require("luci.model.firewall").init() local dump = util.ubus("network.interface", "dump", {}) -local trmiface = uci.get("travelmate", "global", "trm_iface") or "trm_wwan" -local trminput = uci.get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json" -local uplink = uci.get("network", trmiface) or "" +local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan" +local trminput = uci:get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json" +local uplink = uci:get("network", trmiface) or "" local parse = json.parse(fs.readfile(trminput) or "") m = Map("travelmate", translate("Travelmate"), @@ -181,28 +181,27 @@ e2.datatype = "and(uciname,rangelength(6,6))" e2.rmempty = true e3 = e:option(Value, "trm_maxretry", translate("Connection Limit"), - translate("Retry limit to connect to an uplink. ") - .. translate("To disable this feature set it to '0' which means unlimited retries.")) + translate("Retry limit to connect to an uplink.")) e3.default = 3 -e3.datatype = "range(0,30)" +e3.datatype = "range(1,10)" e3.rmempty = false e4 = e:option(Value, "trm_minquality", translate("Signal Quality Threshold"), translate("Minimum signal quality threshold as percent for conditional uplink (dis-) connections.")) -e4.default = 30 -e4.datatype = "range(0,100)" +e4.default = 35 +e4.datatype = "range(20,80)" e4.rmempty = false e5 = e:option(Value, "trm_maxwait", translate("Interface Timeout"), - translate("How long should travelmate wait for a successful wlan interface reload.")) + translate("How long should travelmate wait for a successful wlan uplink connection.")) e5.default = 30 -e5.datatype = "range(5,60)" +e5.datatype = "range(20,40)" e5.rmempty = false e6 = e:option(Value, "trm_timeout", translate("Overall Timeout"), translate("Timeout in seconds between retries in 'automatic' mode.")) e6.default = 60 -e6.datatype = "range(60,300)" +e6.datatype = "range(30,300)" e6.rmempty = false return m diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua index 93e8a05cf8..50edd17bb8 100644 --- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua +++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua @@ -4,7 +4,7 @@ local fs = require("nixio.fs") local uci = require("luci.model.uci").cursor() local http = require("luci.http") -local trmiface = uci.get("travelmate", "global", "trm_iface") or "trm_wwan" +local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan" local encr_psk = {"psk", "psk2", "psk-mixed"} local encr_wpa = {"wpa", "wpa2", "wpa-mixed"} diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm new file mode 100644 index 0000000000..13342a3e66 --- /dev/null +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm @@ -0,0 +1,62 @@ +<%# +Copyright 2018 Dirk Brenken (dev@brenken.org) +This is free software, licensed under the Apache License, Version 2.0 +-%> + +<%+header%> + +<div class="cbi-map"> + <div class="cbi-map-descr"> + <%=translate("Here you'll find the QR codes from all of your configured Access Points. It allows you to connect your Android or iOS devices to your router's WiFi using the QR code shown below.")%> + </div> +<%- + local write = io.write + local uci = require("luci.model.uci").cursor() + + uci:foreach("wireless", "wifi-iface", function(s) + local device = s.device or "" + local mode = s.mode or "" + local ssid = s.ssid or "" + local enc = s.encryption or "" + local key = s.key or "" + local hidden = s.hidden or "false" + local disabled = s.disabled or "" + local wep_slots = {s.key1 or "", s.key2 or "", s.key3 or "", s.key4 or ""} + + if device and mode == "ap" and disabled ~= "1" then + if string.match(enc, '^psk') then + enc = "WPA" + elseif string.match(enc, '^wep') then + enc = "WEP" + if tonumber(key) then + key = wep_slots[tonumber(key)] + end + elseif enc == "none" then + enc = "nopass" + key = "nokey" + else + enc = "" + end + if hidden == "1" then + hidden = "true" + end + if ssid and enc and key then + local e_ssid = string.gsub(ssid,"[\"\\';:, ]",[[\\\%1]]) + local e_key = string.gsub(key,"[\"\\';:, ]",[[\\\%1]]) + local qrcode = "" + if nixio.fs.access("/usr/bin/qrencode") then + qrcode = luci.sys.exec("/usr/bin/qrencode --inline --8bit --type=SVG --output=- 'WIFI:S:\"'" .. e_ssid .. "'\";T:'" .. enc .. "';P:\"'" .. e_key .. "'\";H:'" .. hidden .. "';'") + end +-%> + <fieldset class="cbi-section"> + <legend>AP on <%=device%> with SSID "<%=ssid%>"</legend> + <h3 name="content"><%=qrcode%></h3> + </fieldset> +<%- + end + end + end) +%> +</div> + +<%+footer%> diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm index a267339950..1dacb6e24b 100644 --- a/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm +++ b/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm @@ -12,7 +12,6 @@ This is free software, licensed under the Apache License, Version 2.0 <%+header%> <div class="cbi-map"> -<h2 name="content"><%:Wireless Stations%></h2> <div class="cbi-map-descr"> <%=translatef("Provides an overview of all configured uplinks for the travelmate interface (%s). You can edit, delete or re-order existing uplinks or scan for a new one. The currently used uplink is emphasized in blue.", trmiface)%> </div> |