-
Notifications
You must be signed in to change notification settings - Fork 0
/
Opus.json
1 lines (1 loc) · 7.78 KB
/
Opus.json
1
[{"id":"e1c07481.249ed8","type":"tab","label":"Opus Interface","disabled":false,"info":""},{"id":"34daa89f.7e48b8","type":"serial in","z":"e1c07481.249ed8","name":"","serial":"587a989.90cbf68","x":150,"y":80,"wires":[["616aa3d3.02896c","741ed342.d2352c"]]},{"id":"c7023270.3c7ff","type":"function","z":"e1c07481.249ed8","name":"Opus Receive Text","func":"var buf = Buffer.from(msg.payload);\n\nvar message = buf.slice(21,21 + parseInt(msg.payload[19]))\n\nmsg.SID = parseInt(msg.payload[9])\nmsg.DID = parseInt(msg.payload[13])\nmsg.message = message.toString()\n \nreturn msg;","outputs":1,"noerr":0,"x":590,"y":40,"wires":[["97e23cef.5987f"]],"icon":"node-red/envelope.png"},{"id":"f0069f2a.c192e","type":"inject","z":"e1c07481.249ed8","name":"","topic":"","payload":"102","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":300,"wires":[["4f1ddd3f.564cd4"]]},{"id":"fb883ac3.7ade88","type":"serial out","z":"e1c07481.249ed8","name":"","serial":"587a989.90cbf68","x":630,"y":300,"wires":[]},{"id":"8c96bc8d.083bf","type":"function","z":"e1c07481.249ed8","name":"Opus Send Text","func":"//Get Message Parameters\nvar message = msg.payload;\nvar destination = msg.topic;\n\n//Set buffer sizes\nvar dest = Buffer.alloc(4);\nvar source = Buffer.alloc(4);\nvar DataLength = Buffer.alloc(2);\nvar dLengthBuf = Buffer.alloc(2);\nvar dChecksumBuf = Buffer.alloc(2);\nvar ChecksumBuf = Buffer.alloc(2);\n\n//Set Constants\nvar p1 = Buffer.from([0xb1,0x0]);\nvar p2 = Buffer.from([0x44,0x53,0x01,0x01]);\nvar CallType = Buffer.from([0x01]); //0x00 for Private, 0x01 for Group\nvar NoEncrypt = Buffer.from([0x0]);\nvar EOM = Buffer.from([0xd,0xa]);\nvar sendEnd = Buffer.from([0xb4]);\n\n//Set Variables\nvar SourceID = source.writeInt16LE(0);\nvar DestinationID = dest.writeInt16LE(destination);\nvar Message = Buffer.from(message,\"utf16LE\");\nvar MessageLength = DataLength.writeInt16LE([Number(Message.length)]);\n\n//Set dLength\nvar dLengthCalc = Buffer.concat([source,dest,CallType,NoEncrypt,DataLength,Message]);\nvar dLength = dLengthBuf.writeInt16LE(dLengthCalc.length);\n\n//Set dChecksum\nvar dChecksumConcat = Buffer.concat([p2,dLengthBuf,source,dest,CallType,NoEncrypt,DataLength,Message]);\nvar dChecksumArray = dChecksumBuf.writeInt16LE(Array.prototype.slice.call(dChecksumConcat, 0).reduce((a, b) => a + b, 0));\n\n//Set CF2\nvar CF2 = Buffer.from([p2.length + dLengthBuf.length + source.length + dest.length + CallType.length + NoEncrypt.length + DataLength.length + Message.length + dChecksumBuf.length + EOM.length]);\n\n//Set Checksum\nvar ChecksumConcat = Buffer.concat([p1,CF2,p2,dLengthBuf,source,dest,CallType,NoEncrypt,DataLength,Message,dChecksumBuf,EOM]);\nvar ChecksumArray = ChecksumBuf.writeInt16LE(Array.prototype.slice.call(ChecksumConcat, 0).reduce((a, b) => a + b, 0));\n\n//Build Buffer\nvar array = [p1,CF2,p2,dLengthBuf,source,dest,CallType,NoEncrypt,DataLength,Message,dChecksumBuf,EOM,ChecksumBuf,sendEnd];\nvar buf = Buffer.concat(array);\n\n//Output Data\nmsg.payload = buf\n\nmsg.debug = DataLength\n\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":240,"wires":[["21c169ba.217d66"]],"icon":"font-awesome/fa-feed"},{"id":"be63d2c8.4c932","type":"inject","z":"e1c07481.249ed8","name":"","topic":"240","payload":"Hello World!","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":240,"wires":[["8c96bc8d.083bf"]]},{"id":"21c169ba.217d66","type":"serial out","z":"e1c07481.249ed8","name":"","serial":"587a989.90cbf68","x":630,"y":240,"wires":[]},{"id":"97e23cef.5987f","type":"template","z":"e1c07481.249ed8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{SID}} sent {{message}} to {{DID}}","output":"str","x":760,"y":40,"wires":[["87d74a5f.6f16d8"]]},{"id":"87d74a5f.6f16d8","type":"debug","z":"e1c07481.249ed8","name":"Processed Data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":980,"y":80,"wires":[]},{"id":"616aa3d3.02896c","type":"switch","z":"e1c07481.249ed8","name":"Detect Message Type","property":"payload[1]","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":360,"y":80,"wires":[["c7023270.3c7ff"],[],["fb72f3d5.4ebb3"]],"info":"0 = New Text Message\n1 = Repeated Text Message\n2 = New Location\n3 = Repeated Location\n4 = "},{"id":"4f1ddd3f.564cd4","type":"function","z":"e1c07481.249ed8","name":"Opus Request Location","func":"//Get Message Parameters\nvar destination = msg.payload;\n\n//Set buffer sizes\nvar dest = Buffer.alloc(4);\nvar dLengthBuf = Buffer.alloc(2);\nvar dChecksumBuf = Buffer.alloc(2);\nvar ChecksumBuf = Buffer.alloc(2);\n\n//Set Constants\nvar p1 = Buffer.from([0xb1,0x0]);\nvar p2 = Buffer.from([0x44,0x53,0x10,0x01]);\nvar EOM = Buffer.from([0xd,0xa]);\nvar sendEnd = Buffer.from([0xb4]);\n\n//Set Variables\nvar DestinationID = dest.writeInt16LE(destination);\n\n//Set dLength\nvar dLength = dLengthBuf.writeInt16LE(dest.length);\n\n//Set dChecksum\nvar dChecksumConcat = Buffer.concat([p2,dLengthBuf,dest]);\nvar dChecksumArray = dChecksumBuf.writeInt16LE(Array.prototype.slice.call(dChecksumConcat, 0).reduce((a, b) => a + b, 0));\n\n//Set CF2\nvar CF2 = Buffer.from([p2.length + dLengthBuf.length + dest.length + dChecksumBuf.length + EOM.length]);\n\n//Set Checksum\nvar ChecksumConcat = Buffer.concat([p1,CF2,p2,dLengthBuf,dest,dChecksumBuf,EOM]);\nvar ChecksumArray = ChecksumBuf.writeInt16LE(Array.prototype.slice.call(ChecksumConcat, 0).reduce((a, b) => a + b, 0));\n\n//Build Buffer\nvar array = [p1,CF2,p2,dLengthBuf,dest,dChecksumBuf,EOM,ChecksumBuf,sendEnd];\nvar buf = Buffer.concat(array);\n\n//Output Data\nmsg.payload = buf\n\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":300,"wires":[["fb883ac3.7ade88"]],"icon":"node-red/white-globe.png"},{"id":"fb72f3d5.4ebb3","type":"function","z":"e1c07481.249ed8","name":"Opus Location","func":"var buf = Buffer.from(msg.payload);\n\n//Time\nvar hh = parseInt(msg.payload[25]);\nvar mm = parseInt(msg.payload[26]);\nvar ss = parseInt(msg.payload[27]);\nmsg.time = hh + \":\" + mm + \":\" + ss\n\n//Date\nvar YY = parseInt(msg.payload[21]);\nvar MM = parseInt(msg.payload[22]);\nvar DD = parseInt(msg.payload[23]);\nmsg.date = DD + \"/\" + MM + \"/\" + YY\n\n//Lattitude\nvar LAD = parseInt(msg.payload[13]);\nvar LAM = parseInt(msg.payload[14]);\nvar LAS = parseInt(msg.payload[15]);\nvar LAMS = parseInt(msg.payload[16]);\nmsg.lat = LAD + \"°\" + LAM + \"'\" + LAS + \".\" + LAMS + \"N\" // Cardinal needs to be changed automatically\n\n//Longitude\nvar LOD = parseInt(msg.payload[17]);\nvar LOM = parseInt(msg.payload[18]);\nvar LOS = parseInt(msg.payload[19]);\nvar LOMS = parseInt(msg.payload[20]);\nmsg.lon = LOD + \"°\" + LOM + \"'\" + LOS + \".\" + LOMS + \"E\" // Cardinal needs to be changed automatically\n\n\nvar message = buf.slice(21,21 + parseInt(msg.payload[19]))\n\nmsg.SID = parseInt(msg.payload[9])//Currently I cant see a sender described in the data\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":120,"wires":[["95599129.96da8"]],"icon":"font-awesome/fa-location-arrow"},{"id":"95599129.96da8","type":"template","z":"e1c07481.249ed8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Radio {{SID}} was at {{{lat}}} {{{lon}}} at {{{time}}} on {{{date}}}","output":"str","x":760,"y":120,"wires":[["87d74a5f.6f16d8"]]},{"id":"741ed342.d2352c","type":"debug","z":"e1c07481.249ed8","name":"Raw Data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":300,"y":20,"wires":[]},{"id":"587a989.90cbf68","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","newline":"500","bin":"bin","out":"time","addchar":false,"responsetimeout":"10000"}]