Changing Node ID at run time
-
Is it possible to change the node ID at run time in Setup???
ie: MY_NODE_ID
The way it looks now, it needs to be set prior to Setup or Loop being invoked using a:
#define MY_NODE_ID 10
I'm using an MQTT GW and would like each device to get its ID from a jumper on the board...
Thanks
-
Yes, it should be possible with something like this...
int8_t myNodeId; #define MY_NODE_ID myNodeId void before () { // read pins and set myNodeId }
-
Good idea, but it did not worked...
The node was at 10, so I set the myNodeId = 12 in before() function, node continued to use ID of 10, most likely from Flash.... before() might be running prior to initialization of all variables...
-
-
I have this working now, it was a setup issue on my part...
#define MY_NODE_ID myNodeId
int8_t myNodeId; #define MY_NODE_ID myNodeId void before () { // read I/O pins and set myNodeId myNodeId = 32; Serial.println( myNodeId ); }