From d42d32e3f1ca77dd393b697e4d300e6610afffcd Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Wed, 20 Dec 2023 18:05:23 -0600 Subject: [PATCH] Fix for available() function - Need to re-enable to radio to receive IF returning 0 IF various conditions are met while CRC is good, or else the radio will appear to hang and not receive anything --- library.json | 2 +- library.properties | 2 +- src/nrf_to_nrf.cpp | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/library.json b/library.json index 2317f9d..b8c66c7 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/TMRh20/nrf_to_nrf" }, - "version": "1.2.8", + "version": "1.2.9", "export": { "exclude": [ ".github/*" diff --git a/library.properties b/library.properties index c90ddf6..2be5f0a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=nrf_to_nrf -version=1.2.8 +version=1.2.9 author=TMRh20 maintainer=TMRh20 sentence=NRF52840 to NRF24L01+ ESB communication diff --git a/src/nrf_to_nrf.cpp b/src/nrf_to_nrf.cpp index c7f1cfb..0f32a49 100644 --- a/src/nrf_to_nrf.cpp +++ b/src/nrf_to_nrf.cpp @@ -181,6 +181,7 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) uint8_t tmpIV[CCM_IV_SIZE]; NRF_RADIO->EVENTS_CRCOK = 0; if (DPL && radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 4) { + NRF_RADIO->TASKS_START = 1; return 0; } *pipe_num = (uint8_t)NRF_RADIO->RXMATCH; @@ -277,12 +278,14 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) if (DPL) { if (!decrypt(&rxBuffer[1], rxBuffer[0] - CCM_IV_SIZE - CCM_COUNTER_SIZE)) { Serial.println("DECRYPT FAIL"); + NRF_RADIO->TASKS_START = 1; return 0; } } else { if (!decrypt(&rxBuffer[1], staticPayloadSize - CCM_IV_SIZE - CCM_COUNTER_SIZE)) { Serial.println("DECRYPT FAIL"); + NRF_RADIO->TASKS_START = 1; return 0; } } @@ -304,11 +307,10 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) payloadAvailable = true; return 1; } - if (NRF_RADIO->EVENTS_CRCERROR) { + if(NRF_RADIO->EVENTS_CRCERROR) { NRF_RADIO->EVENTS_CRCERROR = 0; NRF_RADIO->TASKS_START = 1; } - return 0; }