Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions RF24Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ uint8_t ESBNetwork<radio_t>::update(void)
header->to_node = header->from_node;
header->from_node = node_address;
#ifdef SLOW_ADDR_POLL_RESPONSE
delay(parent_pipe + SLOW_ADDR_POLL_RESPONSE);
RF24NETWORK_DELAY(parent_pipe + SLOW_ADDR_POLL_RESPONSE);
#else
delay(parent_pipe);
RF24NETWORK_DELAY(parent_pipe);
#endif
write(header->to_node, USER_TX_TO_PHYSICAL_ADDRESS);
}
Expand Down Expand Up @@ -786,9 +786,7 @@ bool ESBNetwork<radio_t>::main_write(RF24NetworkHeader& header, const void* mess
ok = _write(header, ((char*)message) + offset, fragmentLen, writeDirect);

if (!ok) {
const uint32_t retry_delay_start = millis();
while (millis() - retry_delay_start < 2) {
}
RF24NETWORK_DELAY(2);
++retriesPerFrag;
}
else {
Expand Down Expand Up @@ -902,7 +900,7 @@ bool ESBNetwork<radio_t>::write(uint16_t to_node, uint8_t sendType)
IF_RF24NETWORK_DEBUG(printf_P(PSTR("MAC Sending to 0%o via 0%o on pipe %x\n\r"), to_node, conversion.send_node, conversion.send_pipe));
/**Write it*/
if (sendType == TX_ROUTED && conversion.send_node == to_node && isAckType) {
delay(2);
RF24NETWORK_DELAY(2);
}
ok = write_to_pipe(conversion.send_node, conversion.send_pipe, conversion.multicast);

Expand Down Expand Up @@ -1266,6 +1264,16 @@ void ESBNetwork<radio_t>::pipe_address(uint16_t node, uint8_t pipe, uint8_t* add
IF_RF24NETWORK_DEBUG(uint32_t* top = reinterpret_cast<uint32_t*>(address + 1); printf_P(PSTR("NET Pipe %i on node 0%o has address %x%x\n\r"), pipe, node, *top, *address));
}

/******************************************************************/

template<class radio_t>
void ESBNetwork<radio_t>::RF24NetworkDelay(uint32_t delay)
{
uint32_t timer = millis();
while (millis() - timer < delay) {
}
}

/************************ Sleep Mode ******************************************/

#if defined ENABLE_SLEEP_MODE
Expand Down Expand Up @@ -1307,8 +1315,8 @@ bool ESBNetwork<radio_t>::sleepNode(unsigned int cycles, int interruptPin, uint8

while (sleep_cycles_remaining) {
sleep_mode(); // System sleeps here
} // The WDT_vect interrupt wakes the MCU from here
sleep_disable(); // System continues execution here when watchdog timed out
} // The WDT_vect interrupt wakes the MCU from here
sleep_disable(); // System continues execution here when watchdog timed out
Comment thread
TMRh20 marked this conversation as resolved.
Outdated
Comment thread
TMRh20 marked this conversation as resolved.
Outdated
detachInterrupt(interruptPin);

#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
Expand Down
12 changes: 10 additions & 2 deletions RF24Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,14 @@ class ESBNetwork
*/
uint8_t networkFlags;

#if defined ARDUINO_ARCH_ESP8266 || ARDUINO_ARCH_ESP32
/**
* Use a regular delay for most devices, but on ESP32 and ESP8266, use a millis() based timeout.
* See RF24NETWORK_DELAY in RF24Network_config.h
*/
void RF24NetworkDelay(uint32_t delay);
#endif

protected:
#if defined(RF24NetworkMulticast)
/**
Expand Down Expand Up @@ -965,12 +973,12 @@ class ESBNetwork
#else // Not Linux:

#if defined(DISABLE_USER_PAYLOADS)
uint8_t frame_queue[1]; /** Space for a small set of frames that need to be delivered to the app layer */
uint8_t frame_queue[1]; /** Space for a small set of frames that need to be delivered to the app layer */
Comment thread
TMRh20 marked this conversation as resolved.
Outdated
Comment thread
TMRh20 marked this conversation as resolved.
Outdated
#else
uint8_t frame_queue[MAIN_BUFFER_SIZE]; /** Space for a small set of frames that need to be delivered to the app layer */
#endif

uint8_t* next_frame; /** Pointer into the @p frame_queue where we should place the next received frame */
uint8_t* next_frame; /** Pointer into the @p frame_queue where we should place the next received frame */
Comment thread
TMRh20 marked this conversation as resolved.
Outdated
Comment thread
TMRh20 marked this conversation as resolved.
Outdated
Comment thread
TMRh20 marked this conversation as resolved.
Outdated

#if !defined(DISABLE_FRAGMENTATION)
RF24NetworkFrame frag_queue; /* a cache for re-assembling incoming message fragments */
Expand Down
6 changes: 6 additions & 0 deletions RF24Network_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@
#define ENABLE_DYNAMIC_PAYLOADS
#endif // DISABLE_DYNAMIC_PAYLOADS

#if defined ARDUINO_ARCH_ESP8266 || ARDUINO_ARCH_ESP32
#define RF24NETWORK_DELAY(x) RF24NetworkDelay(x)
#else
#define RF24NETWORK_DELAY(x) delay(x)
#endif

/* Debug Options */
//#define RF24NETWORK_DEBUG
//#define RF24NETWORK_DEBUG_MINIMAL
Expand Down
Loading