Communication protocol simplification possible? #30
Replies: 2 comments 17 replies
-
To start, I think we should review the message and how it is used. The message is a match for the message that Node-RED sends to Status Nodes when the status is changed. Here's a flow to explore that. [
{
"id": "2fec9e130ad0d45f",
"type": "tab",
"label": "delete me",
"disabled": false,
"info": "",
"env": []
},
{
"id": "5e3247acce2fd674",
"type": "status",
"z": "2fec9e130ad0d45f",
"name": "",
"scope": null,
"_mcu": false,
"x": 480,
"y": 220,
"wires": [
[
"16b7efbf68b385c1"
]
]
},
{
"id": "16b7efbf68b385c1",
"type": "debug",
"z": "2fec9e130ad0d45f",
"name": "debug 8",
"active": true,
"tosidebar": false,
"console": true,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"_mcu": false,
"x": 670,
"y": 220,
"wires": []
},
{
"id": "1790bba3c0262e5c",
"type": "inject",
"z": "2fec9e130ad0d45f",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"_mcu": false,
"x": 170,
"y": 360,
"wires": [
[
"9afeee4e3f8febbb"
]
]
},
{
"id": "9afeee4e3f8febbb",
"type": "function",
"z": "2fec9e130ad0d45f",
"name": "function 3",
"func": "node.status({fill:\"red\",shape:\"ring\",text:\"disconnected\"});",
"outputs": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"_mcu": false,
"x": 340,
"y": 360,
"wires": []
}
] In Node-RED, it outputs the following to the console:
Using Node-RED MCU it outputs the following to xsbug (I've reformatted it for readability). {
"status": {
"fill": "red",
"shape": "ring",
"text": "disconnected",
"source": {
"id": "9afeee4e3f8febbb",
"type": "function",
"name": "function 3"
}
},
"_msgid": "287b8cad8de8ef90"
} This same message object is also sent to xsbug to relay to the Node-RED Editor. Changing the message propagated to Status Nodes will break compatibility with Node-RED. The message sent to xsbug could be simplified by removing unnecessary fields - in addition to the source As an aside, you mention "adding a significant load without value". I'm curious if you are able to quantify the load impact? |
Beta Was this translation helpful? Give feedback.
-
Cool. Thanks. I will try to updated the MCU runtime for that this evening.
Exactly. The empty message from your plug-in is a signal to send the state to the editor.
This is additional complexity and a bit of memory for a relatively obscure situation. Let's hold onto this idea. If there's a clear need, it can be implemented then. |
Beta Was this translation helpful? Give feedback.
-
@phoddie --
Currently the status message consists of the status data (necessary for
node-red
) and an additional object that providessource
information. The (only?) relevant property of thesource
object is theid
of the emitting node, that is used by the plugin to build a status notification that is understood by the editor.node-red-mcu/nodered.js
Lines 296 to 306 in 7ddfd04
Thus
type
andname
are not used & can (as well) be derived from the providedid
by the node-red runtime. They yet need to be processed & transmitted with each status message - adding a significant load without value.I propose to change the protocol to just provide the node's
id
& omit eithertype
andname
. I'm fine with keeping the property named assource
, whereasid
would fit as well:This proposal is of course valid not only for
status
, but for all messagestrace
d back to thenode-red
runtime.Beta Was this translation helpful? Give feedback.
All reactions