1 local uci = require "luci.model.uci".cursor()
2 local a = require "luci.model.ipkg"
3 local DISP = require "luci.dispatcher"
5 local wlcursor = luci.model.uci.cursor_state()
6 local wireless = wlcursor:get_all("wireless")
9 for k, v in pairs(wireless) do
10 if v[".type"] == "wifi-iface" then
11 table.insert(ifaces, v)
18 s = m:section(NamedSection, "internet", "rule", translate("Configuration"), translate("Check Internet connectivity via HTTP header download"))
20 hosts = s:option(DynamicList, "hosts", translate("List of host addresses"), translate("List of host addresses (url or IP) to track and request http headers from"))
21 hosts.datatype = "string"
23 interval = s:option(Value, "interval", translate("Test-run interval"), translate("Time interval in seconds to re-start a new test run"))
24 interval.datatype = "uinteger"
25 interval.default = "30"
27 offline_treshold = s:option(Value, "offline_threshold", translate("Switch_to_offline threshold"), translate("Failure counter after how many failed download attempts, the state is considered as offline"))
28 offline_treshold.datatype = "uinteger"
29 offline_treshold.default = "1"
31 add_hostname_to_ssid = s:option(Flag, "add_hostname_to_ssid", translate("Append hostname to ssid"), translate("Append the router's hostname to the SSID when connectivity check fails"))
32 add_hostname_to_ssid.rmempty = false
35 if (a.installed("curl") == true) then
36 use_curl = s:option(Flag, "use_curl", translate("Use curl"), translate("Use curl instead of wget for testing the connectivity."))
37 use_curl.rmempty = false
39 curl_interface = s:option(Value, "curl_interface", translate("Used interface"), translate("Which interface should curl use. (Use ifconfig to find out)"))
40 curl_interface.datatype = "string"
41 curl_interface:depends("use_curl","1")
42 curl_interface.placeholder = "eth0"
44 use_curl = s:option(Flag, "use_curl", translate("Use curl instead of wget"), translate("Curl is currently not installed.")
45 .." Please install the package in the "
46 ..[[<a href="]] .. DISP.build_url("admin", "system", "packages")
47 .. "?display=available&query=curl"..[[">]]
48 .. "Software Section" .. [[</a>]]
51 use_curl.rmempty = false
52 use_curl.template = "dynapoint/cbi_checkbox"
55 m1 = Map("wireless", "DynaPoint", translate("Dynamic Access Point Manager"))
57 aps = m1:section(TypedSection, "wifi-iface", translate("List of Wireless Virtual Interfaces (wVIF)"))
60 aps.template = "cbi/tblsection"
62 status = aps:option(DummyValue, "disabled", translate("WiFi Status"))
63 status.template = "dynapoint/cbi_color"
65 function status.cfgvalue(self,section)
66 local val = m1:get(section, "disabled")
67 if val == "1" then return translate("Disabled") end
68 if (val == nil or val == "0") then return translate("Enabled") end
72 device = aps:option(DummyValue, "device", translate("Device"))
73 function device.cfgvalue(self,section)
74 local dev = m1:get(section, "device")
75 local val = m1:get(dev, "hwmode")
76 if val == "11a" then return dev .. " (5 GHz)" else
77 return dev .. " (2,4 GHz)"
86 mode = aps:option(DummyValue, "mode", translate("Mode"))
88 ssid = aps:option(DummyValue, "ssid", translate("SSID"))
91 action = aps:option(ListValue, "dynapoint_rule", translate("Activate this wVIF if status is:"))
92 action.widget="select"
93 action:value("internet",translate("Online"))
94 action:value("!internet",translate("Offline"))
95 action:value("",translate("Not used by DynaPoint"))