Merge pull request #2021 from dibdot/travelmate
[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 device_suggestions = nixio.fs.glob("/dev/cdc-wdm*")
23         or nixio.fs.glob("/dev/ttyUSB*")
24
25 if device_suggestions then
26         local node
27         for node in device_suggestions do
28                 device:value(node)
29         end
30 end
31
32
33 mode = section:taboption("general", Value, "mode", translate("Service Type"))
34 mode:value("", translate("Modem default"))
35 mode:value("preferlte", translate("Prefer LTE"))
36 mode:value("preferumts", translate("Prefer UMTS"))
37 mode:value("lte", "LTE")
38 mode:value("umts", "UMTS/GPRS")
39 mode:value("gsm", translate("GPRS only"))
40 mode:value("auto", translate("auto"))
41
42
43 mode = section:taboption("general", Value, "pdptype", translate("IP Protocol"))
44 mode.default = "IP"
45 mode:value("IP", translate("IPv4"))
46 mode:value("IPV4V6", translate("IPv4+IPv6"))
47 mode:value("IPV6", translate("IPv6"))
48
49
50 apn = section:taboption("general", Value, "apn", translate("APN"))
51
52
53 pincode = section:taboption("general", Value, "pincode", translate("PIN"))
54
55
56 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
57
58
59 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
60 password.password = true
61
62
63 if luci.model.network:has_ipv6() then
64
65         ipv6 = section:taboption("advanced", ListValue, "ipv6")
66         ipv6:value("auto", translate("Automatic"))
67         ipv6:value("0", translate("Disabled"))
68         ipv6:value("1", translate("Manual"))
69         ipv6.default = "auto"
70
71 end
72
73
74 delay = section:taboption("advanced", Value, "delay",
75         translate("Modem init timeout"),
76         translate("Maximum amount of seconds to wait for the modem to become ready"))
77
78 delay.placeholder = "10"
79 delay.datatype    = "min(1)"
80
81
82 defaultroute = section:taboption("advanced", Flag, "defaultroute",
83         translate("Use default gateway"),
84         translate("If unchecked, no default route is configured"))
85
86 defaultroute.default = defaultroute.enabled
87
88 metric = section:taboption("advanced", Value, "metric",
89         translate("Use gateway metric"))
90
91 metric.placeholder = "0"
92 metric.datatype    = "uinteger"
93 metric:depends("defaultroute", defaultroute.enabled)
94
95
96 peerdns = section:taboption("advanced", Flag, "peerdns",
97         translate("Use DNS servers advertised by peer"),
98         translate("If unchecked, the advertised DNS server addresses are ignored"))
99
100 peerdns.default = peerdns.enabled
101
102
103 dns = section:taboption("advanced", DynamicList, "dns",
104         translate("Use custom DNS servers"))
105
106 dns:depends("peerdns", "")
107 dns.datatype = "ipaddr"
108 dns.cast     = "string"
109