Merge pull request #2160 from remakeelectric/app-mosq
[oweals/luci.git] / protocols / luci-proto-ncm / luasrc / model / cbi / admin_network / proto_ncm.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2015 Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11 ]]--
12
13 local map, section, net = ...
14
15 local device, apn, service, pincode, username, password
16 local ipv6, delay, defaultroute, metric, peerdns, dns
17
18
19 device = section:taboption("general", Value, "device", translate("Modem device"))
20 device.rmempty = false
21
22 local dev
23 for dev in nixio.fs.glob("/dev/ttyUSB*") do
24     device:value(dev)
25 end
26 for dev in nixio.fs.glob("/dev/cdc-wdm*") do
27     device:value(dev)
28 end
29
30 mode = section:taboption("general", Value, "mode", translate("Service Type"))
31 mode:value("", translate("Modem default"))
32 mode:value("preferlte", translate("Prefer LTE"))
33 mode:value("preferumts", translate("Prefer UMTS"))
34 mode:value("lte", "LTE")
35 mode:value("umts", "UMTS/GPRS")
36 mode:value("gsm", translate("GPRS only"))
37 mode:value("auto", translate("auto"))
38
39
40 mode = section:taboption("general", Value, "pdptype", translate("IP Protocol"))
41 mode.default = "IP"
42 mode:value("IP", translate("IPv4"))
43 mode:value("IPV4V6", translate("IPv4+IPv6"))
44 mode:value("IPV6", translate("IPv6"))
45
46
47 apn = section:taboption("general", Value, "apn", translate("APN"))
48
49
50 pincode = section:taboption("general", Value, "pincode", translate("PIN"))
51
52
53 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
54
55
56 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
57 password.password = true
58
59
60 if luci.model.network:has_ipv6() then
61
62         ipv6 = section:taboption("advanced", ListValue, "ipv6")
63         ipv6:value("auto", translate("Automatic"))
64         ipv6:value("0", translate("Disabled"))
65         ipv6:value("1", translate("Manual"))
66         ipv6.default = "auto"
67
68 end
69
70
71 delay = section:taboption("advanced", Value, "delay",
72         translate("Modem init timeout"),
73         translate("Maximum amount of seconds to wait for the modem to become ready"))
74
75 delay.placeholder = "10"
76 delay.datatype    = "min(1)"
77
78
79 defaultroute = section:taboption("advanced", Flag, "defaultroute",
80         translate("Use default gateway"),
81         translate("If unchecked, no default route is configured"))
82
83 defaultroute.default = defaultroute.enabled
84
85 metric = section:taboption("advanced", Value, "metric",
86         translate("Use gateway metric"))
87
88 metric.placeholder = "0"
89 metric.datatype    = "uinteger"
90 metric:depends("defaultroute", defaultroute.enabled)
91
92
93 peerdns = section:taboption("advanced", Flag, "peerdns",
94         translate("Use DNS servers advertised by peer"),
95         translate("If unchecked, the advertised DNS server addresses are ignored"))
96
97 peerdns.default = peerdns.enabled
98
99
100 dns = section:taboption("advanced", DynamicList, "dns",
101         translate("Use custom DNS servers"))
102
103 dns:depends("peerdns", "")
104 dns.datatype = "ipaddr"
105 dns.cast     = "string"
106