Hi Mr Colin,
I using buffer to send cmd, via serial, to my exchange device and array to handling responses received and make a specific decision.
I have two parts in my code. I building a msg flow according msg received, detect a specific byte and than need to send another msg.
Right now is working well. Thanks a lot!!!!
I need to building a html page, with button inside, to catch in specific function to send msgs. Do you have an link to suggest me to start to study it?
I changed my code as you advise me. As you can see bellow:
//variables
var i;
// tratamento das respostas aos comandos do gateway
for (i = 0; i < msg.payload.length; i++) {
// handling parameters and send a response mesage
switch (msg.payload[i]){
//Analyze GetVersion msg and sending the Cmd_SetCh11
case 149:{
//Send Cmd_SetCh11
newMsg = {payload: new Buffer([0x01,0x02,0x10,0x21,0x02,0x10,0x02,0x14,0x2D,0x02,0x10,0x02,0x10,0x02,0x18,0x02,0x10,0x03])}
node.send(newMsg);
}
break;
//Analyze Cmd_SetCh11 msg and sending the Cmd_SetDev-Coord
case 164:{
//Send Cmd_SetDev-Coord
newMsg = {payload: new Buffer([0x01,0x02,0x10,0x23,0x02,0x10,0x02,0x11,0x22,0x02,0x10,0x03])}
node.send(newMsg);
}
break;