diff --git a/src/nrf_to_nrf.cpp b/src/nrf_to_nrf.cpp index f1b1988..d8da709 100644 --- a/src/nrf_to_nrf.cpp +++ b/src/nrf_to_nrf.cpp @@ -56,6 +56,7 @@ nrf_to_nrf::nrf_to_nrf() ARC = 0; addressWidth = 5; ackTimeout = ACK_TIMEOUT_1MBPS; + payloadAvailable = false; #if defined CCM_ENCRYPTION_ENABLED NRF_CCM->INPTR = (uint32_t)inBuffer; @@ -163,7 +164,11 @@ bool nrf_to_nrf::available() bool nrf_to_nrf::available(uint8_t* pipe_num) { - + + if(payloadAvailable){ + return true; + } + if (!inRxMode) { if (ackPayloadAvailable) { *pipe_num = ackAvailablePipeNo; @@ -293,6 +298,7 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) #endif lastPacketCounter = packetCtr; lastData = packetData; + payloadAvailable = true; return 1; } if (NRF_RADIO->EVENTS_CRCERROR) { @@ -312,6 +318,7 @@ void nrf_to_nrf::read(void* buf, uint8_t len) if (inRxMode) { NRF_RADIO->TASKS_START = 1; } + payloadAvailable = false; } /**********************************************************************************************************/ @@ -1339,4 +1346,4 @@ void nrf_to_nrf::setIV(uint8_t IV[CCM_IV_SIZE]){ } -#endif // defined CCM_ENCRYPTION_ENABLED \ No newline at end of file +#endif // defined CCM_ENCRYPTION_ENABLED diff --git a/src/nrf_to_nrf.h b/src/nrf_to_nrf.h index d9104da..d1ad6f4 100644 --- a/src/nrf_to_nrf.h +++ b/src/nrf_to_nrf.h @@ -485,6 +485,7 @@ class nrf_to_nrf uint8_t ARC; uint8_t addressWidth; uint16_t ackTimeout; + bool payloadAvailable; #if defined CCM_ENCRYPTION_ENABLED uint8_t inBuffer[MAX_PACKET_SIZE + CCM_MIC_SIZE + CCM_START_SIZE]; uint8_t scratchPTR[MAX_PACKET_SIZE + CCM_MODE_LENGTH_EXTENDED];