Well, it seems nobody has either the motivation or the answer itself... Wonder if I should have posted this question in the Development forum instead...
I've been researching and doing some trial and error since I posted the question, and it seems I found a way of doing it. Not sure if this is the correct way because I just did not find any documentation about it, but I'll share my discoveries anyway since it can help others.
It seems the ack part is done automatically by the library itself. I've been able to see ack messages returning from the gateway to the controller without doing any treatment myself in my sketch.
Regarding how to differentiate "req" messages sent from the controller to a node, I've been able to detect if a message is a "req" one by reading the value of mGetCommand(message) in my sketch. If this is equal to 2, then it is a "req" message, if it is equal to 1, then it is a "set" message.
void incomingMessage(const MyMessage &message) {
//debug only
//Serial.print("message.destination=");
//Serial.println(message.destination);
//Serial.print("message.type=");
//Serial.println(message.type);
//Serial.print("message.sensor");
//Serial.println(message.sensor);
int comando = mGetCommand(message);
//Serial.print("comando=");
//Serial.println(comando);
if (message.type==V_LIGHT) {
//comando=2 means information has been requested from controller, so we will send it back.
//comando=1 means a new status has been received from controller to the node, so we will act as requested.
if (comando==2){
gw.send(lightMsg.set(digitalRead(lightPin)));
}
if (comando==1){
// Change relay state
setLightState(message.getBool(), false);
// Write some debug info
Serial.print("Incoming light status:");
Serial.println(message.getBool());
}
}
if (message.type==V_VAR1) {
// Toggle program mode
if (programModeActive == false){ // If we're not in programming mode, turn it on.
programmingmode(1);
} else { // If we are in programing mode, turn it off.
programmingmode(0);
}
// Write some debug info
Serial.print("Toggled program mode:");
Serial.println(message.getBool());
}
}
And below are the tests that show what I mentioned.
Sent this, which sets the light child 99 on node 51 to 1 (on), requesting an ack
51;99;1;1;2;1
0;0;3;0;14;Gateway startup complete.
0;0;3;0;9;send: 0-0-51-51 s=99,c=1,t=2,pt=0,l=1,st=ok:1
0;0;3;0;9;read: 51-51-0 s=99,c=1,t=2,pt=0,l=1:1
51;99;1;1;2;1
The last one is the ack itself that returned from the gateway to the controller.
Then sent this, which requests the status of light child 99 on node 51, requesting an ack. Should return the ack and the response containing the current status of the light (1).
51;99;2;1;2;anything
0;0;3;0;9;send: 0-0-51-51 s=99,c=2,t=2,pt=0,l=8,st=ok:anything
0;0;3;0;9;read: 51-51-0 s=99,c=2,t=2,pt=0,l=8:anything
51;99;2;1;2;anything
0;0;3;0;9;read: 51-51-0 s=99,c=1,t=2,pt=2,l=2:1
51;99;1;0;2;1
This "51;99;2;1;2;anything" is the ack generated automatically by the library, and this "51;99;1;0;2;1" is the response that my program performs. Correct!
Then sent this, which sets the light child 99 on node 51 to 0 (off), requesting an ack
51;99;1;1;2;0
0;0;3;0;9;send: 0-0-51-51 s=99,c=1,t=2,pt=0,l=1,st=ok:0
0;0;3;0;9;read: 51-51-0 s=99,c=1,t=2,pt=0,l=1:0
51;99;1;1;2;0
The last one above is the ack generated automatically by the library.
Then sent this, which requests the status of light child 99 on node 51, requesting an ack. Should return the ack and the response containing the current status of the light (0).
51;99;2;1;2;anything
0;0;3;0;9;send: 0-0-51-51 s=99,c=2,t=2,pt=0,l=8,st=ok:anything
0;0;3;0;9;read: 51-51-0 s=99,c=2,t=2,pt=0,l=8:anything
51;99;2;1;2;anything
0;0;3;0;9;read: 51-51-0 s=99,c=1,t=2,pt=2,l=2:0
51;99;1;0;2;0
This "51;99;2;1;2;anything" is the ack generated automatically by the library, and this "51;99;1;0;2;0" is the response that my program performs. Correct!