@ncd-io/node-red-enterprise-sensors 1.0.1 → 1.0.3

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
@@ -347,25 +347,23 @@ module.exports = function(RED) {
347
347
  time: Date.now()
348
348
  });
349
349
  });
350
- node.on('input', function(msg){
351
- switch(msg.topic){
352
- case "route_trace":
353
- var opts = {trace:1};
354
- node.gateway.route_discover(msg.payload.address,opts).then().catch(console.log);
355
- break;
356
- case "link_test":
357
- node.gateway.link_test(msg.payload.source_address,msg.payload.destination_address,msg.payload.options);
358
- break;
359
- case "fft_request":
360
- break;
361
- case "fidelity_test":
362
- break;
363
- default:
364
- const byteArrayToHexString = byteArray => Array.from(msg.payload.address, byte => ('0' + (byte & 0xFF).toString(16)).slice(-2)).join('');
365
- node.gateway.control_send(msg.payload.address, msg.payload.data, msg.payload.options).then().catch(console.log);
366
- }
367
-
368
-
350
+ // node.on('input', function(msg){
351
+ // switch(msg.topic){
352
+ // case "route_trace":
353
+ // var opts = {trace:1};
354
+ // node.gateway.route_discover(msg.payload.address,opts).then().catch(console.log);
355
+ // break;
356
+ // case "link_test":
357
+ // node.gateway.link_test(msg.payload.source_address,msg.payload.destination_address,msg.payload.options);
358
+ // break;
359
+ // case "fft_request":
360
+ // break;
361
+ // case "fidelity_test":
362
+ // break;
363
+ // default:
364
+ // const byteArrayToHexString = byteArray => Array.from(msg.payload.address, byte => ('0' + (byte & 0xFF).toString(16)).slice(-2)).join('');
365
+ // node.gateway.control_send(msg.payload.address, msg.payload.data, msg.payload.options).then().catch(console.log);
366
+ // }
369
367
  // console.log("input triggered, topic:"+msg.topic);
370
368
  // if(msg.topic == "transmit"){
371
369
  // const byteArrayToHexString = byteArray => Array.from(msg.payload.address, byte => ('0' + (byte & 0xFF).toString(16)).slice(-2)).join('');
@@ -383,7 +381,7 @@ module.exports = function(RED) {
383
381
  // }
384
382
  // if(msg.topic == "fidelity_test"){
385
383
  // }
386
- });
384
+ // });
387
385
  node._gateway_node.on('send_firmware_stats', (data) => {
388
386
  node.send({
389
387
  topic: 'update_stats',
@@ -403,6 +401,80 @@ module.exports = function(RED) {
403
401
  break;
404
402
  case "fidelity_test":
405
403
  break;
404
+ case "start_luber":
405
+ // msg = {
406
+ // 'topic': start_luber,
407
+ // 'payload': {
408
+ // 'address': '00:13:a2:00:42:37:87:0a', //REQUIRED
409
+ // duration: 3, //REQUIRED valid values 1-255
410
+ // channel: 2 //OPTIONAL default value of 1
411
+ // }
412
+ // }
413
+ if(!Object.hasOwn(msg.payload, 'duration')){
414
+ console.log('ERROR: No duration specified, please specify duration in msg.payload.duration');
415
+ break;
416
+ }
417
+ if(msg.payload.duration < 1 || msg.payload.duration > 255){
418
+ console.log('ERROR: Duration out of bounds. Duration');
419
+ break;
420
+ }
421
+ var cmd_promise;
422
+ if(Object.hasOwn(msg.payload, 'channel')){
423
+ node.gateway.control_start_luber(msg.payload.address, msg.payload.channel, msg.payload.duration).then((f) => {
424
+ node.send({
425
+ topic: 'command_results',
426
+ payload: {
427
+ res: 'Automatic Luber '+msg.payload.channel+' Activation Complete',
428
+ address: msg.payload.address,
429
+ channel: msg.payload.channel,
430
+ duration: msg.payload.duration
431
+ },
432
+ time: Date.now(),
433
+ addr: msg.payload.address
434
+ });
435
+ }).catch((err) => {
436
+ node.send({
437
+ topic: 'command_error',
438
+ payload: {
439
+ res: err,
440
+ address: msg.payload.address,
441
+ channel: msg.payload.channel,
442
+ duration: msg.payload.duration
443
+ },
444
+ time: Date.now(),
445
+ addr: msg.payload.address
446
+ });
447
+ // node.send({topic: 'Command Error', payload: err});
448
+ });
449
+ }else{
450
+ node.gateway.control_start_luber(msg.payload.address, 1, msg.payload.duration).then((f) => {
451
+ node.send({
452
+ topic: 'Command Results',
453
+ payload: {
454
+ res: 'Automatic Luber 1 Activation Complete',
455
+ address: msg.payload.address,
456
+ channel: 1,
457
+ duration: msg.payload.duration
458
+ },
459
+ time: Date.now(),
460
+ addr: msg.payload.address
461
+ });
462
+ }).catch((err) => {
463
+ node.send({
464
+ topic: 'Command Results',
465
+ payload: {
466
+ res: 'Automatic Luber 1 Activation Complete',
467
+ address: msg.payload.address,
468
+ channel: 1,
469
+ duration: msg.payload.duration
470
+ },
471
+ time: Date.now(),
472
+ addr: msg.payload.address
473
+ });
474
+ node.send({topic: 'Command Error', payload: err});
475
+ });
476
+ }
477
+ break;
406
478
  case "add_firmware_file":
407
479
  // Parse Manifest to grab information and store it for later use
408
480
  // msg.payload = [0x01, 0x00, ...]
@@ -599,7 +671,7 @@ module.exports = function(RED) {
599
671
 
600
672
  var promises = {};
601
673
  // This command is used for OTF on types 53, 80,81,82,83,84, 101, 102, 110, 111, 518, 519
602
- let original_otf_devices = [53, 80, 81, 82, 83, 84, 101, 102, 180, 181, 518, 519, 520];
674
+ let original_otf_devices = [53, 80, 81, 82, 83, 84, 101, 102, 180, 181, 518, 519, 520, 538];
603
675
  if(original_otf_devices.includes(sensor.type)){
604
676
  // This command is used for OTF on types 53, 80, 81, 82, 83, 84, 101, 102, 110, 111, 518, 519
605
677
  promises.config_enter_otn_mode = node.config_gateway.config_enter_otn_mode(sensor.mac);
@@ -785,9 +857,12 @@ module.exports = function(RED) {
785
857
  // promises.impact_duration = node.config_gateway.config_set_impact_duration(mac, parseInt(config.impact_duration));
786
858
  break;
787
859
  case 13:
788
- var cali = parseFloat(config.cm_calibration);
789
- if(cali == 0) break;
790
- promises.calibration = node.config_gateway.config_set_cm_calibration(mac, cali);
860
+ if(config.current_calibration_13_active){
861
+ var cali = parseInt(config.current_calibration_13);
862
+ if(cali != 0){
863
+ promises.current_calibration_13 = node.config_gateway.config_set_current_calibration_13(mac, cali);
864
+ }
865
+ }
791
866
  break;
792
867
  case 14:
793
868
  if(config.sensor_boot_time_420ma_active){
@@ -803,6 +878,20 @@ module.exports = function(RED) {
803
878
  promises.high_calibration_420ma = node.config_gateway.config_set_high_calibration_420ma(mac, parseInt(config.high_calibration_420ma));
804
879
  }
805
880
  break;
881
+ case 19:
882
+ if(config.current_calibration_13_active){
883
+ var cali = parseInt(config.current_calibration_13);
884
+ if(cali != 0){
885
+ promises.current_calibration_13 = node.config_gateway.config_set_current_calibration_13(mac, cali);
886
+ }
887
+ }
888
+ if(config.current_calibration_ch2_19_active){
889
+ var cali = parseInt(config.current_calibration_ch2_19);
890
+ if(cali != 0){
891
+ promises.current_calibration_ch2_19 = node.config_gateway.config_set_current_calibration_ch2_19(mac, cali);
892
+ }
893
+ }
894
+ break;
806
895
  case 23:
807
896
  if(config.thermocouple_type_23_active){
808
897
  promises.thermocouple_type_23 = node.config_gateway.config_set_thermocouple_type_23(mac, parseInt(config.thermocouple_type_23));
@@ -837,15 +926,41 @@ module.exports = function(RED) {
837
926
  }
838
927
  var interr = parseInt(config.activ_interr_x) | parseInt(config.activ_interr_y) | parseInt(config.activ_interr_z) | parseInt(config.activ_interr_op);
839
928
  promises.activity_interrupt = node.config_gateway.config_set_interrupt_24(mac, interr);
929
+ case 28:
930
+ if(config.current_calibration_13_active){
931
+ var cali = parseInt(config.current_calibration_13);
932
+ if(cali != 0){
933
+ promises.current_calibration_13 = node.config_gateway.config_set_current_calibration_13(mac, cali);
934
+ }
935
+ }
936
+ if(config.current_calibration_ch2_19_active){
937
+ var cali = parseInt(config.current_calibration_ch2_19);
938
+ if(cali != 0){
939
+ promises.current_calibration_ch2_19 = node.config_gateway.config_set_current_calibration_ch2_19(mac, cali);
940
+ }
941
+ }
942
+ if(config.current_calibration_ch3_28_active){
943
+ var cali = parseInt(config.current_calibration_ch3_28);
944
+ if(cali != 0){
945
+ promises.current_calibration_ch3_28 = node.config_gateway.config_set_current_calibration_ch3_28(mac, cali);
946
+ }
947
+ }
948
+ break;
840
949
  case 35:
841
950
  if(config.counter_threshold_35_active){
842
951
  promises.config_set_counter_threshold_35 = node.config_gateway.config_set_counter_threshold_35(mac, parseInt(config.counter_threshold_35));
843
952
  }
953
+ if(config.debounce_time_2_active){
954
+ promises.config_set_debounce_time_35 = node.config_gateway.config_set_debounce_time_35(mac, parseInt(config.debounce_time_2));
955
+ }
844
956
  break;
845
957
  case 36:
846
958
  if(config.counter_threshold_35_active){
847
959
  promises.config_set_counter_threshold_35 = node.config_gateway.config_set_counter_threshold_35(mac, parseInt(config.counter_threshold_35));
848
960
  }
961
+ if(config.debounce_time_2_active){
962
+ promises.config_set_debounce_time_35 = node.config_gateway.config_set_debounce_time_35(mac, parseInt(config.debounce_time_2));
963
+ }
849
964
  break;
850
965
  case 40:
851
966
  promises.filtering = node.config_gateway.config_set_filtering(mac, parseInt(config.filtering));
@@ -916,6 +1031,11 @@ module.exports = function(RED) {
916
1031
  promises.high_calibration_420ma = node.config_gateway.config_set_high_calibration_420ma(mac, parseInt(config.high_calibration_420ma));
917
1032
  }
918
1033
  break;
1034
+ case 56:
1035
+ if(config.sensor_boot_time_420ma_active){
1036
+ promises.sensor_boot_time_420ma = node.config_gateway.config_set_sensor_boot_time_420ma(mac, parseInt(config.sensor_boot_time_420ma));
1037
+ }
1038
+ break;
919
1039
  case 76:
920
1040
  if(config.periodic_check_rate_76_active){
921
1041
  promises.periodic_check_rate_76 = node.config_gateway.config_set_periodic_check_rate_76(mac, parseInt(config.periodic_check_rate_76));
@@ -1231,6 +1351,20 @@ module.exports = function(RED) {
1231
1351
  promises.high_calibration_420ma = node.config_gateway.config_set_high_calibration_420ma(mac, parseInt(config.high_calibration_420ma));
1232
1352
  }
1233
1353
  break;
1354
+ case 106:
1355
+ if(config.sensor_boot_time_420ma_active){
1356
+ promises.sensor_boot_time_420ma = node.config_gateway.config_set_sensor_boot_time_420ma(mac, parseInt(config.sensor_boot_time_420ma));
1357
+ }
1358
+ if(config.low_calibration_420ma_active){
1359
+ promises.low_calibration_420ma = node.config_gateway.config_set_low_calibration_420ma(mac, parseInt(config.low_calibration_420ma));
1360
+ }
1361
+ if(config.mid_calibration_420ma_active){
1362
+ promises.mid_calibration_420ma = node.config_gateway.config_set_mid_calibration_420ma(mac, parseInt(config.mid_calibration_420ma));
1363
+ }
1364
+ if(config.high_calibration_420ma_active){
1365
+ promises.high_calibration_420ma = node.config_gateway.config_set_high_calibration_420ma(mac, parseInt(config.high_calibration_420ma));
1366
+ }
1367
+ break;
1234
1368
  case 107:
1235
1369
  if(config.sensor_boot_time_420ma_active){
1236
1370
  promises.sensor_boot_time_420ma = node.config_gateway.config_set_sensor_boot_time_420ma(mac, parseInt(config.sensor_boot_time_420ma));
@@ -1258,6 +1392,18 @@ module.exports = function(RED) {
1258
1392
  if(config.debounce_time_108_active){
1259
1393
  promises.debounce_time_108 = node.config_gateway.config_set_debounce_time_108(mac, parseInt(config.debounce_time_108));
1260
1394
  }
1395
+ if(config.input_one_108_active){
1396
+ promises.input_one_108 = node.config_gateway.config_set_input_one_108(mac, parseInt(config.input_one_108));
1397
+ }
1398
+ if(config.input_two_108_active){
1399
+ promises.input_two_108 = node.config_gateway.config_set_input_two_108(mac, parseInt(config.input_two_108));
1400
+ }
1401
+ if(config.input_three_108_active){
1402
+ promises.input_three_108 = node.config_gateway.config_set_input_three_108(mac, parseInt(config.input_three_108));
1403
+ }
1404
+ if(config.counter_threshold_108_active){
1405
+ promises.counter_threshold_108 = node.config_gateway.config_set_counter_threshold_108(mac, parseInt(config.counter_threshold_108));
1406
+ }
1261
1407
  break;
1262
1408
  case 110:
1263
1409
  if(config.current_calibration_c1_80_active){
@@ -1318,7 +1464,7 @@ module.exports = function(RED) {
1318
1464
  promises.smart_interval_110 = node.config_gateway.config_set_smart_interval_110(mac, parseInt(config.smart_interval_110));
1319
1465
  }
1320
1466
  if(config.smart_threshold_110_active){
1321
- promises.smart_threshold_110 = nocd.config_gateway.config_set_smart_threshold_110(mac, parseInt(config.smart_threshold_110));
1467
+ promises.smart_threshold_110 = node.config_gateway.config_set_smart_threshold_110(mac, parseInt(config.smart_threshold_110));
1322
1468
  }
1323
1469
  break;
1324
1470
  case 111:
@@ -1395,7 +1541,7 @@ module.exports = function(RED) {
1395
1541
  promises.smart_interval_110 = node.config_gateway.config_set_smart_interval_110(mac, parseInt(config.smart_interval_110));
1396
1542
  }
1397
1543
  if(config.smart_threshold_110_active){
1398
- promises.smart_threshold_110 = nocd.config_gateway.config_set_smart_threshold_110(mac, parseInt(config.smart_threshold_110));
1544
+ promises.smart_threshold_110 = node.config_gateway.config_set_smart_threshold_110(mac, parseInt(config.smart_threshold_110));
1399
1545
  }
1400
1546
  break;
1401
1547
  case 112:
@@ -1457,7 +1603,7 @@ module.exports = function(RED) {
1457
1603
  promises.smart_interval_110 = node.config_gateway.config_set_smart_interval_110(mac, parseInt(config.smart_interval_110));
1458
1604
  }
1459
1605
  if(config.smart_threshold_110_active){
1460
- promises.smart_threshold_110 = nocd.config_gateway.config_set_smart_threshold_110(mac, parseInt(config.smart_threshold_110));
1606
+ promises.smart_threshold_110 = node.config_gateway.config_set_smart_threshold_110(mac, parseInt(config.smart_threshold_110));
1461
1607
  }
1462
1608
  break;
1463
1609
  case 114:
@@ -1528,7 +1674,7 @@ module.exports = function(RED) {
1528
1674
  promises.smart_interval_110 = node.config_gateway.config_set_smart_interval_110(mac, parseInt(config.smart_interval_110));
1529
1675
  }
1530
1676
  if(config.smart_threshold_110_active){
1531
- promises.smart_threshold_110 = nocd.config_gateway.config_set_smart_threshold_110(mac, parseInt(config.smart_threshold_110));
1677
+ promises.smart_threshold_110 = node.config_gateway.config_set_smart_threshold_110(mac, parseInt(config.smart_threshold_110));
1532
1678
  }
1533
1679
  break;
1534
1680
  case 180:
@@ -1787,7 +1933,54 @@ module.exports = function(RED) {
1787
1933
  promises.set_rtc_101 = node.config_gateway.config_set_rtc_101(mac);
1788
1934
  }
1789
1935
  break;
1790
- case 537:
1936
+ case 538:
1937
+ if(config.current_calibration_c1_80_active){
1938
+ promises.current_calibration_c1_80 = node.config_gateway.config_set_current_calibration_individual_80(mac, parseInt(config.current_calibration_c1_80), 1);
1939
+ }
1940
+ if(config.output_data_rate_101_active){
1941
+ promises.output_data_rate_101 = node.config_gateway.config_set_output_data_rate_101(mac, parseInt(config.output_data_rate_101));
1942
+ }
1943
+ if(config.sampling_duration_101_active){
1944
+ promises.sampling_duration_101 = node.config_gateway.config_set_sampling_duration_101(mac, parseInt(config.sampling_duration_101));
1945
+ }
1946
+ if(config.x_axis_101 || config.y_axis_101 || config.z_axis_101){
1947
+ promises.axis_enabled_101 = node.config_gateway.config_set_axis_enabled_101(mac, config.x_axis_101, config.y_axis_101, config.z_axis_101);
1948
+ }
1949
+ if(config.sampling_interval_101_active){
1950
+ promises.sampling_interval_101 = node.config_gateway.config_set_sampling_interval_101(mac, parseInt(config.sampling_interval_101));
1951
+ }
1952
+ if(config.full_scale_range_101_active){
1953
+ promises.full_scale_range_101 = node.config_gateway.config_set_full_scale_range_101(mac, parseInt(config.full_scale_range_101));
1954
+ }
1955
+ if(config.mode_80_active){
1956
+ promises.mode = node.config_gateway.config_set_operation_mode_80(mac, parseInt(config.mode_80));
1957
+ }
1958
+ if(config.filter_80_active){
1959
+ promises.filter = node.config_gateway.config_set_filters_80(mac, parseInt(config.filter_80));
1960
+ }
1961
+ if(config.low_pass_filter_80_active){
1962
+ promises.low_pass_filter = node.config_gateway.config_set_low_pass_filter_80(mac, parseInt(config.low_pass_filter_80));
1963
+ }
1964
+ if(config.high_pass_filter_80_active){
1965
+ promises.high_pass_filter = node.config_gateway.config_set_high_pass_filter_80(mac, parseInt(config.high_pass_filter_80));
1966
+ }
1967
+ if(config.measurement_mode_80_active){
1968
+ promises.measurement_mode = node.config_gateway.config_set_measurement_mode_80(mac, parseInt(config.measurement_mode_80));
1969
+ }
1970
+ if(config.on_request_timeout_80_active){
1971
+ promises.on_request_timeout = node.config_gateway.config_set_on_request_timeout_80(mac, parseInt(config.on_request_timeout_80));
1972
+ }
1973
+ if(config.deadband_80_active){
1974
+ promises.deadband = node.config_gateway.config_set_deadband_80(mac, parseInt(config.deadband_80));
1975
+ }
1976
+ if(config.payload_length_80_active){
1977
+ promises.payload_length_80 = node.config_gateway.config_set_payload_length_80(mac, parseInt(config.payload_length_80));
1978
+ }
1979
+ if(config.set_rtc_101){
1980
+ promises.set_rtc_101 = node.config_gateway.config_set_rtc_101(mac);
1981
+ }
1982
+ break;
1983
+ case 539:
1791
1984
  if(config.stay_on_mode_539_active){
1792
1985
  promises.stay_on_mode_539 = node.config_gateway.config_set_stay_on_mode_539(mac, parseInt(config.stay_on_mode_539));
1793
1986
  }
@@ -1803,11 +1996,29 @@ module.exports = function(RED) {
1803
1996
  if(config.sensor_add_539_active){
1804
1997
  promises.sensor_add_539 = node.config_gateway.config_set_sensor_add_539(mac, parseInt(config.sensor_add_539));
1805
1998
  }
1806
- if(config.rs_node_id_539_active){
1807
- promises.rs_node_id_539 = node.config_gateway.config_set_rs_node_id_539(mac, parseInt(config.rs_node_id_539));
1999
+ if(config.sub_device_type_539_active){
2000
+ promises.sub_device_type_539 = node.config_gateway.config_set_sub_device_type_539(mac, parseInt(config.sub_device_type_539));
1808
2001
  }
1809
2002
  if(config.number_of_regs_to_rd_539_active){
1810
- promises.number_of_regs_to_rd_539 = node.config_gateway.config_set_number_of_regs_to_rd_539(mac, parseInt(config.number_of_regs_to_rd_539));
2003
+ let register_array = [];
2004
+ for(let ind = 0; ind < config.number_of_regs_to_rd_539; ind++){
2005
+ register_array.push(parseInt(config['register_value_'+ind+'_539']));
2006
+ }
2007
+ promises.config_set_all_register_data_539 = node.config_gateway.config_set_all_register_data_539(mac, parseInt(config.number_of_regs_to_rd_539), register_array);
2008
+ }
2009
+ break;
2010
+ case 540:
2011
+ if(config.sensor_boot_time_420ma_active){
2012
+ promises.sensor_boot_time_420ma = node.config_gateway.config_set_sensor_boot_time_420ma(mac, parseInt(config.sensor_boot_time_420ma));
2013
+ }
2014
+ if(config.low_calibration_420ma_active){
2015
+ promises.low_calibration_420ma = node.config_gateway.config_set_low_calibration_420ma(mac, parseInt(config.low_calibration_420ma));
2016
+ }
2017
+ if(config.mid_calibration_420ma_active){
2018
+ promises.mid_calibration_420ma = node.config_gateway.config_set_mid_calibration_420ma(mac, parseInt(config.mid_calibration_420ma));
2019
+ }
2020
+ if(config.high_calibration_420ma_active){
2021
+ promises.high_calibration_420ma = node.config_gateway.config_set_high_calibration_420ma(mac, parseInt(config.high_calibration_420ma));
1811
2022
  }
1812
2023
  break;
1813
2024
  case 540:
@@ -1827,7 +2038,7 @@ module.exports = function(RED) {
1827
2038
  }
1828
2039
  }
1829
2040
  // These sensors listed in original_otf_devices use a different OTF code.
1830
- let original_otf_devices = [53, 80, 81, 82, 83, 84, 101, 102, 180, 181, 518, 519, 520];
2041
+ let original_otf_devices = [53, 80, 81, 82, 83, 84, 101, 102, 180, 181, 518, 519, 520, 538];
1831
2042
  // If we changed the network ID reboot the sensor to take effect.
1832
2043
  // TODO if we add the encryption key command to node-red we need to reboot for it as well.
1833
2044
  if(reboot){