Need help to understand basic communication API: send, receive, ACK
-
Looks like I have a problem to understand how sending exactly works? I read the docs, examples, I created sketches for 4 nodes but I'm still not sure wether I use the function send correctly.
The function returns boolean which according to documentation:
Returns true if message reached the first stop on its way to destination.
My doubts here:- If I send without ACK, how does a node "knows" that the "message reached the first stop on its way" ? How to interpret the returned boolean in such case? If I get false should I repeat sending?
- If I want to use ACK, does the send function call blocks execution until ACK is received then it returns true? Do I need to implement receive function and handle ACK by myself?
-
@michał-kozak ack is a complex topic. See https://forum.mysensors.org/post/34267 for an earlier discussion on the same topic.
To answer your questions:
- The next-hop node will acknowledge the message. The returned boolean shows if the sending node received an acknowledgement from the next hop node. If you get false, it could be because the next hop didn't receive the message, or because the sending node didn't receive the acknowledgement. What you should do depends on what you want to happen.
- No, the send function will not block. Yes you need to handle the echoed message in receive().
-
@mfalkvidd that's helped me a lot to better understand what is happening during send! Thanks!