[
{
"id": "b0592bb97cfa085a",
"type": "tab",
"label": "流程 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "819a6dc5.6771e",
"type": "inject",
"z": "b0592bb97cfa085a",
"name": "",
"props": [
{
"p": "payload",
"v": "",
"vt": "str"
},
{
"p": "topic",
"v": "",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "",
"payload": "",
"payloadType": "str",
"x": 430,
"y": 400,
"wires": [
[
"153983e4.bce93c"
]
]
},
{
"id": "153983e4.bce93c",
"type": "function",
"z": "b0592bb97cfa085a",
"name": "create test buffer",
"func": "// @ts-ignore\nmsg.payload = new Buffer.from([238,177,17,0,0,4,4,16,1,0,255,252,255,255]);\n//msg.payload = new Buffer.from([04,04,04,02]);\nreturn msg;\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 610,
"y": 400,
"wires": [
[
"939c9b2c819b21a3",
"ebb6cf4e89cf1c60"
]
]
},
{
"id": "2e685d10.e739a2",
"type": "comment",
"z": "b0592bb97cfa085a",
"name": "parse buffer to msg properties",
"info": "",
"x": 500,
"y": 360,
"wires": []
},
{
"id": "939c9b2c819b21a3",
"type": "binary",
"z": "b0592bb97cfa085a",
"name": "转码",
"property": "payload",
"pattern": "b8 => zt,\nb16 => commid,\nb16 => screenid,\nb16 => contid,\nb8 => cont,\nb8 => boole,\nb8 => status,\nl32=> zw1\n",
"x": 810,
"y": 400,
"wires": [
[
"1265f83d7f7e3554",
"c13392e49e5fbaf6"
]
]
},
{
"id": "fb2f1e45bf3fe89c",
"type": "debug",
"z": "b0592bb97cfa085a",
"name": "debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1130,
"y": 400,
"wires": []
},
{
"id": "1265f83d7f7e3554",
"type": "function",
"z": "b0592bb97cfa085a",
"name": "分割字符",
"func": "var screenID = msg.payload.screenid\nvar controlID = msg.payload.contid\nvar status = msg.payload.status\n\nmsg.payload=screenID.toString()+controlID.toString()+status.toString();\nreturn msg;\n\n// msg.payload = \n// {\n// //upcommd: upcommd,\n// str: str,\n// screenID: screenID,\n// controlID: controlID,\n// status: status\n// };\n //return msg\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 980,
"y": 400,
"wires": [
[
"fb2f1e45bf3fe89c"
]
]
},
{
"id": "31664a503303edb7",
"type": "debug",
"z": "b0592bb97cfa085a",
"name": "resowed",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 960,
"y": 620,
"wires": []
},
{
"id": "ebb6cf4e89cf1c60",
"type": "function",
"z": "b0592bb97cfa085a",
"name": "UDP解析",
"func": "var header = (msg.payload[0]);\nvar upcommd = msg.payload.slice(1,3);\nvar screenID = parseInt(msg.payload.slice(3,4),16);\nvar controlIDbuff = msg.payload.slice(5, 7);\nvar status = msg.payload.slice(9, 10);\n\nvar controlID = parseInt(controlIDbuff)\n//var battery = parseInt((msg.payload[48] + msg.payload[49]), 16);\n//var heartrate = parseInt((msg.payload[54] + msg.payload[55]), 16);\n//var temperature = (parseInt(msg.payload.slice(62,63), 16)) * 0.1 + 20;\n//msg.payload = screenID\n//return msg\nif (header == "238") \n{\n msg.payload = \n {\n //upcommd: upcommd,\n screenID: screenID,\n controlID: controlID,\n status: status\n };\n return msg\n}\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 800,
"y": 620,
"wires": [
[
"31664a503303edb7"
]
]
},
{
"id": "c13392e49e5fbaf6",
"type": "debug",
"z": "b0592bb97cfa085a",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1190,
"y": 560,
"wires": []
}
]
复制代码