From 2b3b000207f6528ebf6fcfbbf3c0015ce9933907 Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Tue, 26 Sep 2023 12:12:32 -0600 Subject: [PATCH] Extra Pipes (#215) * Extra Pipes Add support for any number of 'pipes' that are available for addressing. Allows wider range of addressing on NRF52x devices * Fix comment * Update RF24Network_config.h Co-authored-by: Brendan <2bndy5@gmail.com> * Update RF24Network.cpp Co-authored-by: Brendan <2bndy5@gmail.com> --------- --- RF24Network.cpp | 15 +++++++++++---- RF24Network_config.h | 6 ++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/RF24Network.cpp b/RF24Network.cpp index 2ab77180..b58e9bed 100644 --- a/RF24Network.cpp +++ b/RF24Network.cpp @@ -103,7 +103,7 @@ void ESBNetwork::begin(uint8_t _channel, uint16_t _node_address) setup_address(); // Open up all listening pipes - uint8_t i = 6; + uint8_t i = NUM_PIPES; while (i--) radio.openReadingPipe(i, pipe_address(_node_address, i)); @@ -956,7 +956,7 @@ void ESBNetwork::logicalToPhysicalAddress(logicalToPhysicalStruct* conv //} } else if (is_descendant(*to_node)) { - pre_conversion_send_pipe = 5; // Send to its listening pipe + pre_conversion_send_pipe = NUM_PIPES - 1; // Send to its listening pipe // If the node is a direct child, if (is_direct_child(*to_node)) { // Send directly @@ -1131,7 +1131,7 @@ bool ESBNetwork::is_valid_address(uint16_t node) #endif while (node) { uint8_t digit = node & 0x07; - if (digit < 1 || digit > 5) { + if (digit < 1 || digit > (NUM_PIPES - 1)) { result = false; IF_SERIAL_DEBUG_MINIMAL(printf_P(PSTR("*** WARNING *** Invalid address 0%o\n\r"), origNode);); break; @@ -1181,7 +1181,14 @@ template uint64_t ESBNetwork::pipe_address(uint16_t node, uint8_t pipe) { - static uint8_t address_translation[] = {0xc3, 0x3c, 0x33, 0xce, 0x3e, 0xe3, 0xec}; + static uint8_t address_translation[] = {0xc3, 0x3c, 0x33, 0xce, 0x3e, 0xe3, 0xec +#if NUM_PIPES > 6 +, 0xee + #if NUM_PIPES > 7 +, 0xed + #endif +#endif +}; uint64_t result = 0xCCCCCCCCCCLL; uint8_t* out = reinterpret_cast(&result); diff --git a/RF24Network_config.h b/RF24Network_config.h index ae29865e..5968a305 100644 --- a/RF24Network_config.h +++ b/RF24Network_config.h @@ -81,6 +81,12 @@ /** Enable dynamic payloads - If using different types of nRF24L01 modules, some may be incompatible when using this feature **/ #define ENABLE_DYNAMIC_PAYLOADS #endif // DISABLE_DYNAMIC_PAYLOADS + + /** The number of 'pipes' available for addressing in the current device + * Networks with NRF24L01 devices only have 6 pipes + * NRF52x networks support up to 8 pipes + */ + #define NUM_PIPES 6 /* Debug Options */ //#define SERIAL_DEBUG