This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AF_DataReq Ack

How can i check the data is reached to Destination?. If i am sending data with AF_ACK_REQUEST Option, it will send ack in AF_DATA_CONFIRM_CMD, then how can i wait till ack received.

AF_DataReq();

Wait till data Ack;

check Status in AF_DATA_CONFIRM_CMD.


How to wait?

  • Hi,

    You could use a while loop to wait while you dont receive the ack. 
    The code should look something like the following.

    while(data Ack is not received )
    {
    // loop untill you receive the ack
    }
    //Check status in AF_DATA_CONFIRM_CMD
    
    

  • Is there any chances  that, i will not get ack?. If there, then my app will hang there, right?

  • Yes, there is a chance that you wont receive the Ack, in that case you will have to have a timeout variable which will exit the while loop after a specified number of iterations. For example, you could do something like in the following code.

    int timeout = 500;
    while(data Ack is not received && timeout-- > 0)
    {
    // loop untill you receive the ack
    }
    
    //Check status in AF_DATA_CONFIRM_CMD

  • Yes. If the destination is not there, you won't receive ACK. in this case, Hector's suggestion will have a deadlock. I would suggest you keep a structure that contains sequence number in AF_DataReq and a Boolean dataack to false first. In AF_DATA_CONFIRM_CMD, you check the matched sequence number and label dataack to true. Also, you can have a event does periodic check on this data structure to see if there is any message that doesn't have ack. If so, you can resend it.