node-red-contrib-tak-registration 0.11.4 → 0.11.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tak-ingest.js +11 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-tak-registration",
3
- "version": "0.11.4",
3
+ "version": "0.11.5",
4
4
  "description": "A Node-RED node to register to TAK and to help wrap files as datapackages to send to TAK",
5
5
  "dependencies": {
6
6
  "@turf/turf": "6.5.0",
package/tak-ingest.js CHANGED
@@ -52,19 +52,16 @@ module.exports = function(RED) {
52
52
 
53
53
  node.on("input",function(msg) {
54
54
  if (Buffer.isBuffer(msg.payload)) {
55
- if (msg.payload[0] === 191 && !msg.hasOwnProperty("fromip")) {
56
- var l = msg.payload[1] + msg.payload[2] * 256;
57
- msg.payload = msg.payload.slice(3,l+3);
58
- handleProtoBuf(msg);
59
- return;
60
- }
61
- else if (msg.payload[0] === 191 && msg.payload[2] === 191) {
55
+ // handle UDP packet
56
+ if (msg.payload[0] === 191 && msg.payload[2] === 191) {
62
57
  var head = msg.payload[1];
63
58
  msg.payload = msg.payload.slice(3);
59
+ // type 1 = protobuf
64
60
  if (head === 1) {
65
61
  handleProtoBuf(msg);
66
62
  return;
67
63
  }
64
+ // type 0 = plain text
68
65
  else if (head === 0) {
69
66
  msg.payload = msg.payload.toString();
70
67
  }
@@ -73,6 +70,13 @@ module.exports = function(RED) {
73
70
  return;
74
71
  }
75
72
  }
73
+ // ideally need to check if tcp and streaming protobuf...
74
+ // else if (msg.payload[0] === 191 && !msg.hasOwnProperty("fromip")) {
75
+ // var l = msg.payload[1] + msg.payload[2] * 256;
76
+ // msg.payload = msg.payload.slice(3,l+3);
77
+ // handleProtoBuf(msg);
78
+ // return;
79
+ // }
76
80
  else {
77
81
  node.error("Unknown buffer type",msg);
78
82
  return;