... this approach seems that work !
#define ACKDELAY 40 //seems 40 millis is a good value
bool nodeACK = false;
void SendData(byte sensor, byte destination, bool value, bool ack) {
msg.setSensor(sensor);
msg.setDestination(destination);
for(byte i=0; i<=ATTEMPTS; i++){
if(send(msg.set(value),ack)){
Serial.println("Gateway ACK");
// wait(ACKDELAY);
if(nodeACK == true){
Serial.println("Node ACK");
nodeACK = false;
break;}else{
Serial.println("Node NACK");
}
}else{
Serial.println("Gateway NACK");
}
wait(ACKDELAY);
}
}
... in combination with this
void receive(const MyMessage &message) {
if (message.isAck()){
nodeACK=true;
digitalWrite(LED_PINS[message.sensor], message.getBool()? LED_ON:LED_OFF);
Serial.println(F("ACK recieved LED Status Changed"));
}
... but probably is not the most elegand way!
... because if during the send/ack back message duty cycle, an ack from an other sensor received, a conflict may occure! i do not feel safe!
(i also have a feeling that i did that post in the wrong topic! )