general.js 5.1 KB

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