@ncd-io/node-red-enterprise-sensors 0.1.4 → 0.1.6

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.
@@ -62,7 +62,7 @@ module.exports = class WirelessSensor{
62
62
  var new_mode = is_new;
63
63
  var mode = (type == 'power_up') ? data.mode : ((type == 'sensor_data') ? 'RUN' : ((type == 'config_ack') ? 'ACK' : 'PGM'));
64
64
  // #OTF
65
- var otf_devices = [80,81,82,84,101,102,519,520];
65
+ var otf_devices = [80,81,82,84,89,101,102,519,520];
66
66
  var device_type = msbLsb(frame.data[6], frame.data[7]);
67
67
  // var device_type = frame.data[7];
68
68
 
@@ -79,6 +79,9 @@ module.exports = class WirelessSensor{
79
79
  }else{
80
80
  data.sensor_type = msbLsb(frame.data[3], frame.data[4]);
81
81
  }
82
+ if(data.sensor_type == 0){
83
+ data.sensor_type = msbLsb(frame.data[3], frame.data[4]);
84
+ }
82
85
  if(frame.data[7] == 79 && frame.data[8] == 84 && frame.data[9] == 78){
83
86
  mode = "OTN";
84
87
  }
@@ -123,8 +126,18 @@ module.exports = class WirelessSensor{
123
126
  }
124
127
  // mode === 'ACK' check added to allow multiple configs through front end gateway input
125
128
  if(new_mode || mode === 'ACK'){
126
- that._emitter.emit('sensor_mode', that.sensor_pool[frame.mac]);
127
- that._emitter.emit('sensor_mode-'+frame.mac, that.sensor_pool[frame.mac]);
129
+ // If RSSI is not enabled send stored values, if it is, request the RSSI and temporarily append it.
130
+ if(typeof frame.rssi == 'undefined'){
131
+ that._emitter.emit('sensor_mode', that.sensor_pool[frame.mac]);
132
+ that._emitter.emit('sensor_mode-'+frame.mac, that.sensor_pool[frame.mac]);
133
+ }else{
134
+ frame.rssi.then((v) => {
135
+ let sensor_pool_rssi = that.sensor_pool[frame.mac];
136
+ sensor_pool_rssi.rssi = v.data[0];
137
+ that._emitter.emit('sensor_mode', sensor_pool_rssi);
138
+ that._emitter.emit('sensor_mode-'+frame.mac, sensor_pool_rssi);
139
+ }).catch(console.log);
140
+ }
128
141
  }
129
142
  if(mode != 'FLY'){
130
143
  var send_events = function(){
@@ -201,7 +214,7 @@ module.exports = class WirelessSensor{
201
214
  };
202
215
 
203
216
  // #OTF
204
- var otf_devices = [80,81,82,84,101,102,519,520];
217
+ var otf_devices = [80,81,82,84,89,101,102,519,520];
205
218
  if(otf_devices.includes(parsed.sensor_type)){
206
219
  // If the message says FLY and there is not FLY timer in progress.
207
220
  if(payload[8] == 70 && payload[9] == 76 && payload[10] == 89) {
@@ -995,6 +1008,31 @@ module.exports = class WirelessSensor{
995
1008
  return this.config_send(sensor_mac, packet);
996
1009
  }
997
1010
 
1011
+ config_set_low_calibration_420ma(sensor_mac, value){
1012
+ console.log('config_set_low_calibration_420ma');
1013
+ let packet = [244, 66, 0, 0, 45, 1];
1014
+ let calibration = int2Bytes((value), 4);
1015
+ packet.push(...calibration);
1016
+ console.log(packet);
1017
+ return this.config_send(sensor_mac, packet);
1018
+ }
1019
+ config_set_mid_calibration_420ma(sensor_mac, value){
1020
+ console.log('config_set_mid_calibration_420ma');
1021
+ let packet = [244, 66, 0, 0, 45, 2];
1022
+ let calibration = int2Bytes((value), 4);
1023
+ packet.push(...calibration);
1024
+ console.log(packet);
1025
+ return this.config_send(sensor_mac, packet);
1026
+ }
1027
+ config_set_high_calibration_420ma(sensor_mac, value){
1028
+ console.log('config_set_high_calibration_420ma');
1029
+ let packet = [244, 66, 0, 0, 45, 3];
1030
+ let calibration = int2Bytes((value), 4);
1031
+ packet.push(...calibration);
1032
+ console.log(packet);
1033
+ return this.config_send(sensor_mac, packet);
1034
+ }
1035
+
998
1036
  config_get_delay(sensor_mac){
999
1037
  return new Promise((fulfill, reject) => {
1000
1038
  this.config_send(sensor_mac, [247, 21, 0, 0, 0]).then((res) => {
@@ -4058,7 +4096,7 @@ function sensor_types(parent){
4058
4096
  },
4059
4097
 
4060
4098
  '84': {
4061
- name: 'Type 84 - Vibration on a stick',
4099
+ name: 'Type 84 - Standalone Smart Vibration Sensor',
4062
4100
  parse: (payload, parsed, mac) => {
4063
4101
  if(payload[7] >> 1 != 0){
4064
4102
  console.log('Error found');
@@ -4613,7 +4651,27 @@ function sensor_types(parent){
4613
4651
  }
4614
4652
  }
4615
4653
  },
4616
-
4654
+ '89': {
4655
+ name: '2 Channel Ultrasound Vibration Sensor',
4656
+ parse: (d) => {
4657
+ return {
4658
+ c1_raw_adc: d.slice(0, 2).reduce(msbLsb),
4659
+ c1_ma: d.slice(2, 4).reduce(msbLsb) / 100,
4660
+ c1_db: d.slice(4, 6).reduce(msbLsb) / 100,
4661
+ c2_raw_adc: d.slice(6, 8).reduce(msbLsb),
4662
+ c2_ma: d.slice(8, 10).reduce(msbLsb) / 100,
4663
+ c2_db: d.slice(10, 12).reduce(msbLsb) / 100
4664
+ };
4665
+ }
4666
+ },
4667
+ '92': {
4668
+ name: 'Sound Sensor',
4669
+ parse: (d) => {
4670
+ return {
4671
+ sound: signInt(d[3], 8)/100
4672
+ };
4673
+ }
4674
+ },
4617
4675
  '101':{
4618
4676
  name: 'Pro Vibration',
4619
4677
  parse: (d, full)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ncd-io/node-red-enterprise-sensors",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {