summaryrefslogtreecommitdiffstats
path: root/applications/luci-app-lorawan-basicstation/htdocs/luci-static/resources/view/lorawan-basicstation/general.js
blob: 71cb71ec98c30c9f12c64f5bc7d971faa5ca9a51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
'use strict';
'require form';
'require view';
'require uci';
'require fs';
'require network';
'require tools.widgets as widgets'; 

return view.extend({
	load() {
		return Promise.all([
			uci.load('basicstation')
		]);
	},

	render() {
		let m, s, o;

		/* General Settings */
		m = new form.Map('basicstation', _('General Settings'));
		
		/* Station Identity */
		s = m.section(form.NamedSection, 'station', 'station',
			_('Station Identity'));

		o = s.option(widgets.DeviceSelect, 'idGenIf',
			_('Interface for station ID generation'),
			_('Station ID is derived from the MAC address of the chosen interface'));
		o.filter = function(section_id, value) {
			var dev = this.devices.filter(function(dev) { return dev.getName() == value })[0];
			return (dev && dev.getMAC() != null && dev.getMAC() != '00:00:00:00:00:00');
		}
		o.nobridges = true;
		o.novirtual = true;
		o.noaliases = true;
		o.default = 'eth0';

		o.write = function(sid, value) {
			var path = "/sys/class/net/" + value + "/address";
			uci.set('basicstation', sid, 'idGenIf', value);
			uci.set('basicstation', sid, 'routerid', path);
		}

		o = s.option(form.Value, 'stationid', _('Station ID'),
			_('Click save and apply to generate station ID'));
		o.readonly = true;

		/* Authentication */
		s = m.section(form.NamedSection, 'auth', 'auth', 
			_('Authentication'));

		o = s.option(form.ListValue, 'cred', _('Credentials'), 
			_('Credentials for LNS (TC) or CUPS (CUPS)'));
		o.value('tc', _('TC'));
		o.value('cups', _('CUPS'));
		o.default = 'tc';

		o = s.option(form.ListValue, 'mode', _('Authentication mode'), 
			_('Authentication mode for server connection'));
		o.value('no', _('No Authentication'));
		o.value('server', _('TLS Server Authentication'));
		o.value('serverAndClient', _('TLS Server and Client Authentication'));
		o.value('serverAndClientToken', _('TLS Server Authentication and Client Token'));
		o.default = 'no';

		o = s.option(form.Value, 'addr', _('Server address'));
		o.optional = false;
		o.rmempty = false;
		o.placeholder = 'eu1.cloud.thethings.network';

		o = s.option(form.Value, 'port', _('Port'));
		o.optional = false;
		o.rmempty = false;
		o.datatype = 'uinteger';
		o.placeholder = '8887';

		o = s.option(form.Value, 'token', _('Authorization token'));
		o.optional = false;
		o.rmempty = false;
		o.depends({ mode: 'serverAndClientToken' });

		o = s.option(form.Value, 'key', _('Private station key'));
		o.optional = false;
		o.rmempty = false;
		o.depends({ mode: 'serverAndClient' });

		o = s.option(form.FileUpload, 'crt', _('Private station certificate'));
		o.optional = false;
		o.rmempty = false;
		o.depends({ mode: "serverAndClient" });

		o = s.option(form.FileUpload, 'trust', _('CA certificate'));
		o.optional = false;
		o.rmempty = false;
		o.depends({ mode: "no", "!reverse": true });
		
		/* Radio Configuration */
		s = m.section(form.NamedSection, 'sx130x', 'sx130x',
			_('Radio Configuration'));

		o = s.option(form.ListValue, 'comif', _('Communication interface'), 
			_('Currently only USB devices are supported'));
		o.value('usb', 'USB');
		o.default = 'usb';

		o = s.option(form.Value, 'devpath', _('Device path'),
			_('Device path of the LoRaWAN concentrator card'));
		o.optional = false;
		o.rmempty = false;
		o.placeholder = '/dev/ttyACM0';

		o = s.option(form.Flag, 'pps', _('PPS'),
			_('PPS (pulse per second) provided by GPS device or other source'));
		o.default = false

		o = s.option(form.Flag, 'public', _('Public network'),
			_('Public or private LoRaWAN network'));
		o.default = true;

		o = s.option(form.ListValue, 'clksrc', _('Clock source'),
			_('Radio to provide clock to Basicstation'));
		o.value('0', 'Radio 0');
		o.value('1', 'Radio 1');
		o.default = '0';

		let options = uci.sections('basicstation', 'rfconf');

		o = s.option(form.ListValue, 'radio0', _('Radio 0'),
			_('RF configuration for Radio 0'));
		for (let opt of options) {
			o.value(opt['.name']);
		}
		o.default = 'rfconf0';

		o = s.option(form.ListValue, 'radio1', _('Radio 1'),
			_('RF configuration for Radio 1'));
		for (let opt of options) {
			o.value(opt['.name']);
		}
		o.default = 'rfconf1';
		
		/* Logging */
		s = m.section(form.NamedSection, 'station','station', 
			_('Logging'));

		o = s.option(form.ListValue, 'logLevel', _('Level'), 
			_('Level to which messages are to be logged'));
		o.value('XDEBUG', 'xdebug');
		o.value('DEBUG', 'debug');
		o.value('VERBOSE', 'verbose');
		o.value('INFO', 'info');
		o.value('NOTICE', 'notice');
		o.value('WARNING', 'warning');
		o.value('ERROR', 'error');
		o.value('CRITICAL', 'critical');
		o.default = 'DEBUG';

		o = s.option(form.Value, 'logSize', _('Size'), 
			_('Maximum size of log file in MB'));
		o.value('1');
		o.value('2');
		o.value('3');
		o.value('4');
		o.default = '1';
		o.datatype = 'range(1,10)';

		o = s.option(form.Value, 'logRotate', _('Rotate'), 
			_('Number of old log files to be kept'));
		o.value('1');
		o.value('2');
		o.value('3');
		o.value('4');
		o.default = '1';
		o.datatype = 'range(1, 10)';
		
		return m.render();
	},
});