Hi,
I'm try to fix problems at the famous (built-in) Arduino module of Node-RED.
Here is my progress so far:
But I'm stuck because I've faced how many problems is there with the current code structure, so the only way to fix every problem is to refactor it completely.
My question is:
What is the recommended way to develop a node module, where:
- There is a "main" (Firmata board) node, which is hidden
- The
in + out
nodes are basically visualisation of the main module's capabilities. - If the main node state is changing, it is affecting all the "sub-nodes". Like :
- it is (re-)connecting,
- has wrong com port setup, or none
- disconnected
- can not open com port (because is was not closed and now it is occupied!!!)
- working fine
- ... partial re-deployed? ... will discuss the problem here ...
Should I :
-
Add an array to the main node, where I keep track of all sub-nodes?
- Adding them, when they register.
- But what if one gets deleted, and the flow gets partial deployed?
-
Keep the current code's plan, how it is?
(recursive time-loop of the sub-nodes every 5 secs to reflect changes) -
Any other ideas?
// state types of the Firmata Board:
const BdStates = Object.freeze({ // (freeze = immutable record)
permanentError: -3, // no COM-port specified
disconnected : -2,
tryReconnect : -1,
start : 0,
gettingVersion: 1,
OK : 2
});