diff --git a/node-red scripts/nodered_Meshtastic_flow.txt b/node-red scripts/nodered_Meshtastic_flow.txt new file mode 100644 index 0000000..5a03312 --- /dev/null +++ b/node-red scripts/nodered_Meshtastic_flow.txt @@ -0,0 +1,282 @@ +[ + { + "id": "2e8554c4cacf5240", + "type": "tcp in", + "z": "ec4547d237679549", + "name": "ShortFast", + "server": "client", + "host": "192.168.100.113", + "port": "20000", + "datamode": "stream", + "datatype": "buffer", + "newline": "", + "topic": "ShortFast", + "trim": false, + "base64": false, + "tls": "", + "x": 80, + "y": 40, + "wires": [ + [ + "31a2e27ea5b2e77b" + ] + ] + }, + { + "id": "31a2e27ea5b2e77b", + "type": "function", + "z": "ec4547d237679549", + "name": "Buffer2Hex", + "func": "msg.payload = msg.payload.toString('hex');\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 510, + "y": 220, + "wires": [ + [ + "cd015e39b23c58c7" + ] + ] + }, + { + "id": "cd015e39b23c58c7", + "type": "function", + "z": "ec4547d237679549", + "name": "Hex2MeshHeader", + "func": "// From https://meshtastic.org/docs/overview/mesh-algo/\n// This is in MSB/big endian order. \n\nvar destination = msg.payload.substring(0, 8); // 4 bytes \nvar sender = msg.payload.substring(8, 16); // 4 bytes\nvar packetID = msg.payload.substring(16, 24); // 4 bytes\nvar flags = msg.payload.substring(24, 26); // 1 byte\nvar channelHash = msg.payload.substring(26, 28); // 1 byte\nvar reserved = msg.payload.substring(28, 32); // 2 bytes\nvar data = msg.payload.substring(32, msg.payload.length); // the rest\n\nmsg.meshtastic = [destination, sender, packetID, flags, channelHash, reserved, data];\n\nreturn msg;", + "outputs": 1, + "timeout": "", + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 690, + "y": 220, + "wires": [ + [ + "61306710ab42e6d8" + ] + ] + }, + { + "id": "61306710ab42e6d8", + "type": "function", + "z": "ec4547d237679549", + "name": "MSBtoLSB", + "func": "var changeEndianness = (msb) => {\n var lsb = \"\";\n for (var i = msb.length; i > 0; i = i - 2) {\n lsb = lsb + msb.substring((i - 2), i)\n }\n return lsb;\n}\n\nmsg.meshtastic[0] = changeEndianness(msg.meshtastic[0]);\nmsg.meshtastic[1] = changeEndianness(msg.meshtastic[1]);\nmsg.meshtastic[2] = changeEndianness(msg.meshtastic[2]);\nmsg.meshtastic[3] = changeEndianness(msg.meshtastic[3]);\nmsg.meshtastic[4] = changeEndianness(msg.meshtastic[4]);\nmsg.meshtastic[5] = changeEndianness(msg.meshtastic[5]);\nmsg.meshtastic[6] = changeEndianness(msg.meshtastic[6]);\n\nreturn msg;", + "outputs": 1, + "timeout": "", + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 870, + "y": 220, + "wires": [ + [ + "d91efbc96f023aee" + ] + ] + }, + { + "id": "d91efbc96f023aee", + "type": "function", + "z": "ec4547d237679549", + "name": "recombinePayload", + "func": "msg.payload = msg.meshtastic[0] + msg.meshtastic[1] + msg.meshtastic[2] + msg.meshtastic[3] + msg.meshtastic[4] + msg.meshtastic[5] + msg.meshtastic[6];\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1050, + "y": 220, + "wires": [ + [ + "b7d858594cd04b91" + ] + ] + }, + { + "id": "b7d858594cd04b91", + "type": "debug", + "z": "ec4547d237679549", + "name": "correctByteOrder", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 1250, + "y": 220, + "wires": [] + }, + { + "id": "afc8ec524838f5f1", + "type": "tcp in", + "z": "ec4547d237679549", + "name": "ShortSlow", + "server": "client", + "host": "192.168.100.113", + "port": "20001", + "datamode": "stream", + "datatype": "buffer", + "newline": "", + "topic": "ShortSlow", + "trim": false, + "base64": false, + "tls": "", + "x": 80, + "y": 100, + "wires": [ + [ + "31a2e27ea5b2e77b" + ] + ] + }, + { + "id": "54e752f80b657416", + "type": "tcp in", + "z": "ec4547d237679549", + "name": "MediumFast", + "server": "client", + "host": "192.168.100.113", + "port": "20002", + "datamode": "stream", + "datatype": "buffer", + "newline": "", + "topic": "MediumFast", + "trim": false, + "base64": false, + "tls": "", + "x": 90, + "y": 160, + "wires": [ + [ + "31a2e27ea5b2e77b" + ] + ] + }, + { + "id": "c3cf8213b9816e28", + "type": "tcp in", + "z": "ec4547d237679549", + "name": "MediumSlow", + "server": "client", + "host": "192.168.100.113", + "port": "20003", + "datamode": "stream", + "datatype": "buffer", + "newline": "", + "topic": "MediumSlow", + "trim": false, + "base64": false, + "tls": "", + "x": 90, + "y": 220, + "wires": [ + [ + "31a2e27ea5b2e77b" + ] + ] + }, + { + "id": "9041db64281742aa", + "type": "tcp in", + "z": "ec4547d237679549", + "name": "LongFast", + "server": "client", + "host": "192.168.100.113", + "port": "20004", + "datamode": "stream", + "datatype": "buffer", + "newline": "", + "topic": "LongFast", + "trim": false, + "base64": false, + "tls": "", + "x": 80, + "y": 280, + "wires": [ + [ + "31a2e27ea5b2e77b" + ] + ] + }, + { + "id": "6b5657786491171d", + "type": "tcp in", + "z": "ec4547d237679549", + "name": "LongModerate", + "server": "client", + "host": "192.168.100.113", + "port": "20005", + "datamode": "stream", + "datatype": "buffer", + "newline": "", + "topic": "LongModerate", + "trim": false, + "base64": false, + "tls": "", + "x": 90, + "y": 340, + "wires": [ + [ + "31a2e27ea5b2e77b" + ] + ] + }, + { + "id": "76777577f97247d3", + "type": "tcp in", + "z": "ec4547d237679549", + "name": "LongSlow", + "server": "client", + "host": "192.168.100.113", + "port": "20006", + "datamode": "stream", + "datatype": "buffer", + "newline": "", + "topic": "LongSlow", + "trim": false, + "base64": false, + "tls": "", + "x": 80, + "y": 400, + "wires": [ + [ + "31a2e27ea5b2e77b" + ] + ] + }, + { + "id": "b04c3fbb14e0d023", + "type": "tcp in", + "z": "ec4547d237679549", + "name": "VeryLongSlow", + "server": "client", + "host": "192.168.100.113", + "port": "20007", + "datamode": "stream", + "datatype": "buffer", + "newline": "", + "topic": "VeryLongSlow", + "trim": false, + "base64": false, + "tls": "", + "x": 90, + "y": 460, + "wires": [ + [ + "31a2e27ea5b2e77b" + ] + ] + } +] \ No newline at end of file