@ncd-io/node-red-enterprise-sensors 1.2.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/wireless.js CHANGED
@@ -4,6 +4,7 @@ const sp = require('serialport');
4
4
  const Queue = require("promise-queue");
5
5
  const events = require("events");
6
6
  const fs = require('fs');
7
+ const path = require('path');
7
8
  const home_dir = require('os').homedir
8
9
  module.exports = function(RED) {
9
10
  var gateway_pool = {};
@@ -20,6 +21,9 @@ module.exports = function(RED) {
20
21
  this._emitter = new events.EventEmitter();
21
22
  this.on = (e,c) => this._emitter.on(e, c);
22
23
 
24
+ // comms_timer object var added to clear the time to prevent issues with rapid redeploy
25
+ this.comms_timer;
26
+
23
27
  if(config.comm_type == 'serial'){
24
28
  this.key = config.port;
25
29
  }
@@ -62,7 +66,7 @@ module.exports = function(RED) {
62
66
 
63
67
  if(config.comm_type == 'serial'){
64
68
  if(config.port !== ''){
65
- setTimeout(()=>{node.gateway.digi.serial.setupSerial()}, 5000);
69
+ this.comms_timer = setTimeout(()=>{node.gateway.digi.serial.setupSerial()}, 5000);
66
70
  }else{
67
71
  node.warn('No Port Selected for Serial Communications.')
68
72
  }
@@ -70,7 +74,7 @@ module.exports = function(RED) {
70
74
  if(config.tcp_port === '' || config.ip_address === ''){
71
75
  node.warn('TCP Socket not configured for Network Communications. Please enter a Port and IP Address.');
72
76
  }else{
73
- setTimeout(()=>{node.gateway.digi.serial.setupClient()}, 5000);
77
+ this.comms_timer = setTimeout(()=>{node.gateway.digi.serial.setupClient()}, 5000);
74
78
  }
75
79
  }
76
80
  node.gateway.digi.serial.on('ready', () => {
@@ -133,14 +137,29 @@ module.exports = function(RED) {
133
137
  });
134
138
  for(var i in promises){
135
139
  (function(name){
136
- promises[name].then((f) => {
140
+ promises[name].then((res) => {
137
141
  if(name != 'finish'){
142
+ // IF we receive an FON message with success
143
+ if(Object.hasOwn(res, 'data') && res.data[0] == 70 && res.data[1] == 79 && res.data[2] == 78 && res.result == 255){
144
+ manifest_data.enter_ota_fota_version = res.original.data[5];
145
+ console.log('Great Success');
146
+ console.log(res);
147
+ }
138
148
  console.log(name);
139
- }
140
- else{
149
+ } else{
141
150
  // enter ota mode
142
151
  node.gateway.digi.send.at_command("ID", [0x7a, 0xaa]).then().catch().then(() => {
143
- node.start_firmware_update(manifest_data, firmware_data);
152
+ console.log(manifest_data);
153
+ if(manifest_data.enter_ota_fota_version <13){
154
+ console.log('OLD PROCESSS');
155
+ console.log(manifest_data);
156
+ // console.log(firmware_data);
157
+ node.start_firmware_update(manifest_data, firmware_data);
158
+ }else{
159
+ console.log('NEW PROCESS');
160
+ console.log(manifest_data);
161
+ node.start_firmware_update_v13(manifest_data, firmware_data);
162
+ }
144
163
  });
145
164
  }
146
165
  }).catch((err) => {
@@ -148,7 +167,7 @@ module.exports = function(RED) {
148
167
  // msg[name] = err;
149
168
  });
150
169
  })(i);
151
- }
170
+ };
152
171
  });
153
172
  });
154
173
  }));
@@ -180,7 +199,6 @@ module.exports = function(RED) {
180
199
  node._emitter.emit('mode_change', mode);
181
200
  });
182
201
  };
183
-
184
202
  node.start_firmware_update = function(manifest_data, firmware_data){
185
203
  return new Promise((top_fulfill, top_reject) => {
186
204
  var success = {};
@@ -244,7 +262,96 @@ module.exports = function(RED) {
244
262
  }
245
263
  }, 1000);
246
264
  });
