ESB ACK message is not sent immediately

Hello,

Scenario:

2x nRF52833 - One set as PTX and the second PRX. PTX is connected to my PC via UART. Both boards are initialized with ESB_PROTOCOL_ESB_DPL.

I want to send a data packet to PTX via UART, PTX will transmit this packet to PRX, PRX will reply ACK + payload (mirror the received data) and PTX will write the received data back to the PC via UART.

Problem: 

PC to PTX via UART works fine;

PTX to PRX via ESB works fine;

PRX to PTX (ACK + Payload) seems that PRX is buffering the packet in the FIFO (by 1) or PTX is not getting the ACK receive event on first try.
Let's say PTX send data packet "A", PRX receives packet "A" and send back ACK + "A", PTX doesn't get it.
Then PTX sends data packet "B", PRX receives  packet "B" and send back ACK + "B", PTX gets ACK + "A" (?!).

Extra:

Data is being received in PRX (checked).

Question:

My guess is that either the PRX is buffering the ACK (which doesn't make much sense, since PTX would get an ACK timeout) or the PTX "event_handler" is not being triggered.
Is there a way to make sure I'm flushing the data in the PRX side?

I'm using selective_auto_ack = false for the ACK + Payload purpose.

Here is my code:

PTX

                esb_flush_tx();
                tx_payload.length = cDebugPayload + serial_recv_offset; // always maximum bytes for measurements
                tx_payload.pipe = 1;
                serial_recv_offset = 0;
                (void)esb_write_payload(&tx_payload);

PRX

            memcpy(&tx_payload.data[0], &rx_payload.data[0], rx_payload.length);
            tx_payload.length = rx_payload.length;
            tx_payload.pipe = rx_payload.pipe;
            esb_write_payload(&tx_payload);
  • I'm reading the documentation here: 194.19.86.155/.../esb.html

    int esb_write_payload(conststructesb_payload *payload)
    Write a payload for transmission or acknowledgement.
    This function writes a payload that is added to the queue. When the module is in PTX mode, the payload is queued for a regular transmission. When the module is in PRX mode, the payload is queued for when a packet is received that requires an acknowledgement with payload.

    And it seems like that what I'm probably doing is preparing the next ACK message in the PRX receive event.

Related