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

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
@@ -142,25 +142,32 @@ module.exports = function(RED) {
142
142
  // IF we receive an FON message with success
143
143
  if(Object.hasOwn(res, 'data') && res.data[0] == 70 && res.data[1] == 79 && res.data[2] == 78 && res.result == 255){
144
144
  manifest_data.enter_ota_fota_version = res.original.data[5];
145
- console.log('Great Success');
145
+ manifest_data.enter_ota_success = true;
146
146
  console.log(res);
147
+ }else{
148
+ manifest_data.enter_ota_success = false;
147
149
  }
148
150
  console.log(name);
149
151
  } else{
150
- // enter ota mode
151
- node.gateway.digi.send.at_command("ID", [0x7a, 0xaa]).then().catch().then(() => {
152
- console.log(manifest_data);
153
- if(manifest_data.enter_ota_fota_version <13){
154
- console.log('OLD PROCESSS');
152
+ if(manifest_data.enter_ota_success){
153
+ // enter ota mode
154
+ node.gateway.digi.send.at_command("ID", [0x7a, 0xaa]).then().catch().then(() => {
155
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
- }
163
- });
156
+ if(manifest_data.enter_ota_fota_version > 16){
157
+ console.log('V17 PROCESS');
158
+ console.log(manifest_data);
159
+ node.start_firmware_update_v17(manifest_data, firmware_data);
160
+ }else if(manifest_data.enter_ota_fota_version > 12){
161
+ console.log('V13 PROCESS');
162
+ console.log(manifest_data);
163
+ node.start_firmware_update_v13(manifest_data, firmware_data);
164
+ }else{
165
+ console.log('OLD PROCESSS');
166
+ console.log(manifest_data);
167
+ node.start_firmware_update(manifest_data, firmware_data);
168
+ }
169
+ });
170
+ }
164
171
  }
165
172
  }).catch((err) => {
166
173
  console.log(err);
@@ -352,6 +359,119 @@ module.exports = function(RED) {
352
359
  }
353
360
  });
354
361
  };
