I am using nrf24l01+ to send data from one arduino to another, each one with a nrf24l01+ module. Using the method "write" I can check if the message was succesfully sent to the other arduino cuse it returns a boolean.
However I am using writeAckPayload cause I need one arduino to send some data and the other should immediatly reply with another data. The docs say it is much better using writeAckPayload instead of write (on the reply side) cause I dont need to change the mode of the module (writing/listening). But as far as I know, writeAckPayload does not provide a boolean that could tell me if the response of the second arduino arrived to the first.
I want this: 1st arduino sends AAA to 2nd arduino -> 2nd arduino sends BBB to 1st arduino -> both arduino can check if the 2 messages were sent/received succesfully.
I could use the write method in the 1st and 2nd arduino but as I said, the method writeAckPayload is better suitable for this but I see not way to check if the 2nd response was indeed received by the 1st. I am using this docs RF24: RF24 Class Reference
@PaulS you misunderstood me. First I make module start the communication with "write" method. After that the second module receive the data and can reply the ACK providing also custom data using the method "writeAckPayload" . If I didnt do that I would have to make a "write" in the first module, receive the data and make another "write" to send data back.
It's not me who is saying this method is WAY BETTER, everybody says that cause you DONT need to manually change the mode of the chip (stoplistening starlistening) to send the reply back if you use the ACK to send the data back. You also have the benefit to only send the information once cause you only need one single "write" call and one single ACK payload.
Yes Robin2 I used what you say but my trouble is that: I need to make sure the ACK was received. I can check if "write" was succesfull but as far as I know it's not possible to check if ACK was indeed received by the arduino that sent the information?
I can't see anything in the nRF24L01+ datasheet that tells the "receiver" that it has successfully sent the ACK message. Whereas, if the "sender" is expecting an ACK it will not show a successful write until it receives the ACK. In the sense that the purpose of the ACK is to keep the "sender" happy this is probably understandable.
If my reading of the datasheet is correct then I think you have two choices
Don't use ackPayload to send data from the "receiver" to the "sender" - just get both devices to switch roles.
Or, get the "sender" to send another message to the "receiver" with a repeat of the data from the ACK.
batata004:
I can check if "write" was succesfull but as far as I know it's not possible to check if ACK was indeed received by the arduino that sent the information?
If write returns success on a standard send to an acknowledging address, it received the acknowledge and so any attached acknowledge payload.
If you only have one address that uses acknowledge payloads, you can check for an empty tx fifo in the acknowledging station.
You have to reload the payload after a reception on the acknowledging pipe anyway, so this code could be expanded a little.
Whandall:
If you only have one address that uses acknowledge payloads, you can check for an empty tx fifo in the acknowledging station.
Because of role-reversals the language can get a bit confusing here.
Does this mean that if A sends to B and B sends an ackPayload that B can test its tx fifo to see if the ackPayload was sent correctly? I could not see anything in the datasheet about that.
@Robin2 yes you are right. I think I understand what you said, so the best way is to avoid using ACK payload and switch roles to send the information back. There is indeed no way to check if the ACK was received, according to the documentation.