node-red-contrib-tak-registration
Version:
A Node-RED node to register to TAK and to help wrap files as datapackages to send to TAK
183 lines (176 loc) • 9.29 kB
HTML
<script type="text/html" data-template-name="tak registration">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-latitude"><i class="fa fa-globe"></i> Latitude</label>
<input type="text" id="node-input-latitude" placeholder="degrees dd.ddddd">
</div>
<div class="form-row">
<label for="node-input-longitude"><i class="fa fa-globe"></i> Longitude</label>
<input type="text" id="node-input-longitude" placeholder="degrees dd.ddddd">
</div>
<div class="form-row">
<label for="node-input-callsign"><i class="fa fa-user-circle-o"></i> Callsign</label>
<input type="text" id="node-input-callsign" placeholder="Nickname">
</div>
<div class="form-row">
<label for="node-input-group"><i class="fa fa-users"></i> Group</label>
<!-- <input type="text" id="node-input-group" placeholder="Group (if any)"> -->
<select id="node-input-group">
<option value="Cyan">Cyan</option>
<option value="Yellow">Yellow</option>
<option value="Red">Red</option>
<option value="Blue">Blue</option>
<option value="Green">Green</option>
<option value="Orange">Orange</option>
<option value="Magenta">Magenta</option>
<option value="Maroon">Maroon</option>
<option value="Purple">Purple</option>
<option value="Dark Blue">Dark Blue</option>
<option value="Dark Green">Dark Green</option>
<option value="Teal">Teal</option>
<option value="Brown">Brown</option>
</select>
</div>
<div class="form-row">
<label for="node-input-role"><i class="fa fa-crosshairs"></i> Role</label>
<!-- <input type="text" id="node-input-group" placeholder="Group (if any)"> -->
<select id="node-input-role">
<option value="Gateway">Gateway</option>
<option value="Team Member">Team Member</option>
<option value="Team Lead">Team Lead</option>
<option value="HQ">HQ</option>
<option value="Sniper">Sniper</option>
<option value="Medic">Medic</option>
<option value="Forward Observer">Forward Observer</option>
<option value="RTO">RTO</option>
<option value="K9">K9</option>
</select>
</div>
<div class="form-row" id="node-timing">
<label for="node-once"><i class="fa fa-heartbeat"></i> Heartbeat</label>
Send heartbeat every
<input id="inject-time-interval-count" class="inject-time-count" value="30" type="text"/>
<select style="width:100px" id="inject-time-interval-units">
<option value="s">Seconds</option>
<option value="m">Minutes</option>
<option value="h">Hours</option>
</select>
<input type="hidden" id="node-input-repeat">
</div>
<div class="form-row">
<label for="node-input-dphost"><i class="fa fa-globe"></i> DP-Host url:port</label>
<input type="text" id="node-input-dphost" placeholder="Data package server url http://server:port">
</div>
<div class="form-tips" id="pin-tip"><b>Note</b>: This node MUST be used in conjunction with a TCP request node,
configured to point to your TAK server tcp address and port (usually 8087 or 8089), set to return strings,
<i>keep connection open</i> mode, and split on <code></event></code></div>
</script>
<style>
.inject-time-count {
width: 40px ;
}
</style>
<script type="text/javascript">
RED.nodes.registerType('tak registration',{
category: 'location',
color:"#C0DEED",
defaults: {
name: {value:""},
callsign: {value: ""},
group: {value: "Cyan"},
role: {value: "Gateway"},
latitude: {value: ""},
longitude: {value: ""},
repeat: {value:"60", validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0) && (v <= 2147483))) }},
dphost: {value:""}
},
icon: "tak.png",
inputs: 1,
outputs: 1,
paletteLabel: "TAK gateway",
label: function() {
return "TAK gateway" || this.name;
},
oneditprepare: function() {
var r = "s";
var c = this.repeat;
if (this.repeat % 60 === 0) { r = "m"; c = c/60; }
if (this.repeat % 1440 === 0) { r = "h"; c = c/60; }
$("#inject-time-interval-count").val(c);
$("#inject-time-interval-units").val(r);
$("#inject-time-interval-days").prop("disabled","disabled");
},
oneditsave: function() {
var repeat = "";
var count = $("#inject-time-interval-count").val();
var units = $("#inject-time-interval-units").val();
if (units == "s") {
repeat = count;
} else {
if (units == "m") {
repeat = count * 60;
} else if (units == "h") {
repeat = count * 60 * 60;
}
}
$("#node-input-repeat").val(repeat);
}
});
</script>
<script type="text/html" data-help-name="tak registration">
<p>Registers a TAK gateway node and sets up a heartbeat.</p>
<p>Works in conjunction with a TCP request node, set to point to the TAK server tcp address and port
(usually 8087 or 8089), set to return strings, <i>keep connection open</i> mode, and split on <code></event></code>.</p>
<p>If the <code>msg.payload</code> is an XML string it will be passed directly though.</p>
<h3>Sending data packages...</h3>
<dl class="message-properties">
<dt>sendTo <span class="property-type">string | array</span></dt>
<dd>can either be an individual TAK callsign, an array of callsigns, or <b>broadcast</b>
to send to all users, or <b>public</b> to just upload the package to the TAK server.</dd>
<dt>topic <span class="property-type">string</span></dt>
<dd>the overall package name - IE what you want it to be called on the TAK device (keep it short).</dd>
<dt>attachments <span class="property-type">array of objects</span></dt>
<dd>each object must contain at least a <b>filename</b> (string) and <b>content</b> a buffer of the file/data.
eg <code>[{filename:"foo.kml", content: <buffer of the file>}]</code></dd>
<dt>from <span class="property-type">string</span></dt>
<dd>(optional) callsign of the person sending the file - defaults to the gateway node callsign.</dd>
<dt>lat <span class="property-type">number | (string)</span></dt>
<dd>(optional) latitude of the marker for the file.</dd>
<dt>lon <span class="property-type">number | (string)</span></dt>
<dd>(optional) longitude of the marker for the file.</dd>
</dl>
If you just need to send a single file then you can use <code>msg.filename</code> to set the filename and the <code>msg.payload</code> should be a binary buffer.
<h3>Sending simple GeoChat messages...</h3>
<dl class="message-properties">
<dt>sendTo <span class="property-type">string | array</span></dt>
<dd>can either be an individual TAK callsign, a comma separted list of callsigns, an array of callsigns,
or <b>broadcast</b> to send to all users.</dd>
<dt>payload <span class="property-type">string</span></dt>
<dd>the text of the message to send.</dd>
</dl>
<h3>Sending marker position...</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>a "standard" <b>node-red worldmap</b> format msg.payload containing `name, lat, lon, SIDC or cottype or aistype,
(alt), (speed), (bearing), (layer), (remarks)`, where SIDC is the standard mil 2525C code, eg SFGPU, or cottype is the
CoT type, eg a-f-g-u, or aistype is the AIS type code, eg 80 for a tanker. The layer will get turned into a hashtag
which can then be selected on/off in the TAK app layers control, and any `remarks` will get added to the CoT remarks
field.</dd>
</dl>
<h3>Updating gateway position...</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">string | object</span></dt>
<dd>Either an NMEA string starting `$GPGGA`, for example from a locally attached serial GPS, or an object
containing `lat` and `lon` and optional `alt` properties (but no name property).</dd>
</dl>
<h3>Details</h3>
<p>This should work almost directly with messages received from an email-in node for example -
but you will need to add the recipients in the sendTo property and may need to filter out
unwanted messages first.</p>
<p>As well as accepting simple worldmap type marker object it will accept "draw" actions from the
worldmap drawing layer and convert them to CoT objects for display.</p>
</p>
</script>