@cabat, @rozpruwacz is right: I don't use the noACK function.
But I do use send(msg) function with an echo parameter set to true, which forces the gateway to send echo back to node.
How it works:
- When the node starts sending message, the variable isSent is set to false.
- The node's send(msg) function runs in a loop for up to 5 repetitions unless the isSent variable changes to true. The function repeats sending message every 1 second.
- The receive() function on the node reads the messages from the gateway. If it is is.Echo() it sets the isSent variable to true. This interrupts the loop with send(msg) function.
Important ! you need to wait about 0,5 s after sending message to get echo back from gateway.
bool isSent;
void loop() {
// your other code in loop() function
isSent = false;
while ( ! isSent && i < 5 ) {
send( message.set( value ), true );
wait( 500 );
if ( ! isSent ) {
wait( 1000 );
}
i++;
}
// your other code in loop() function
}
void receive( const MyMessage& message ) {
if ( message.isEcho() ) isSent = true;
else doSomething;
}