Skip to content

Commit 54063b3

Browse files
authored
Fix handling of radio/network overruns (#249)
* Fix handling of radio/network overruns - The network can get stuck in an available loop if the radio is receiving data faster than the network can process it. If this happens, the RX FIFO needs to be flushed - Also return NETWORK_OVERRUN when this happens - Add network system type 160 NETWORK_OVERRUN * Set timeout to 100 in available()
1 parent 5b24caf commit 54063b3

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

RF24Network.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,12 @@ uint8_t ESBNetwork<radio_t>::update(void)
132132

133133
uint8_t returnVal = 0;
134134

135-
uint32_t timeout = millis();
135+
uint32_t timeout = millis() + 100;
136136

137137
while (radio.available()) {
138-
if (millis() - timeout > 1000) {
139-
#if defined FAILURE_HANDLING
140-
radio.failureDetected = 1;
141-
#endif
142-
break;
138+
if (millis() > timeout) {
139+
radio.flush_rx();
140+
return NETWORK_OVERRUN;
143141
}
144142
#if defined(ENABLE_DYNAMIC_PAYLOADS) && !defined(XMEGA_D3)
145143
frame_size = radio.getDynamicPayloadSize();

RF24Network.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@
122122
// NO ACK Response Types
123123
//#define NETWORK_ACK_REQUEST 192
124124

125+
/**
126+
* Messages of this type indicate the network is being overrun with data & the RX FIFO has been flushed.
127+
**/
128+
#define NETWORK_OVERRUN 160
129+
125130
/**
126131
* Messages of this type signal the sender that a network-wide transmission has been completed.
127132
*

0 commit comments

Comments
 (0)