362
+ node.start_firmware_update_v17 = function(manifest_data, firmware_data){
363
+ console.log('V17 Update Start');
364
+ var start_offset = 0;
365
+ setTimeout(() => {
366
+ if(Object.hasOwn(node.sensor_list[manifest_data.addr], 'last_chunk_success')){
367
+ node.gateway.firmware_read_last_chunk_segment(manifest_data.addr).then((status_frame) => {
368
+ console.log('Last Chunk Segment Read');
369
+ console.log(status_frame);
370
+ start_offset = status_frame.data.slice(4,8).reduce(msbLsb);
371
+ node.queue_firmware_update_v17(manifest_data, firmware_data, start_offset);
372
+ }).catch((err) => {
373
+ // TODO FOTA EMIT ERROR FOTA
374
+ console.log('Error reading last chunk segment');
375
+ node.resume_normal_operation();
376
+ });
377
+ }else{
378
+ node.queue_firmware_update_v17(manifest_data, firmware_data, start_offset);
379
+ };
380
+ }, 1000);
381
+ };
382
+ node.queue_firmware_update_v17 = function(manifest_data, firmware_data, start_offset){
383
+ console.log('V17 Queue Update Start');
384
+ console.log('Start Offset: '+start_offset);
385
+ return new Promise((top_fulfill, top_reject) => {
386
+ var success = {successes:{}, failures:{}};
387
+
388
+ let chunk_size = 128;
389
+ let image_start = firmware_data.firmware.slice(1, 5).reduce(msbLsb)+6;
390
+ var promises = {};
391
+ if(start_offset == 0){
392
+ promises.manifest = node.gateway.firmware_send_manifest(manifest_data.addr, firmware_data.firmware.slice(5, image_start-1));
393
+ };
394
+ // promises.manifest = node.gateway.firmware_send_manifest(manifest_data.addr, firmware_data.firmware.slice(5, image_start-1));
395
+ firmware_data.firmware = firmware_data.firmware.slice(image_start+4);
396
+
397
+ // if(Object.hasOwn(node.sensor_list[manifest_data.addr], 'last_chunk_success')){
398
+ // index = node.sensor_list[manifest_data.addr].last_chunk_success;
399
+ // }
400
+
401
+ // reverse calculate index based on start_offset.
402
+ var index = parseInt(start_offset / chunk_size);
403
+ console.log('Index: '+index);
404
+ while(index*chunk_size < firmware_data.manifest.image_size){
405
+ let offset = index*chunk_size;
406
+ let offset_bytes = int2Bytes(offset, 4);
407
+ let firmware_chunk = firmware_data.firmware.slice(index*chunk_size, index*chunk_size+chunk_size);
408
+ promises[index] = node.gateway.firmware_send_chunk_v13(manifest_data.addr, offset_bytes, firmware_chunk);
409
+ if(((index + 1) % 50) == 0 || (index+1)*chunk_size >= firmware_data.manifest.image_size){
410
+ promises[index+'_check'] = node.gateway.firmware_read_last_chunk_segment(manifest_data.addr);
411
+ };
412
+ index++;
413
+ }
414
+ console.log('Update Started');
415
+ console.log(Object.keys(promises).length);
416
+ console.log(Date.now());
417
+ promises.reboot = node.gateway.config_reboot_sensor(manifest_data.addr);
418
+ var firmware_continue = true;
419
+ for(var i in promises){
420
+ (function(name){
421
+ let retryCount = 0;
422
+ const maxRetries = 3; // Set the maximum number of retries
423
+
424
+ function attemptPromise() {
425
+ console.log(name);
426
+ promises[name].then((status_frame) => {
427
+ if(name == 'manifest'){
428
+ console.log('MANIFEST SUCCESFULLY SENT');
429
+ node.sensor_list[manifest_data.addr].test_check = {name: true};
430
+ node.sensor_list[manifest_data.addr].update_in_progress = true;
431
+ }
432
+ else if(name.includes('_check')){
433
+ console.log(name);
434
+ console.log(parseInt(name.split('_')[0]) * chunk_size);
435
+ let last_chunk = status_frame.data.slice(0,4).reduce(msbLsb);
436
+ console.log(last_chunk);
437
+ if(last_chunk != (parseInt(name.split('_')[0]) * chunk_size)){
438
+ console.log('ERROR DETECTED IN OTA UPDATE');
439
+ success.failures[name] = {chunk: last_chunk, last_transmit: (parseInt(name.split('_')[0]) * chunk_size), last_report: last_chunk};
440
+ // node.gateway.clear_queue_except_last();
441
+ node.gateway.clear_queue();
442
+ node.resume_normal_operation();
443
+ } else {
444
+ success.successes[name] = {chunk: last_chunk};
445
+ }
446
+ }
447
+ else {
448
+ success[name] = true;
449
+ node.sensor_list[manifest_data.addr].test_check[name] = true;
450
+ node.sensor_list[manifest_data.addr].last_chunk_success = name;
451
+ }
452
+ }).catch((err) => {
453
+ console.log(name);
454
+ console.log(err);
455
+ if(name != 'reboot'){
456
+ node.gateway.clear_queue();
457
+ success[name] = err;
458
+ } else {
459
+ delete node.sensor_list[manifest_data.addr].last_chunk_success;
460
+ delete node.sensor_list[manifest_data.addr].update_request;
461
+ node._emitter.emit('send_firmware_stats', {state: success, addr: manifest_data.addr});
462
+ top_fulfill(success);
463
+ }
464
+ console.log('Update Finished')
465
+ console.log(Date.now());
466
+ node._emitter.emit('send_firmware_stats', {state: success, addr: manifest_data.addr});
467
+ node.resume_normal_operation();
468
+ });
469
+ }
470
+ attemptPromise(); // Start the initial attempt
471
+ })(i);
472
+ }
473
+ });
474
+ }
355
475
  node.resume_normal_operation = function(){
356
476
  let pan_id = parseInt(config.pan_id, 16);
357
477
  node.gateway.digi.send.at_command("ID", [pan_id >> 8, pan_id & 255]).then().catch().then(() => {
@@ -450,6 +570,18 @@ module.exports = function(RED) {
450
570
 
451
571
  node.on('close', function(){
452
572
  this._gateway_node.close_comms();
573
+ this._gateway_node._emitter.removeAllListeners('send_manifest');
574
+ this._gateway_node._emitter.removeAllListeners('send_firmware_stats');
575
+ this._gateway_node._emitter.removeAllListeners('mode_change');
576
+ this.gateway._emitter.removeAllListeners('ncd_error');
577
+ this.gateway._emitter.removeAllListeners('sensor_data');
578
+ this.gateway._emitter.removeAllListeners('sensor_mode');
579
+ this.gateway._emitter.removeAllListeners('receive_packet-unknown_device');
580
+ this.gateway._emitter.removeAllListeners('route_info');
581
+ this.gateway._emitter.removeAllListeners('link_info');
582
+ this.gateway._emitter.removeAllListeners('converter_response');
583
+ this.gateway._emitter.removeAllListeners('manifest_received');
584
+ console.log(this.gateway._emitter.eventNames());
453
585
  });
454
586
 
455
587
  node.is_config = false;
@@ -555,10 +687,13 @@ module.exports = function(RED) {
555
687
  // 'description': 'Query water levels in mm/cm',
556
688
  // 'target_parser': 'parse_water_levels'
557
689
  // }
690
+ if(!Object.hasOwn(msg.payload, 'timeout')){
691
+ msg.payload.timeout = 1500;
692
+ }
558
693
  if(msg.payload.hasOwnProperty('meta')){
559
- node.gateway.queue_bridge_query(msg.payload.address, msg.payload.command, msg.payload.meta);
694
+ node.gateway.queue_bridge_query(msg.payload.address, msg.payload.command, msg.payload.meta, msg.payload.timeout);
560
695
  }else{
561
- node.gateway.queue_bridge_query(msg.payload.address, msg.payload.command);
696
+ node.gateway.queue_bridge_query(msg.payload.address, msg.payload.command, null, msg.payload.timeout);
562
697
  }
563
698
  break;
564
699
  case "converter_send_multiple":
@@ -583,7 +718,10 @@ module.exports = function(RED) {
583
718
  // }
584
719
  // }
585
720
  // ];
586
- node.gateway.prepare_bridge_query(msg.payload.address, msg.payload.commands);
721
+ if(!Object.hasOwn(msg.payload, 'timeout')){
722
+ msg.payload.timeout = 1500;
723
+ }
724
+ node.gateway.prepare_bridge_query(msg.payload.address, msg.payload.commands, msg.payload.timeout);
587
725
  break;
588
726
  case "start_luber":
589
727
  // msg = {
@@ -739,10 +877,10 @@ module.exports = function(RED) {
739
877
  // }
740
878
  // TODO unfinished
741
879
  msg.payload.addresses.forEach((address) => {
742
- if(!Object.hasOwn(node._gateway_node.sensor_list, msg.payload.address)){
880
+ if(!Object.hasOwn(node._gateway_node.sensor_list, address)){
743
881
  node._gateway_node.sensor_list[address] = {};
744
882
  };
745
- if(!Object.hasOwn(node._gateway_node.sensor_list[msg.payload.address], 'update_request')){
883
+ if(!Object.hasOwn(node._gateway_node.sensor_list[address], 'update_request')){
746
884
  node._gateway_node.sensor_list[address].update_request = true;
747
885
  };
748
886
  });
@@ -909,7 +1047,7 @@ module.exports = function(RED) {
909
1047
 
910
1048
  var promises = {};
911
1049
  // This command is used for OTF on types 53, 80,81,82,83,84, 101, 102, 110, 111, 518, 519
912
- let original_otf_devices = [53, 80, 81, 82, 83, 84, 101, 102, 110, 111, 112, 114, 117, 180, 181, 518, 519, 520, 538];
1050
+ let original_otf_devices = [53, 80, 81, 82, 83, 84, 87, 101, 102, 103, 110, 111, 112, 114, 117, 180, 181, 518, 519, 520, 538];
913
1051
  if(original_otf_devices.includes(sensor.type)){
914
1052
  // This command is used for OTF on types 53, 80, 81, 82, 83, 84, 101, 102, 110, 111, 518, 519
915
1053
  promises.config_enter_otn_mode = node.config_gateway.config_enter_otn_mode(sensor.mac);
@@ -1251,6 +1389,12 @@ module.exports = function(RED) {
1251
1389
  if(config.pressure_sensor_type_21_active){
1252
1390
  promises.pressure_sensor_type_21 = node.config_gateway.config_set_pressure_sensor_type_21(mac, parseInt(config.pressure_sensor_type_21));
1253
1391
  }
1392
+ if(config.pressure_sensor_range_AMS5812_21_active){
1393
+ promises.pressure_sensor_range_AMS5812_21 = node.config_gateway.config_set_pressure_sensor_range_21(mac, parseInt(config.pressure_sensor_range_AMS5812_21));
1394
+ }
1395
+ if(config.pressure_sensor_range_AMS5915_21_active){
1396
+ promises.pressure_sensor_range_AMS5915_21 = node.config_gateway.config_set_pressure_sensor_range_21(mac, parseInt(config.pressure_sensor_range_AMS5915_21));
1397
+ }
1254
1398
  break;
1255
1399
  case 23:
1256
1400
  if(config.thermocouple_type_23_active){
@@ -1535,6 +1679,9 @@ module.exports = function(RED) {
1535
1679
  if(config.sampling_rate_duration_active){
1536
1680
  promises.sampling_rate_duration = node.config_gateway.config_set_sampling_rate_duration(mac, parseInt(config.sampling_rate_duration));
1537
1681
  }
1682
+ if(config.start_sps30_fan_cleaning_53){
1683
+ promises.start_sps30_fan_cleaning_53 = node.config_gateway.config_set_start_sps30_fan_cleaning_53(mac);
1684
+ }
1538
1685
  break;
1539
1686
  case 56:
1540
1687
  if(config.sensor_boot_time_420ma_active){
@@ -1621,8 +1768,8 @@ module.exports = function(RED) {
1621
1768
  if(config.x_axis_101 || config.y_axis_101 || config.z_axis_101){
1622
1769
  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);
1623
1770
  }
1624
- if(config.sampling_interval_101_active){
1625
- promises.sampling_interval_101 = node.config_gateway.config_set_sampling_interval_101(mac, parseInt(config.sampling_interval_101));
1771
+ if(config.sampling_interval_80_active){
1772
+ promises.sampling_interval = node.config_gateway.config_set_sampling_interval_101(mac, parseInt(config.sampling_interval_80));
1626
1773
  }
1627
1774
  if(config.full_scale_range_101_active){
1628
1775
  promises.full_scale_range_101 = node.config_gateway.config_set_full_scale_range_101(mac, parseInt(config.full_scale_range_101));
@@ -1671,8 +1818,8 @@ module.exports = function(RED) {
1671
1818
  if(config.x_axis_101 || config.y_axis_101 || config.z_axis_101){
1672
1819
  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);
1673
1820
  }
1674
- if(config.sampling_interval_101_active){
1675
- promises.sampling_interval_101 = node.config_gateway.config_set_sampling_interval_101(mac, parseInt(config.sampling_interval_101));
1821
+ if(config.sampling_interval_80_active){
1822
+ promises.sampling_interval = node.config_gateway.config_set_sampling_interval_101(mac, parseInt(config.sampling_interval_80));
1676
1823
  }
1677
1824
  if(config.full_scale_range_101_active){
1678
1825
  promises.full_scale_range_101 = node.config_gateway.config_set_full_scale_range_101(mac, parseInt(config.full_scale_range_101));
@@ -1724,8 +1871,8 @@ module.exports = function(RED) {
1724
1871
  if(config.x_axis_101 || config.y_axis_101 || config.z_axis_101){
1725
1872
  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);
1726
1873
  }
1727
- if(config.sampling_interval_101_active){
1728
- promises.sampling_interval_101 = node.config_gateway.config_set_sampling_interval_101(mac, parseInt(config.sampling_interval_101));
1874
+ if(config.sampling_interval_80_active){
1875
+ promises.sampling_interval = node.config_gateway.config_set_sampling_interval_101(mac, parseInt(config.sampling_interval_80));
1729
1876
  }
1730
1877
  if(config.full_scale_range_101_active){
1731
1878
  promises.full_scale_range_101 = node.config_gateway.config_set_full_scale_range_101(mac, parseInt(config.full_scale_range_101));
@@ -1768,8 +1915,8 @@ module.exports = function(RED) {
1768
1915
  if(config.x_axis_101 || config.y_axis_101 || config.z_axis_101){
1769
1916
  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);
1770
1917
  }
1771
- if(config.sampling_interval_101_active){
1772
- promises.sampling_interval_101 = node.config_gateway.config_set_sampling_interval_101(mac, parseInt(config.sampling_interval_101));
1918
+ if(config.sampling_interval_80_active){
1919
+ promises.sampling_interval = node.config_gateway.config_set_sampling_interval_101(mac, parseInt(config.sampling_interval_80));
1773
1920
  }
1774
1921
  if(config.full_scale_range_101_active){
1775
1922
  promises.full_scale_range_101 = node.config_gateway.config_set_full_scale_range_101(mac, parseInt(config.full_scale_range_101));
@@ -1840,6 +1987,26 @@ module.exports = function(RED) {
1840
1987
  promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
1841
1988
  }
1842
1989
  break;
1990
+ case 87:
1991
+ if(config.ct_constant_87_active){
1992
+ promises.ct_constant_87 = node.config_gateway.config_set_ct_constant_87(mac, parseInt(config.ct_constant_87));
1993
+ }
1994
+ if(config.deadband_87_active){
1995
+ promises.deadband_87 = node.config_gateway.config_set_deadband_87(mac, parseInt(config.deadband_87));
1996
+ }
1997
+ if(config.sampling_frequency_87_active){
1998
+ promises.sampling_frequency_87 = node.config_gateway.config_set_sampling_frequency_87(mac, parseInt(config.sampling_frequency_87));
1999
+ }
2000
+ if(config.raw_length_87_active){
2001
+ promises.raw_length_87 = node.config_gateway.config_set_raw_length_87(mac, parseInt(config.raw_length_87));
2002
+ }
2003
+ if(config.stay_on_mode_539_active){
2004
+ promises.stay_on_mode_87 = node.config_gateway.config_set_stay_on_mode_539(mac, parseInt(config.stay_on_mode_539));
2005
+ }
2006
+ if(config.quality_of_service_121_active){
2007
+ promises.quality_of_service_87 = node.config_gateway.config_set_quality_of_service_121(mac, parseInt(config.quality_of_service_121));
2008
+ }
2009
+ break;
1843
2010
  case 88:
1844
2011
  if(config.sensor_boot_time_420ma_active){
1845
2012
  promises.sensor_boot_time_420ma = node.config_gateway.config_set_sensor_boot_time_420ma(mac, parseInt(config.sensor_boot_time_420ma));
@@ -2062,6 +2229,35 @@ module.exports = function(RED) {
2062
2229
  // }
2063
2230
  // promises.set_rtc_101 = node.config_gateway.config_set_rtc_101(mac);
2064
2231
  break;
2232
+ case 103:
2233
+ if(config.output_data_rate_103_active){
2234
+ promises.output_data_rate_103 = node.config_gateway.config_set_output_data_rate_101(mac, parseInt(config.output_data_rate_103));
2235
+ }
2236
+ if(config.sampling_interval_101_active){
2237
+ promises.sampling_interval_103 = node.config_gateway.config_set_sampling_interval_101(mac, parseInt(config.sampling_interval_101));
2238
+ }
2239
+ if(config.acc_threshold_103_active){
2240
+ promises.acc_threshold_103 = node.config_gateway.config_set_acc_threshold_103(mac, parseInt(config.acc_threshold_103));
2241
+ }
2242
+ if(config.enable_sensor_103_active){
2243
+ promises.enable_sensor_103 = node.config_gateway.config_set_enable_sensor_103(mac, parseInt(config.enable_sensor_103));
2244
+ }
2245
+ if(config.enable_hp_filter_cutoff_103_active){
2246
+ promises.enable_hp_filter_cutoff_103 = node.config_gateway.config_set_enable_hp_filter_cutoff_103(mac, parseInt(config.enable_hp_filter_cutoff_103));
2247
+ }
2248
+ if(config.gyro_fsr_103_active){
2249
+ promises.gyro_fsr_103 = node.config_gateway.config_set_gyro_fsr_103(mac, parseInt(config.gyro_fsr_103));
2250
+ }
2251
+ if(config.adxl_fsr_103_active){
2252
+ promises.adxl_fsr_103 = node.config_gateway.config_set_adxl_fsr_103(mac, parseInt(config.adxl_fsr_103));
2253
+ }
2254
+ if(config.sampling_duration_103_active){
2255
+ promises.sampling_duration_103 = node.config_gateway.config_set_sampling_duration_101(mac, parseInt(config.sampling_duration_103));
2256
+ }
2257
+ if(config.set_rtc_101){
2258
+ promises.set_rtc_103 = node.config_gateway.config_set_rtc_101(mac);
2259
+ }
2260
+ break;
2065
2261
  case 105:
2066
2262
  if(config.sensor_boot_time_420ma_active){
2067
2263
  promises.sensor_boot_time_420ma = node.config_gateway.config_set_sensor_boot_time_420ma(mac, parseInt(config.sensor_boot_time_420ma));
@@ -2153,6 +2349,9 @@ module.exports = function(RED) {
2153
2349
  if(config.debounce_time_108_active){
2154
2350
  promises.debounce_time_108 = node.config_gateway.config_set_debounce_time_108(mac, parseInt(config.debounce_time_108));
2155
2351
  }
2352
+ if(config.debounce_time_v10_108_active){
2353
+ promises.debounce_time_v10_108 = node.config_gateway.config_set_debounce_time_v10_108(mac, parseInt(config.debounce_time_v10_108));
2354
+ }
2156
2355
  if(config.input_one_108_active){
2157
2356
  promises.input_one_108 = node.config_gateway.config_set_input_one_108(mac, parseInt(config.input_one_108));
2158
2357
  }
@@ -2204,6 +2403,9 @@ module.exports = function(RED) {
2204
2403
  if(config.sample_rate_108_active){
2205
2404
  promises.sample_rate_108 = node.config_gateway.config_set_sample_rate_108(mac, parseInt(config.sample_rate_108));
2206
2405
  }
2406
+ if(config.interrupt_timeout_108_active){
2407
+ promises.interrupt_timeout_108 = node.config_gateway.config_set_interrupt_timeout_108(mac, parseInt(config.interrupt_timeout_108));
2408
+ }
2207
2409
  break;
2208
2410
  case 110:
2209
2411
  if(config.odr_p1_110_active){
@@ -2272,6 +2474,12 @@ module.exports = function(RED) {
2272
2474
  if(config.max_raw_sample_110_active){
2273
2475
  promises.max_raw_sample_110 = node.config_gateway.config_set_max_raw_sample_110(mac, parseInt(config.max_raw_sample_110));
2274
2476
  }
2477
+ if(config.motion_to_sampling_delay_110_active){
2478
+ promises.motion_to_sampling_delay_110 = node.config_gateway.config_set_motion_to_sampling_delay_110(mac, parseInt(config.motion_to_sampling_delay_110));
2479
+ }
2480
+ if(config.max_num_motion_tx_delay_110_active){
2481
+ promises.max_num_motion_tx_delay_110 = node.config_gateway.config_set_max_num_motion_tx_delay_110(mac, parseInt(config.max_num_motion_tx_delay_110));
2482
+ }
2275
2483
  break;
2276
2484
  case 111:
2277
2485
  if(config.odr_p1_110_active){
@@ -2358,6 +2566,12 @@ module.exports = function(RED) {
2358
2566
  if(config.max_raw_sample_110_active){
2359
2567
  promises.max_raw_sample_110 = node.config_gateway.config_set_max_raw_sample_110(mac, parseInt(config.max_raw_sample_110));
2360
2568
  }
2569
+ if(config.motion_to_sampling_delay_110_active){
2570
+ promises.motion_to_sampling_delay_111 = node.config_gateway.config_set_motion_to_sampling_delay_110(mac, parseInt(config.motion_to_sampling_delay_110));
2571
+ }
2572
+ if(config.max_num_motion_tx_delay_110_active){
2573
+ promises.max_num_motion_tx_delay_111 = node.config_gateway.config_set_max_num_motion_tx_delay_110(mac, parseInt(config.max_num_motion_tx_delay_110));
2574
+ }
2361
2575
  break;
2362
2576
  case 112:
2363
2577
  if(config.current_calibration_82_active){
@@ -2450,6 +2664,12 @@ module.exports = function(RED) {
2450
2664
  if(config.max_raw_sample_110_active){
2451
2665
  promises.max_raw_sample_110 = node.config_gateway.config_set_max_raw_sample_110(mac, parseInt(config.max_raw_sample_110));
2452
2666
  }
2667
+ if(config.motion_to_sampling_delay_110_active){
2668
+ promises.motion_to_sampling_delay_112 = node.config_gateway.config_set_motion_to_sampling_delay_110(mac, parseInt(config.motion_to_sampling_delay_110));
2669
+ }
2670
+ if(config.max_num_motion_tx_delay_110_active){
2671
+ promises.max_num_motion_tx_delay_112 = node.config_gateway.config_set_max_num_motion_tx_delay_110(mac, parseInt(config.max_num_motion_tx_delay_110));
2672
+ }
2453
2673
  break;
2454
2674
  case 114:
2455
2675
  if(config.odr_p1_110_active){
@@ -2527,6 +2747,12 @@ module.exports = function(RED) {
2527
2747
  if(config.max_raw_sample_110_active){
2528
2748
  promises.max_raw_sample_110 = node.config_gateway.config_set_max_raw_sample_110(mac, parseInt(config.max_raw_sample_110));
2529
2749
  }
2750
+ if(config.motion_to_sampling_delay_110_active){
2751
+ promises.motion_to_sampling_delay_114 = node.config_gateway.config_set_motion_to_sampling_delay_110(mac, parseInt(config.motion_to_sampling_delay_110));
2752
+ }
2753
+ if(config.max_num_motion_tx_delay_110_active){
2754
+ promises.max_num_motion_tx_delay_114 = node.config_gateway.config_set_max_num_motion_tx_delay_110(mac, parseInt(config.max_num_motion_tx_delay_110));
2755
+ }
2530
2756
  break;
2531
2757
  case 118:
2532
2758
  if(config.pressure_sensor_fs_ch1_118_active){
@@ -2596,6 +2822,62 @@ module.exports = function(RED) {
2596
2822
  promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
2597
2823
  }
2598
2824
  break;
2825
+ case 123:
2826
+ if(config.clear_timers_123_active){
2827
+ promises.clear_timers_123 = node.config_gateway.config_set_clear_timers_108(mac, parseInt(config.clear_timers_123));
2828
+ }
2829
+ if(config.debounce_time_123_active){
2830
+ promises.debounce_time_123 = node.config_gateway.config_set_debounce_time_v10_108(mac, parseInt(config.debounce_time_123));
2831
+ }
2832
+ if(config.input_one_123_active){
2833
+ promises.input_one_123 = node.config_gateway.config_set_input_one_108(mac, parseInt(config.input_one_123));
2834
+ }
2835
+ if(config.input_two_123_active){
2836
+ promises.input_two_123 = node.config_gateway.config_set_input_two_108(mac, parseInt(config.input_two_123));
2837
+ }
2838
+ if(config.input_three_123_active){
2839
+ promises.input_three_123 = node.config_gateway.config_set_input_three_108(mac, parseInt(config.input_three_123));
2840
+ }
2841
+ if(config.counter_threshold_108_active){
2842
+ promises.counter_threshold_123 = node.config_gateway.config_set_counter_threshold_108(mac, parseInt(config.counter_threshold_108));
2843
+ }
2844
+ if(config.push_notification_123_active){
2845
+ promises.push_notification_123 = node.config_gateway.config_set_push_notification_108(mac, parseInt(config.push_notification_123));
2846
+ }
2847
+ if(config.reset_timeout_108_active){
2848
+ promises.reset_timeout_123 = node.config_gateway.config_set_reset_timeout_108(mac, parseInt(config.reset_timeout_108));
2849
+ }
2850
+ if(config.reset_mode_to_disabled_108_active){
2851
+ promises.reset_mode_123 = node.config_gateway.config_set_reset_mode_to_disabled_108(mac, parseInt(config.reset_mode_to_disabled_108));
2852
+ }
2853
+ if(config.rtc_108){
2854
+ promises.rtc_123 = node.config_gateway.config_set_rtc_108(mac);
2855
+ }
2856
+ if(config.transmission_interval_108_active){
2857
+ promises.transmission_interval_123 = node.config_gateway.config_set_transmission_interval_108(mac, parseInt(config.transmission_interval_108));
2858
+ }
2859
+ if(config.shift_one_108_active){
2860
+ promises.shift_time1_123 = node.config_gateway.config_set_shift_one_108(mac, parseInt(config.shift_one_hours_108), parseInt(config.shift_one_minutes_108));
2861
+ }
2862
+ if(config.shift_two_108_active){
2863
+ promises.shift_time2_123 = node.config_gateway.config_set_shift_two_108(mac, parseInt(config.shift_two_hours_108), parseInt(config.shift_two_minutes_108));
2864
+ }
2865
+ if(config.shift_three_108_active){
2866
+ promises.shift_time3_123 = node.config_gateway.config_set_shift_three_108(mac, parseInt(config.shift_three_hours_108), parseInt(config.shift_three_minutes_108));
2867
+ }
2868
+ if(config.shift_four_108_active){
2869
+ promises.shift_time4_123 = node.config_gateway.config_set_shift_four_108(mac, parseInt(config.shift_four_hours_108), parseInt(config.shift_four_minutes_108));
2870
+ }
2871
+ if(config.quality_of_service_108_active){
2872
+ promises.quality_of_service_123 = node.config_gateway.config_set_quality_of_service_108(mac, parseInt(config.quality_of_service_108));
2873
+ }
2874
+ if(config.fly_interval_108_active){
2875
+ promises.fly_interval_123 = node.config_gateway.config_set_fly_interval_108(mac, parseInt(config.fly_interval_108));
2876
+ }
2877
+ if(config.interrupt_timeout_108_active){
2878
+ promises.interrupt_timeout_123 = node.config_gateway.config_set_interrupt_timeout_108(mac, parseInt(config.interrupt_timeout_108));
2879
+ }
2880
+ break;
2599
2881
  case 180:
2600
2882
  if(config.output_data_rate_101_active){
2601
2883
  promises.output_data_rate_101 = node.config_gateway.config_set_output_data_rate_101(mac, parseInt(config.output_data_rate_101));
@@ -2724,6 +3006,17 @@ module.exports = function(RED) {
2724
3006
  promises.probe_boot_time_202 = node.config_gateway.config_set_probe_boot_time_202(mac, parseInt(config.probe_boot_time_202));
2725
3007
  }
2726
3008
  break;
3009
+ case 211:
3010
+ if(config.oxygen_rate_211_active){
3011
+ promises.oxygen_rate_211 = node.config_gateway.config_set_oxygen_rate_211(mac, parseInt(config.oxygen_rate_211));
3012
+ }
3013
+ if(config.oxygen_timeout_211_active){
3014
+ promises.oxygen_timeout_211 = node.config_gateway.config_set_oxygen_timeout_211(mac, parseInt(config.oxygen_timeout_211));
3015
+ }
3016
+ if(config.oxygen_threshold_211_active){
3017
+ promises.oxygen_threshold_211 = node.config_gateway.config_set_oxygen_threshold_211(mac, parseInt(config.oxygen_threshold_211));
3018
+ }
3019
+ break;
2727
3020
  case 217:
2728
3021
  if(config.tare_the_scale_217){
2729
3022
  promises.tare_the_scale_217 = node.config_gateway.config_set_tare_the_scale_217(mac);
@@ -2732,6 +3025,23 @@ module.exports = function(RED) {
2732
3025
  promises.weight_calib_217 = node.config_gateway.config_set_weight_calib_217(mac, parseInt(config.weight_calib_217));
2733
3026
  }
2734
3027
  break;
3028
+ case 270:
3029
+ // if(config.do_read_rate_270_active){
3030
+ // promises.sensors_read_rate_270 = node.config_gateway.config_set_do_read_rate_270(mac, parseInt(config.do_read_rate_270));
3031
+ // }
3032
+ if(config.do_boot_time_270_active){
3033
+ promises.do_boot_time_270 = node.config_gateway.config_set_do_boot_time_270(mac, parseInt(config.do_boot_time_270));
3034
+ }
3035
+ if(config.do_dev_id_270_active){
3036
+ promises.do_dev_id_270 = node.config_gateway.config_set_do_dev_id_270(mac, parseInt(config.do_dev_id_1_270), parseInt(config.do_dev_id_2_270), parseInt(config.do_dev_id_3_270), parseInt(config.do_dev_id_4_270));
3037
+ }
3038
+ if(config.ec_boot_time_270_active){
3039
+ promises.ec_boot_time_270 = node.config_gateway.config_set_ec_boot_time_270(mac, parseInt(config.ec_boot_time_270));
3040
+ }
3041
+ if(config.ec_dev_id_270_active){
3042
+ promises.ec_dev_id_270 = node.config_gateway.config_set_ec_dev_id_270(mac, parseInt(config.ec_dev_id_1_270), parseInt(config.ec_dev_id_2_270), parseInt(config.ec_dev_id_3_270), parseInt(config.ec_dev_id_4_270));
3043
+ }
3044
+ break;
2735
3045
  case 505:
2736
3046
  if(config.current_calibration_c1_80_active){
2737
3047
  promises.current_calibration_c1_80_active = node.config_gateway.config_set_current_calibration_individual_80(mac, parseInt(config.current_calibration_c1_80), 1);
@@ -2982,6 +3292,38 @@ module.exports = function(RED) {
2982
3292
  promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
2983
3293
  }
2984
3294
  break;
3295
+ case 541:
3296
+ if(config.sensor_boot_time_420ma_active){
3297
+ promises.sensor_boot_time_420ma = node.config_gateway.config_set_sensor_boot_time_420ma(mac, parseInt(config.sensor_boot_time_420ma));
3298
+ }
3299
+ if(config.low_calibration_420ma_active){
3300
+ promises.low_calibration_420ma = node.config_gateway.config_set_low_calibration_420ma(mac, parseInt(config.low_calibration_420ma));
3301
+ }
3302
+ if(config.mid_calibration_420ma_active){
3303
+ promises.mid_calibration_420ma = node.config_gateway.config_set_mid_calibration_420ma(mac, parseInt(config.mid_calibration_420ma));
3304
+ }
3305
+ if(config.high_calibration_420ma_active){
3306
+ promises.high_calibration_420ma = node.config_gateway.config_set_high_calibration_420ma(mac, parseInt(config.high_calibration_420ma));
3307
+ }
3308
+ if(config.auto_check_interval_88_active){
3309
+ promises.auto_check_interval_88 = node.config_gateway.config_set_auto_check_interval_88(mac, parseInt(config.auto_check_interval_88));
3310
+ }
3311
+ if(config.auto_check_threshold_88_active){
3312
+ promises.auto_check_threshold_88 = node.config_gateway.config_set_auto_check_threshold_88(mac, parseInt(config.auto_check_threshold_88));
3313
+ }
3314
+ if(config.fsr_420ma_active){
3315
+ promises.fsr_420ma = node.config_gateway.config_set_fsr_420ma(mac, parseInt(config.fsr_420ma));
3316
+ }
3317
+ if(config.always_on_420ma_active){
3318
+ promises.always_on_420ma = node.config_gateway.config_set_always_on_420ma(mac, parseInt(config.always_on_420ma));
3319
+ }
3320
+ if(config.max_flow_541_active){
3321
+ promises.max_flow_541 = node.config_gateway.config_set_max_flow_541(mac, parseInt(config.max_flow_541));
3322
+ }
3323
+ if(config.min_flow_541_active){
3324
+ promises.min_flow_541 = node.config_gateway.config_set_min_flow_541(mac, parseInt(config.min_flow_541));
3325
+ }
3326
+ break;
2985
3327
  case 1010:
2986
3328
  if(config.stay_on_mode_539_active){
2987
3329
  promises.stay_on_mode_539 = node.config_gateway.config_set_stay_on_mode_539(mac, parseInt(config.stay_on_mode_539));
@@ -3031,7 +3373,7 @@ module.exports = function(RED) {
3031
3373
  }
3032
3374
  }
3033
3375
  // These sensors listed in original_otf_devices use a different OTF code.
3034
- let original_otf_devices = [53, 80, 81, 82, 83, 84, 101, 102, 110, 111, 112, 114, 117, 180, 181, 518, 519, 520, 538];
3376
+ let original_otf_devices = [53, 80, 81, 82, 83, 84, 87, 101, 102, 103, 110, 111, 112, 114, 117, 180, 181, 518, 519, 520, 538];
3035
3377
  // If we changed the network ID reboot the sensor to take effect.
3036
3378
  // TODO if we add the encryption key command to node-red we need to reboot for it as well.
3037
3379
  if(reboot){
@@ -3344,9 +3686,10 @@ module.exports = function(RED) {
3344
3686
  for(var p in pgm_events){
3345
3687
  node.config_gateway._emitter.removeAllListeners(p);
3346
3688
  }
3689
+
3347
3690
  node.gateway_node.close_comms();
3348
3691
  if(typeof node.config_gateway_node != 'undefined'){
3349
- node.config_gateway_node.close_comms();
3692
+ console.log(node.config_gateway_node.close_comms());
3350
3693
  }
3351
3694
  });
3352
3695
  }