RC from send() and How to identify an Ack message


  • Hardware Contributor

    I have a very simple sketch, Controller sends a message every 500 ms to a sensor node. with the millis() as is it's payload.
    The sensor node just echos the payload back...

    void loop() 
    {
        int iRC;
        
        rf24.process();
        if ((millis() - lastrun) > 500)
        {
            Serial.println("---------------------------------------------------");
            iRC = rf24.send(myMsgPingReply.set(millis()), RF24_RECEIVE_ACK_FALSE);
            Serial.print("rf24.send() RC=");
            Serial.println(iRC);
            lastrun = millis();
        }
    }```
    
    
    Here is a question to what is in the serial output..
    
    Q1:  The first send():  Why is the RC = 0  when the remote node got the message and replied.    
    ---
    Am I understanding the RC of the send() incorrectly?  1 = Successful, 0 = failed?
    Especially since the "st=fail" in the debug corresponds to the RC from the send() 
    
    

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=fail:27546
    rf24.send() RC=0
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:27546

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=ok:28072
    rf24.send() RC=1
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:28072

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=ok:28582
    rf24.send() RC=1
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:28582

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=fail:29092
    rf24.send() RC=0
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:29092

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=ok:29618
    rf24.send() RC=1
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:29618

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=ok:30127
    rf24.send() RC=1
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:30127

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=fail:30637
    rf24.send() RC=0

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=fail:31162
    rf24.send() RC=0
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:31162

    
    
    
    Q2:  Set the ACK flag to TRUE:  How do I know from the serial output which is the Ack Message?
    ----
    My sketch sends the first send: 0-0-200-0 ....
    I'm done after displaying the RC
    The first read: 0-200-0 ... must be the Echo back from the sensor node
    the second send 0-0-200-0  must be the Ack to the Sensor node
    the second read 0-200-0 must be the Ack from the Sensor node to the initial Send?
    
    Send Msg -->
    <--  Echo of the Msg
    Ack of the Echo -->
    <--  Ack to the Msg"
    Is this correct?  
    
    
    * Only way I could assume the above is  because there is only one message involved.  In a more complicated case when trying to debug how would someone know what is a message I sent and one automatically sent by the Library?  What is an Ack message?
    
    * st=ok and st=fail still concerns me that is does not make sense.  :-(
    
    

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=fail:327302
    rf24.send() RC=0
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:327302
    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=ok:327302

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=ok:327827
    rf24.send() RC=1
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:327827
    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=ok:327827
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:327827

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=fail:328336
    rf24.send() RC=0
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:328336
    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=fail:328336
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:328336

    
    ---

  • Admin

    The serial debug messages does not print the ack flags. You'll have to add it yourself.


  • Hardware Contributor

    I guess then it's a feature request..

    1. Add Ack Flag
    2. Add indicator when the library sends the message vs. the sketch.

    Any idea why the status is returning fail (st=fail) when it looks like the message send was actually successful?

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=fail:328336
    rf24.send() RC=0
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:328336
    


  • hi, go to my last project... I use ACK .. look to my code..
    may be help..

    regards


  • Hardware Contributor

    @dzairo thanks.

    I'm not asking how to use the Ack flag.

    I'm asking how to recognize the Ack messages from the debug messages.
    This is the debug with Ack enabled. can you tell me which one is the Ack message?

    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=fail:328336
    rf24.send() RC=0
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:328336
    send: 0-0-200-0 s=0,c=1,t=0,pt=5,l=4,st=fail:328336
    read: 0-200-0 s=0,c=1,t=0,pt=5,l=4:328336
    

    Second, why is the send status = fail but seems like the message actually was successful in being received by the receiver (as I received a reply to the message sent).


  • Admin

    Second, why is the send status = fail but seems like the message actually was successful in being received by the receiver (as I received a reply to the message sent).

    The receiver can very well receive a message but does not succeed in sending (hardware) ack back to sender. This will result in "st=failed" on sending side.

    You can do a simple msg.isAck() in the message callback to check if it is a ack message.


  • Hardware Contributor

    @hek thanks for the clarification...

    OK, that's interesting...

    So you are utilizing the Hardware Ack mechanisms - RC represents the hardware successfully received HW Ack to the message.

    • Understand the st=fail now. The hardware Ack was not received.
    • Even if the Ack was received, No guarantee that the sketch got the message

    The Software Ack is then handles the full path - validates that the message made it all the way up to the clients' sketch.

    • The HW may have successfully received the message but for some reason did not make it to the sketch to be processed
    • or the sketch failed to process the message.

    Now, only if we can "fix" the debug output to identify which are Acks

    • I know I can use the isAck() in the sketches......
    • This was just in the debug messages so when we look at the output, it's clear that its an Ack message.
    • That's what debug mode is for, so we can simply trace the messages


  • @hek said:

    You can do a simple msg.isAck() in the message callback to check if it is a ack message.

    How the received acks can be matched with the sent messages?


Log in to reply
 

Suggested Topics

70
Online

11.4k
Users

11.1k
Topics

112.7k
Posts