247
- }
265
+ };
266
+ node.start_firmware_update_v13 = function(manifest_data, firmware_data){
267
+ console.log('V13');
268
+ return new Promise((top_fulfill, top_reject) => {
269
+ var success = {successes:{}, failures:{}};
270
+
271
+ let chunk_size = 128;
272
+ let image_start = firmware_data.firmware.slice(1, 5).reduce(msbLsb)+6;
273
+
274
+ var promises = {
275
+ manifest: node.gateway.firmware_send_manifest(manifest_data.addr, firmware_data.firmware.slice(5, image_start-1))
276
+ };
277
+ // promises.manifest = node.gateway.firmware_send_manifest(manifest_data.addr, firmware_data.firmware.slice(5, image_start-1));
278
+ firmware_data.firmware = firmware_data.firmware.slice(image_start+4);
279
+
280
+ var index = 0;
281
+ if(Object.hasOwn(node.sensor_list[manifest_data.addr], 'last_chunk_success')){
282
+ index = node.sensor_list[manifest_data.addr].last_chunk_success;
283
+ }
284
+ while(index*chunk_size < firmware_data.manifest.image_size){
285
+ let offset = index*chunk_size;
286
+ let offset_bytes = int2Bytes(offset, 4);
287
+ let firmware_chunk = firmware_data.firmware.slice(index*chunk_size, index*chunk_size+chunk_size);
288
+ promises[index] = node.gateway.firmware_send_chunk_v13(manifest_data.addr, offset_bytes, firmware_chunk);
289
+ if(((index + 1) % 50) == 0 || (index+1)*chunk_size >= firmware_data.manifest.image_size){
290
+ promises[index+'_check'] = node.gateway.firmware_read_last_chunk_segment(manifest_data.addr);
291
+ };
292
+ index++;
293
+ }
294
+ console.log('Update Started');
295
+ console.log(Object.keys(promises).length);
296
+ console.log(Date.now());
297
+ promises.reboot = node.gateway.config_reboot_sensor(manifest_data.addr);
298
+ var firmware_continue = true;
299
+ for(var i in promises){
300
+ (function(name){
301
+ let retryCount = 0;
302
+ const maxRetries = 3; // Set the maximum number of retries
303
+
304
+ function attemptPromise() {
305
+ console.log(name);
306
+ promises[name].then((status_frame) => {
307
+ if(name == 'manifest'){
308
+ console.log('MANIFEST SUCCESFULLY SENT');
309
+ node.sensor_list[manifest_data.addr].test_check = {name: true};
310
+ node.sensor_list[manifest_data.addr].update_in_progress = true;
311
+ }
312
+ else if(name.includes('_check')){
313
+ console.log(name);
314
+ console.log(parseInt(name.split('_')[0]) * chunk_size);
315
+ let last_chunk = status_frame.data.reduce(msbLsb);
316
+ console.log(last_chunk);
317
+ if(last_chunk != (parseInt(name.split('_')[0]) * chunk_size)){
318
+ console.log('ERROR DETECTED IN OTA UPDATE');
319
+ success.failures[name] = {chunk: last_chunk, last_transmit: (parseInt(name.split('_')[0]) * chunk_size), last_report: last_chunk};
320
+ // node.gateway.clear_queue_except_last();
321
+ node.gateway.clear_queue();
322
+ node.resume_normal_operation();
323
+ } else {
324
+ success.successes[name] = {chunk: last_chunk};
325
+ }
326
+ }
327
+ else {
328
+ success[name] = true;
329
+ node.sensor_list[manifest_data.addr].test_check[name] = true;
330
+ node.sensor_list[manifest_data.addr].last_chunk_success = name;
331
+ }
332
+ }).catch((err) => {
333
+ console.log(name);
334
+ console.log(err);
335
+ if(name != 'reboot'){
336
+ node.gateway.clear_queue();
337
+ success[name] = err;
338
+ } else {
339
+ delete node.sensor_list[manifest_data.addr].last_chunk_success;
340
+ delete node.sensor_list[manifest_data.addr].update_request;
341
+ node._emitter.emit('send_firmware_stats', {state: success, addr: manifest_data.addr});
342
+ top_fulfill(success);
343
+ }
344
+ console.log('Update Finished')
345
+ console.log(Date.now());
346
+ node._emitter.emit('send_firmware_stats', {state: success, addr: manifest_data.addr});
347
+ node.resume_normal_operation();
348
+ });
349
+ }
350
+ attemptPromise(); // Start the initial attempt
351
+ })(i);
352
+ }
353
+ });
354
+ };
248
355
  node.resume_normal_operation = function(){
249
356
  let pan_id = parseInt(config.pan_id, 16);
250
357
  node.gateway.digi.send.at_command("ID", [pan_id >> 8, pan_id & 255]).then().catch().then(() => {
@@ -262,11 +369,13 @@ module.exports = function(RED) {
262
369
  if(typeof gateway_pool[this.key] != 'undefined'){
263
370
  if(config.comm_type == 'serial'){
264
371
  node.gateway.digi.serial.close();
372
+ clearTimeout(this.comms_timer);
265
373
  // node.gateway.digi.serial.close(() => {
266
374
  delete gateway_pool[this.key];
267
375
  // });
268
376
  }else{
269
377
  node.gateway.digi.serial.close();
378
+ clearTimeout(this.comms_timer);
270
379
  // node.gateway.digi.serial.close(() => {
271
380
  delete gateway_pool[this.key];
272
381
  // });
@@ -582,6 +691,32 @@ module.exports = function(RED) {
582
691
  // device_type: 80,
583
692
  // hardware_id: [88, 88, 88]
584
693
  // }
694
+ let fw_dir = home_dir()+'/.node-red/node_modules/@ncd-io/node-red-enterprise-sensors/firmware_files';
695
+ fs.readdir(fw_dir, (err, files) => {
696
+ if (err) {
697
+ node.error('Error reading firmware directory: ' + err);
698
+ return;
699
+ }
700
+
701
+ // Create firmware files array
702
+ const firmwareFiles = files
703
+ .filter(file => file.endsWith('.ncd'))
704
+ .map((file) => {
705
+ const stats = fs.statSync(path.join(fw_dir, file));
706
+ const file_info = file.split("-");
707
+ return {
708
+ file_name: file,
709
+ download_date: stats.mtime,
710
+ for_sensor_type: Number(file_info[0]),
711
+ for_hardware_id: file_info[1].substring(0, file_info[1].length - 4)
712
+ };
713
+ });
714
+ // Send firmware files list
715
+ node.send({
716
+ topic: 'check_firmware_file_response',
717
+ payload: firmwareFiles
718
+ });
719
+ });
585
720
  break;
586
721
  case "ota_firmware_update_single":
587
722
  // msg.payload = {
@@ -774,7 +909,7 @@ module.exports = function(RED) {
774
909
 
775
910
  var promises = {};
776
911
  // This command is used for OTF on types 53, 80,81,82,83,84, 101, 102, 110, 111, 518, 519
777
- let original_otf_devices = [53, 80, 81, 82, 83, 84, 101, 102, 110, 111, 112, 114, 180, 181, 518, 519, 520, 538];
912
+ let original_otf_devices = [53, 80, 81, 82, 83, 84, 101, 102, 110, 111, 112, 114, 117, 180, 181, 518, 519, 520, 538];
778
913
  if(original_otf_devices.includes(sensor.type)){
779
914
  // This command is used for OTF on types 53, 80, 81, 82, 83, 84, 101, 102, 110, 111, 518, 519
780
915
  promises.config_enter_otn_mode = node.config_gateway.config_enter_otn_mode(sensor.mac);
@@ -930,6 +1065,12 @@ module.exports = function(RED) {
930
1065
  if(config.change_detection_t3_active){
931
1066
  promises.change_detection = node.config_gateway.config_set_change_detection(mac, config.change_enabled ? 1 : 0, parseInt(config.change_pr), parseInt(config.change_interval));
932
1067
  }
1068
+ if(config.fsr_420ma_active){
1069
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1070
+ }
1071
+ if(config.always_on_420ma_active){
1072
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1073
+ }
933
1074
  break;
934
1075
  case 4:
935
1076
  if(config.thermocouple_type_23_active){
@@ -1041,6 +1182,12 @@ module.exports = function(RED) {
1041
1182
  if(config.auto_check_threshold_88_active){
1042
1183
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1043
1184
  }
1185
+ if(config.fsr_420ma_active){
1186
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1187
+ }
1188
+ if(config.always_on_420ma_active){
1189
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1190
+ }
1044
1191
  break;
1045
1192
  case 15:
1046
1193
  if(config.sensor_boot_time_420ma_active){
@@ -1061,6 +1208,12 @@ module.exports = function(RED) {
1061
1208
  if(config.auto_check_threshold_88_active){
1062
1209
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1063
1210
  }
1211
+ if(config.fsr_420ma_active){
1212
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1213
+ }
1214
+ if(config.always_on_420ma_active){
1215
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1216
+ }
1064
1217
  break;
1065
1218
  case 19:
1066
1219
  if(config.current_calibration_13_active){
@@ -1151,6 +1304,14 @@ module.exports = function(RED) {
1151
1304
  var interr = parseInt(config.activ_interr_x) | parseInt(config.activ_interr_y) | parseInt(config.activ_interr_z) | parseInt(config.activ_interr_op);
1152
1305
  promises.activity_interrupt = node.config_gateway.config_set_interrupt_24(mac, interr);
1153
1306
  break;
1307
+ case 26:
1308
+ if(config.pressure_limit_26_active){
1309
+ promises.pressure_limit_26 = node.config_gateway.config_set_pressure_limit_26(mac, parseInt(config.pressure_limit_26));
1310
+ }
1311
+ if(config.auto_pressure_check_26_active){
1312
+ promises.auto_pressure_check_26 = node.config_gateway.config_set_auto_pressure_check_26(mac, parseInt(config.auto_pressure_check_26));
1313
+ }
1314
+ break;
1154
1315
  case 28:
1155
1316
  if(config.current_calibration_13_active){
1156
1317
  var cali = parseInt(config.current_calibration_13);
@@ -1292,6 +1453,12 @@ module.exports = function(RED) {
1292
1453
  if(config.auto_check_threshold_88_active){
1293
1454
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1294
1455
  }
1456
+ if(config.fsr_420ma_active){
1457
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1458
+ }
1459
+ if(config.always_on_420ma_active){
1460
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1461
+ }
1295
1462
  break;
1296
1463
  case 46:
1297
1464
  if(config.motion_threshold_46_active){
@@ -1325,6 +1492,12 @@ module.exports = function(RED) {
1325
1492
  if(config.auto_check_threshold_88_active){
1326
1493
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1327
1494
  }
1495
+ if(config.fsr_420ma_active){
1496
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1497
+ }
1498
+ if(config.always_on_420ma_active){
1499
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1500
+ }
1328
1501
  break;
1329
1502
  case 52:
1330
1503
  if(config.sensor_boot_time_420ma_active){
@@ -1345,6 +1518,12 @@ module.exports = function(RED) {
1345
1518
  if(config.auto_check_threshold_88_active){
1346
1519
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1347
1520
  }
1521
+ if(config.fsr_420ma_active){
1522
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1523
+ }
1524
+ if(config.always_on_420ma_active){
1525
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1526
+ }
1348
1527
  break;
1349
1528
  case 53:
1350
1529
  if(config.scd_skip_samples_44_active){
@@ -1376,6 +1555,12 @@ module.exports = function(RED) {
1376
1555
  if(config.auto_check_threshold_88_active){
1377
1556
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1378
1557
  }
1558
+ if(config.fsr_420ma_active){
1559
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1560
+ }
1561
+ if(config.always_on_420ma_active){
1562
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1563
+ }
1379
1564
  break;
1380
1565
  case 58:
1381
1566
  if(config.calibration_58){
@@ -1648,6 +1833,12 @@ module.exports = function(RED) {
1648
1833
  if(config.auto_check_threshold_88_active){
1649
1834
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1650
1835
  }
1836
+ if(config.fsr_420ma_active){
1837
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1838
+ }
1839
+ if(config.always_on_420ma_active){
1840
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1841
+ }
1651
1842
  break;
1652
1843
  case 88:
1653
1844
  if(config.sensor_boot_time_420ma_active){
@@ -1668,6 +1859,12 @@ module.exports = function(RED) {
1668
1859
  if(config.auto_check_threshold_88_active){
1669
1860
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1670
1861
  }
1862
+ if(config.fsr_420ma_active){
1863
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1864
+ }
1865
+ if(config.always_on_420ma_active){
1866
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1867
+ }
1671
1868
  break;
1672
1869
  case 89:
1673
1870
  if(config.sensor_boot_time_420ma_active){
@@ -1688,6 +1885,12 @@ module.exports = function(RED) {
1688
1885
  if(config.auto_check_threshold_88_active){
1689
1886
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1690
1887
  }
1888
+ if(config.fsr_420ma_active){
1889
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1890
+ }
1891
+ if(config.always_on_420ma_active){
1892
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1893
+ }
1691
1894
  break;
1692
1895
  case 90:
1693
1896
  if(config.sensor_boot_time_420ma_active){
@@ -1708,6 +1911,12 @@ module.exports = function(RED) {
1708
1911
  if(config.auto_check_threshold_88_active){
1709
1912
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1710
1913
  }
1914
+ if(config.fsr_420ma_active){
1915
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1916
+ }
1917
+ if(config.always_on_420ma_active){
1918
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1919
+ }
1711
1920
  break;
1712
1921
  case 91:
1713
1922
  if(config.sensor_boot_time_78_active){
@@ -1733,6 +1942,12 @@ module.exports = function(RED) {
1733
1942
  if(config.auto_check_threshold_88_active){
1734
1943
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1735
1944
  }
1945
+ if(config.fsr_420ma_active){
1946
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1947
+ }
1948
+ if(config.always_on_420ma_active){
1949
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1950
+ }
1736
1951
  break;
1737
1952
  case 96:
1738
1953
  if(config.sensor_boot_time_420ma_active){
@@ -1753,6 +1968,12 @@ module.exports = function(RED) {
1753
1968
  if(config.auto_check_threshold_88_active){
1754
1969
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1755
1970
  }
1971
+ if(config.fsr_420ma_active){
1972
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
1973
+ }
1974
+ if(config.always_on_420ma_active){
1975
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1976
+ }
1756
1977
  break;
1757
1978
  case 97:
1758
1979
  if(config.raw_length_97_active){
@@ -1860,6 +2081,12 @@ module.exports = function(RED) {
1860
2081
  if(config.auto_check_threshold_88_active){
1861
2082
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1862
2083
  }
2084
+ if(config.fsr_420ma_active){
2085
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
2086
+ }
2087
+ if(config.always_on_420ma_active){
2088
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
2089
+ }
1863
2090
  break;
1864
2091
  case 106:
1865
2092
  if(config.sensor_boot_time_420ma_active){
@@ -1880,6 +2107,12 @@ module.exports = function(RED) {
1880
2107
  if(config.auto_check_threshold_88_active){
1881
2108
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1882
2109
  }
2110
+ if(config.fsr_420ma_active){
2111
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
2112
+ }
2113
+ if(config.always_on_420ma_active){
2114
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
2115
+ }
1883
2116
  break;
1884
2117
  case 107:
1885
2118
  if(config.sensor_boot_time_420ma_active){
@@ -1900,6 +2133,12 @@ module.exports = function(RED) {
1900
2133
  if(config.auto_check_threshold_88_active){
1901
2134
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
1902
2135
  }
2136
+ if(config.fsr_420ma_active){
2137
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
2138
+ }
2139
+ if(config.always_on_420ma_active){
2140
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
2141
+ }
1903
2142
  break;
1904
2143
  case 108:
1905
2144
  if(config.accelerometer_state_108_active){
@@ -1960,16 +2199,19 @@ module.exports = function(RED) {
1960
2199
  promises.quality_of_service_108 = node.config_gateway.config_set_quality_of_service_108(mac, parseInt(config.quality_of_service_108));
1961
2200
  }
1962
2201
  if(config.fly_interval_108_active){
1963
- promises.fly_interval_108 = node.config_gateway.config_set_fly_interval_108(mac, parseInt(config.fly_interval_108));
1964
- }
2202
+ promises.fly_interval_108 = node.config_gateway.config_set_fly_interval_108(mac, parseInt(config.fly_interval_108));
2203
+ }
1965
2204
  if(config.sample_rate_108_active){
1966
- promises.sample_rate_108 = node.config_gateway.config_set_sample_rate_108(mac, parseInt(config.sample_rate_108));
1967
- }
2205
+ promises.sample_rate_108 = node.config_gateway.config_set_sample_rate_108(mac, parseInt(config.sample_rate_108));
2206
+ }
1968
2207
  break;
1969
2208
  case 110:
1970
2209
  if(config.odr_p1_110_active){
1971
2210
  promises.odr_p1_110 = node.config_gateway.config_set_odr_p1_110(mac, parseInt(config.odr_p1_110));
1972
2211
  }
2212
+ if(config.enable_filtering_110_active){
2213
+ promises.enable_filtering_110 = node.config_gateway.config_set_enable_filtering_110(mac, parseInt(config.enable_filtering_110));
2214
+ }
1973
2215
  if(config.sampling_duration_p1_110_active){
1974
2216
  promises.sampling_duration_p1_110 = node.config_gateway.config_set_sampling_duration_p1_110(mac, parseInt(config.sampling_duration_p1_110));
1975
2217
  }
@@ -1991,9 +2233,6 @@ module.exports = function(RED) {
1991
2233
  if(config.high_pass_filter_p1_110_active){
1992
2234
  promises.high_pass_filter_p1_110 = node.config_gateway.config_set_high_pass_filter_p1_110(mac, parseInt(config.high_pass_filter_p1_110));
1993
2235
  }
1994
- if(config.measurement_mode_80_active){
1995
- promises.measurement_mode = node.config_gateway.config_set_measurement_mode_80(mac, parseInt(config.measurement_mode_80));
1996
- }
1997
2236
  if(config.on_request_timeout_80_active){
1998
2237
  promises.on_request_timeout = node.config_gateway.config_set_on_request_timeout_80(mac, parseInt(config.on_request_timeout_80));
1999
2238
  }
@@ -2038,6 +2277,9 @@ module.exports = function(RED) {
2038
2277
  if(config.odr_p1_110_active){
2039
2278
  promises.odr_p1_111 = node.config_gateway.config_set_odr_p1_110(mac, parseInt(config.odr_p1_110));
2040
2279
  }
2280
+ if(config.enable_filtering_110_active){
2281
+ promises.enable_filtering_111 = node.config_gateway.config_set_enable_filtering_110(mac, parseInt(config.enable_filtering_110));
2282
+ }
2041
2283
  if(config.sampling_duration_p1_110_active){
2042
2284
  promises.sampling_duration_p1_111 = node.config_gateway.config_set_sampling_duration_p1_110(mac, parseInt(config.sampling_duration_p1_110));
2043
2285
  }
@@ -2071,9 +2313,6 @@ module.exports = function(RED) {
2071
2313
  if(config.high_pass_filter_p2_110_active){
2072
2314
  promises.high_pass_filter_p2_111 = node.config_gateway.config_set_high_pass_filter_p2_110(mac, parseInt(config.high_pass_filter_p2_110));
2073
2315
  }
2074
- if(config.measurement_mode_80_active){
2075
- promises.measurement_mode = node.config_gateway.config_set_measurement_mode_80(mac, parseInt(config.measurement_mode_80));
2076
- }
2077
2316
  if(config.on_request_timeout_80_active){
2078
2317
  promises.on_request_timeout = node.config_gateway.config_set_on_request_timeout_80(mac, parseInt(config.on_request_timeout_80));
2079
2318
  }
@@ -2127,6 +2366,9 @@ module.exports = function(RED) {
2127
2366
  if(config.odr_p1_110_active){
2128
2367
  promises.odr_p1_112 = node.config_gateway.config_set_odr_p1_110(mac, parseInt(config.odr_p1_110));
2129
2368
  }
2369
+ if(config.enable_filtering_110_active){
2370
+ promises.enable_filtering_112 = node.config_gateway.config_set_enable_filtering_110(mac, parseInt(config.enable_filtering_110));
2371
+ }
2130
2372
  if(config.sampling_duration_p1_110_active){
2131
2373
  promises.sampling_duration_p1_112 = node.config_gateway.config_set_sampling_duration_p1_110(mac, parseInt(config.sampling_duration_p1_110));
2132
2374
  }
@@ -2148,9 +2390,6 @@ module.exports = function(RED) {
2148
2390
  if(config.high_pass_filter_p1_110_active){
2149
2391
  promises.high_pass_filter_p1_112 = node.config_gateway.config_set_high_pass_filter_p1_110(mac, parseInt(config.high_pass_filter_p1_110));
2150
2392
  }
2151
- if(config.measurement_mode_80_active){
2152
- promises.measurement_mode = node.config_gateway.config_set_measurement_mode_80(mac, parseInt(config.measurement_mode_80));
2153
- }
2154
2393
  if(config.on_request_timeout_80_active){
2155
2394
  promises.on_request_timeout = node.config_gateway.config_set_on_request_timeout_80(mac, parseInt(config.on_request_timeout_80));
2156
2395
  }
@@ -2216,6 +2455,9 @@ module.exports = function(RED) {
2216
2455
  if(config.odr_p1_110_active){
2217
2456
  promises.odr_p1_114 = node.config_gateway.config_set_odr_p1_110(mac, parseInt(config.odr_p1_110));
2218
2457
  }
2458
+ if(config.enable_filtering_110_active){
2459
+ promises.enable_filtering_114 = node.config_gateway.config_set_enable_filtering_110(mac, parseInt(config.enable_filtering_110));
2460
+ }
2219
2461
  if(config.sampling_duration_p1_110_active){
2220
2462
  promises.sampling_duration_p1_114 = node.config_gateway.config_set_sampling_duration_p1_110(mac, parseInt(config.sampling_duration_p1_110));
2221
2463
  }
@@ -2237,9 +2479,6 @@ module.exports = function(RED) {
2237
2479
  if(config.high_pass_filter_p1_110_active){
2238
2480
  promises.high_pass_filter_p1_114 = node.config_gateway.config_set_high_pass_filter_p1_110(mac, parseInt(config.high_pass_filter_p1_110));
2239
2481
  }
2240
- if(config.measurement_mode_80_active){
2241
- promises.measurement_mode = node.config_gateway.config_set_measurement_mode_80(mac, parseInt(config.measurement_mode_80));
2242
- }
2243
2482
  if(config.on_request_timeout_80_active){
2244
2483
  promises.on_request_timeout = node.config_gateway.config_set_on_request_timeout_80(mac, parseInt(config.on_request_timeout_80));
2245
2484
  }
@@ -2323,6 +2562,40 @@ module.exports = function(RED) {
2323
2562
  promises.alert_threshold_120 = node.config_gateway.config_set_alert_threshold_120(mac, parseInt(config.alert_threshold_120));
2324
2563
  }
2325
2564
  break;
2565
+ case 121:
2566
+ if(config.wood_type_121_active){
2567
+ promises.wood_type_121 = node.config_gateway.config_set_wood_type_121(mac, parseInt(config.wood_type_121));
2568
+ }
2569
+ if(config.quality_of_service_121_active){
2570
+ promises.quality_of_service_121 = node.config_gateway.config_set_quality_of_service_121(mac, parseInt(config.quality_of_service_121));
2571
+ }
2572
+ break;
2573
+ case 122:
2574
+ if(config.sensor_boot_time_420ma_active){
2575
+ promises.sensor_boot_time_420ma_122 = node.config_gateway.config_set_sensor_boot_time_420ma(mac, parseInt(config.sensor_boot_time_420ma));
2576
+ }
2577
+ if(config.low_calibration_420ma_active){
2578
+ promises.low_calibration_420ma_122 = node.config_gateway.config_set_low_calibration_420ma(mac, parseInt(config.low_calibration_420ma));
2579
+ }
2580
+ if(config.mid_calibration_420ma_active){
2581
+ promises.mid_calibration_420ma_122 = node.config_gateway.config_set_mid_calibration_420ma(mac, parseInt(config.mid_calibration_420ma));
2582
+ }
2583
+ if(config.high_calibration_420ma_active){
2584
+ promises.high_calibration_420ma_122 = node.config_gateway.config_set_high_calibration_420ma(mac, parseInt(config.high_calibration_420ma));
2585
+ }
2586
+ if(config.auto_check_interval_88_active){
2587
+ promises.auto_check_interval_122 = node.config_gateway.config_set_auto_check_interval_88(mac, parseInt(config.auto_check_interval_88));
2588
+ }
2589
+ if(config.auto_check_threshold_88_active){
2590
+ promises.auto_check_threshold_122 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
2591
+ }
2592
+ if(config.fsr_420ma_active){
2593
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
2594
+ }
2595
+ if(config.always_on_420ma_active){
2596
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
2597
+ }
2598
+ break;
2326
2599
  case 180:
2327
2600
  if(config.output_data_rate_101_active){
2328
2601
  promises.output_data_rate_101 = node.config_gateway.config_set_output_data_rate_101(mac, parseInt(config.output_data_rate_101));
@@ -2433,6 +2706,12 @@ module.exports = function(RED) {
2433
2706
  if(config.high_calibration_420ma_active){
2434
2707
  promises.high_calibration_420ma = node.config_gateway.config_set_high_calibration_420ma(mac, parseInt(config.high_calibration_420ma));
2435
2708
  }
2709
+ if(config.fsr_420ma_active){
2710
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
2711
+ }
2712
+ if(config.always_on_420ma_active){
2713
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
2714
+ }
2436
2715
  break;
2437
2716
  case 202:
2438
2717
  if(config.sampling_interval_202_active){
@@ -2446,13 +2725,13 @@ module.exports = function(RED) {
2446
2725
  }
2447
2726
  break;
2448
2727
  case 217:
2449
- if(config.tare_the_scale_217){
2450
- promises.tare_the_scale_217 = node.config_gateway.config_set_tare_the_scale_217(mac);
2451
- }
2452
- if(config.weight_calib_217_active){
2453
- promises.weight_calib_217 = node.config_gateway.config_set_weight_calib_217(mac, parseInt(config.weight_calib_217));
2454
- }
2455
- break;
2728
+ if(config.tare_the_scale_217){
2729
+ promises.tare_the_scale_217 = node.config_gateway.config_set_tare_the_scale_217(mac);
2730
+ }
2731
+ if(config.weight_calib_217_active){
2732
+ promises.weight_calib_217 = node.config_gateway.config_set_weight_calib_217(mac, parseInt(config.weight_calib_217));
2733
+ }
2734
+ break;
2456
2735
  case 505:
2457
2736
  if(config.current_calibration_c1_80_active){
2458
2737
  promises.current_calibration_c1_80_active = node.config_gateway.config_set_current_calibration_individual_80(mac, parseInt(config.current_calibration_c1_80), 1);
@@ -2696,6 +2975,12 @@ module.exports = function(RED) {
2696
2975
  if(config.auto_check_threshold_88_active){
2697
2976
  promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
2698
2977
  }
2978
+ if(config.fsr_420ma_active){
2979
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
2980
+ }
2981
+ if(config.always_on_420ma_active){
2982
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
2983
+ }
2699
2984
  break;
2700
2985
  case 1010:
2701
2986
  if(config.stay_on_mode_539_active){
@@ -2746,7 +3031,7 @@ module.exports = function(RED) {
2746
3031
  }
2747
3032
  }
2748
3033
  // These sensors listed in original_otf_devices use a different OTF code.
2749
- let original_otf_devices = [53, 80, 81, 82, 83, 84, 101, 102, 110, 111, 112, 114, 180, 181, 518, 519, 520, 538];
3034
+ let original_otf_devices = [53, 80, 81, 82, 83, 84, 101, 102, 110, 111, 112, 114, 117, 180, 181, 518, 519, 520, 538];
2750
3035
  // If we changed the network ID reboot the sensor to take effect.
2751
3036
  // TODO if we add the encryption key command to node-red we need to reboot for it as well.
2752
3037
  if(reboot){