Skip to content

Instantly share code, notes, and snippets.

@ampledata

ampledata/network_gps.json

Last active May 14, 2021
Embed
What would you like to do?
Node-RED Flow for adding Network GPS to ATAK & WinTAK
[{"id":"758f7cac.e17e64","type":"tcp request","z":"53dcc9e8.57f8d8","server":"127.0.0.1","port":"2947","out":"sit","splitc":" ","name":"Connect to GPSD TCP Port 2947","x":280,"y":320,"wires":[["12a46902.2a5087"]]},{"id":"90a23821.a7ee88","type":"inject","z":"53dcc9e8.57f8d8","name":"Start","props":[{"p":"payload"}],"repeat":"120","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":370,"y":240,"wires":[["930d05b5.b70958"]]},{"id":"930d05b5.b70958","type":"function","z":"53dcc9e8.57f8d8","name":"Config GPSD Output","func":"msg.payload = '?WATCH={\"enable\":true,\"json\":true,\"nmea\":true,\"raw\":0,\"scaled\":false,\"timing\":false,\"split24\":false,\"pps\":false}';\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":280,"wires":[["758f7cac.e17e64"]]},{"id":"12a46902.2a5087","type":"function","z":"53dcc9e8.57f8d8","name":"Buffer.toString()","func":"let oldPayload = msg.payload;\nmsg.payload = oldPayload.toString();\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":360,"wires":[["3b4e8dbe.678b62"]]},{"id":"83ed0b75.4cba38","type":"udp out","z":"53dcc9e8.57f8d8","name":"Send NMEA to WinTAK UDP Port 4349","addr":"172.17.2.109","iface":"","port":"4349","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":640,"y":440,"wires":[]},{"id":"1ae2d8ee.9311e7","type":"comment","z":"53dcc9e8.57f8d8","name":"Network GPS: https://ampledata.org/network_gps.html","info":"Node-RED Flow for adding Network GPS to ATAK & WinTAK. See https://ampledata.org/network_gps.html","x":360,"y":200,"wires":[]},{"id":"a265cace.2ba938","type":"switch","z":"53dcc9e8.57f8d8","name":"Filter for GPGGA Sentences","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"$GPGGA","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":300,"y":440,"wires":[["83ed0b75.4cba38","3597a012.bc6bd"]]},{"id":"3b4e8dbe.678b62","type":"split","z":"53dcc9e8.57f8d8","name":"Split by Newline","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":340,"y":400,"wires":[["a265cace.2ba938"]]},{"id":"821abfb7.28e64","type":"udp out","z":"53dcc9e8.57f8d8","name":"Send to ATAK UDP Port 4349","addr":"172.17.2.171","iface":"","port":"4349","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":590,"y":560,"wires":[]},{"id":"3597a012.bc6bd","type":"nmea","z":"53dcc9e8.57f8d8","name":"NMEA String to JSON","property":"payload","outputProperty":"payload","x":320,"y":480,"wires":[["fae5cb74.fbe638"]]},{"id":"3f051c62.f68744","type":"xml","z":"53dcc9e8.57f8d8","name":"JSON to XML","property":"payload","attr":"","chr":"","x":340,"y":560,"wires":[["821abfb7.28e64"]]},{"id":"fae5cb74.fbe638","type":"function","z":"53dcc9e8.57f8d8","name":"NMEA JSON to CoT Precision Location Event","func":"/*\nCreate a CoT XML serializable JSON payload from NMEA JSON input.\n\nAuthor:: Greg Albrecht W2GMD <oss@undef.net>\nSource:: https://ampledata.org/network_gps.html\n*/\n\n// Geenrate a timestamp for the CoT Event\nconst dt = Date.now();\nconst dtD = new Date(dt).toISOString();\n// \"stale\" Period (mostly ignored for this type of Event)\nconst dtD5 = new Date(dt + 250000).toISOString();\n\n// Copy old event for reference\nlet oldPayload = msg.payload;\n\nmsg.payload = {\n event: {\n $: {\n version: \"2.0\",\n uid: \"External-GPS\",\n type: \"a-f-G-E-S\",\n time: dtD,\n start: dtD,\n stale: dtD5,\n how: \"m-g\"\n },\n point: [ { \n $: {\n lat: oldPayload.lat,\n lon: oldPayload.lon,\n hae: parseFloat(oldPayload.alt) + parseFloat(oldPayload.geoidalSep),\n ce: oldPayload.horDilution,\n le: 0\n }\n } ],\n detail: [ {\n precisionlocation: [ {\n $: {\n geopointsrc: \"GPS\",\n altitudesrc: \"GPS\"\n }\n } ],\n remarks: [\"External GPS\"],\n extendedGpsDetails: [ {\n $: {\n fixQuality: 1,\n numSatellites: oldPayload.numSat,\n time: oldPayload.timestamp\n }\n } ]\n } ]\n }\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":520,"wires":[["3f051c62.f68744"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment