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.

Uh oh!
There was an error while loading. Please reload this page.
-
@phoddie --
Currently the status message consists of the status data (necessary for
node-red) and an additional object that providessourceinformation. The (only?) relevant property of thesourceobject is theidof 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
typeandnameare not used & can (as well) be derived from the providedidby 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 eithertypeandname. I'm fine with keeping the property named assource, whereasidwould fit as well:This proposal is of course valid not only for
status, but for all messagestraced back to thenode-redruntime.Beta Was this translation helpful? Give feedback.
All reactions