a4eb0d210b46d779ae5051fafcbdb0381fc396d6
[project/luci.git] /
1 'use strict';
2 'require form';
3 'require view';
4 'require uci';
5 'require fs';
6 'require network';
7 'require tools.widgets as widgets';
8
9 return view.extend({
10 load: function() {
11 return Promise.all([
12 uci.load('basicstation')
13 ]);
14 },
15
16 render: function(data) {
17 var m, s, o;
18
19 /* General Settings */
20 m = new form.Map('basicstation', _('General Settings'));
21
22 /* Station Identity */
23 s = m.section(form.NamedSection, 'station', 'station',
24 _('Station Identity'));
25
26 o = s.option(widgets.DeviceSelect, 'idGenIf',
27 _('Interface for station ID generation'),
28 _('Station ID is derived from the MAC address of the chosen interface'));
29 o.filter = function(section_id, value) {
30 var dev = this.devices.filter(function(dev) { return dev.getName() == value })[0];
31 return (dev && dev.getMAC() != null && dev.getMAC() != '00:00:00:00:00:00');
32 }
33 o.nobridges = true;
34 o.novirtual = true;
35 o.noaliases = true;
36 o.default = 'eth0';
37
38 o.write = function(sid, value) {
39 var path = "/sys/class/net/" + value + "/address";
40 uci.set('basicstation', sid, 'idGenIf', value);
41 uci.set('basicstation', sid, 'routerid', path);
42 }
43
44 o = s.option(form.Value, 'stationid', _('Station ID'),
45 _('Click save and apply to generate station ID'));
46 o.readonly = true;
47
48 /* Authentication */
49 s = m.section(form.NamedSection, 'auth', 'auth',
50 _('Authentication'));
51
52 o = s.option(form.ListValue, 'cred', _('Credentials'),
53 _('Credentials for LNS (TC) or CUPS (CUPS)'));
54 o.value('tc', _('TC'));
55 o.value('cups', _('CUPS'));
56 o.default = 'tc';
57
58 o = s.option(form.ListValue, 'mode', _('Authentication mode'),
59 _('Authentication mode for server connection'));
60 o.value('no', _('No Authentication'));
61 o.value('server', _('TLS Server Authentication'));
62 o.value('serverAndClient', _('TLS Server and Client Authentication'));
63 o.value('serverAndClientToken', _('TLS Server Authentication and Client Token'));
64 o.default = 'no';
65
66 o = s.option(form.Value, 'addr', _('Server address'));
67 o.optional = false;
68 o.rmempty = false;
69 o.placeholder = 'eu1.cloud.thethings.network';
70
71 o = s.option(form.Value, 'port', _('Port'));
72 o.optional = false;
73 o.rmempty = false;
74 o.datatype = 'uinteger';
75 o.placeholder = '8887';
76
77 o = s.option(form.Value, 'token', _('Authorization token'));
78 o.optional = false;
79 o.rmempty = false;
80 o.depends({ mode: 'serverAndClientToken' });
81
82 o = s.option(form.Value, 'key', _('Private station key'));
83 o.optional = false;
84 o.rmempty = false;
85 o.depends({ mode: 'serverAndClient' });
86
87 o = s.option(form.FileUpload, 'crt', _('Private station certificate'));
88 o.optional = false;
89 o.rmempty = false;
90 o.depends({ mode: "serverAndClient" });
91
92 o = s.option(form.FileUpload, 'trust', _('CA certificate'));
93 o.optional = false;
94 o.rmempty = false;
95 o.depends({ mode: "no", "!reverse": true });
96
97 /* Radio Configuration */
98 s = m.section(form.NamedSection, 'sx130x', 'sx130x',
99 _('Radio Configuration'));
100
101 o = s.option(form.ListValue, 'comif', _('Communication interface'),
102 _('Currently only USB devices are supported'));
103 o.value('usb', 'USB');
104 o.default = 'usb';
105
106 o = s.option(form.Value, 'devpath', _('Device path'),
107 _('Device path of the LoRaWAN concentrator card'));
108 o.optional = false;
109 o.rmempty = false;
110 o.placeholder = '/dev/ttyACM0';
111
112 o = s.option(form.Flag, 'pps', _('PPS'),
113 _('PPS (pulse per second) provided by GPS device or other source'));
114 o.default = false
115
116 o = s.option(form.Flag, 'public', _('Public network'),
117 _('Public or private LoRaWAN network'));
118 o.default = true;
119
120 o = s.option(form.ListValue, 'clksrc', _('Clock source'),
121 _('Radio to provide clock to Basicstation'));
122 o.value('0', 'Radio 0');
123 o.value('1', 'Radio 1');
124 o.default = '0';
125
126 var options = uci.sections('basicstation', 'rfconf');
127
128 o = s.option(form.ListValue, 'radio0', _('Radio 0'),
129 _('RF configuration for Radio 0'));
130 for (var i = 0; i < options.length; i++) {
131 var value = options[i]['.name'];
132 o.value(value);
133 }
134 o.default = 'rfconf0';
135
136 o = s.option(form.ListValue, 'radio1', _('Radio 1'),
137 _('RF configuration for Radio 1'));
138 for (var i = 0; i < options.length; i++) {
139 var value = options[i]['.name'];
140 o.value(value);
141 }
142 o.default = 'rfconf1';
143
144 /* Logging */
145 s = m.section(form.NamedSection, 'station','station',
146 _('Logging'));
147
148 o = s.option(form.ListValue, 'logLevel', _('Level'),
149 _('Level to which messages are to be logged'));
150 o.value('XDEBUG', 'xdebug');
151 o.value('DEBUG', 'debug');
152 o.value('VERBOSE', 'verbose');
153 o.value('INFO', 'info');
154 o.value('NOTICE', 'notice');
155 o.value('WARNING', 'warning');
156 o.value('ERROR', 'error');
157 o.value('CRITICAL', 'critical');
158 o.default = 'DEBUG';
159
160 o = s.option(form.Value, 'logSize', _('Size'),
161 _('Maximum size of log file in MB'));
162 o.value('1');
163 o.value('2');
164 o.value('3');
165 o.value('4');
166 o.default = '1';
167 o.datatype = 'range(1,10)';
168
169 o = s.option(form.Value, 'logRotate', _('Rotate'),
170 _('Number of old log files to be kept'));
171 o.value('1');
172 o.value('2');
173 o.value('3');
174 o.value('4');
175 o.default = '1';
176 o.datatype = 'range(1, 10)';
177
178 return m.render();
179 },
180 });