Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 14 additions & 6 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));
}

/******************************************************************/
#if defined ARDUINO_ARCH_ESP8266 || defined ARDUINO_ARCH_ESP32
template<class radio_t>
void ESBNetwork<radio_t>::RF24NetworkDelay(uint32_t delay)
{
uint32_t timer = millis();
while (millis() - timer < delay) {
}
}
#endif
/************************ Sleep Mode ******************************************/

#if defined ENABLE_SLEEP_MODE
Expand Down
8 changes: 8 additions & 0 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 || defined 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
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