Merge pull request #2791 from TDT-AG/pr/20190626-luci-proto-3g
[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, dialnum
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 dialnum = section:taboption("general", Value, "dialnum", translate("Dial number"))
61 dialnum.placeholder = "*99#"
62
63
64 if luci.model.network:has_ipv6() then
65
66         ipv6 = section:taboption("advanced", ListValue, "ipv6")
67         ipv6:value("auto", translate("Automatic"))
68         ipv6:value("0", translate("Disabled"))
69         ipv6:value("1", translate("Manual"))
70         ipv6.default = "auto"
71
72 end
73
74
75 delay = section:taboption("advanced", Value, "delay",
76         translate("Modem init timeout"),
77         translate("Maximum amount of seconds to wait for the modem to become ready"))
78
79 delay.placeholder = "10"
80 delay.datatype    = "min(1)"
81
82
83 defaultroute = section:taboption("advanced", Flag, "defaultroute",
84         translate("Use default gateway"),
85         translate("If unchecked, no default route is configured"))
86
87 defaultroute.default = defaultroute.enabled
88
89 metric = section:taboption("advanced", Value, "metric",
90         translate("Use gateway metric"))
91
92 metric.placeholder = "0"
93 metric.datatype    = "uinteger"
94 metric:depends("defaultroute", defaultroute.enabled)
95
96
97 peerdns = section:taboption("advanced", Flag, "peerdns",
98         translate("Use DNS servers advertised by peer"),
99         translate("If unchecked, the advertised DNS server addresses are ignored"))
100
101 peerdns.default = peerdns.enabled
102
103
104 dns = section:taboption("advanced", DynamicList, "dns",
105         translate("Use custom DNS servers"))
106
107 dns:depends("peerdns", "")
108 dns.datatype = "ipaddr"
109 dns.cast     = "string"
110