Skip to content

Commit eefd41a

Browse files
Fixes for lwIP integration (#260)
* Fixes for lwIP integration - Redefine MAX_FRAME_SIZE to RF24_NETWORK_MAX_FRAME_SIZE - Change delay() to millis() timeout * Update RF24Network.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update RF24Network.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update RF24Network.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update RF24Network.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update RF24Network.h Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update RF24Network.h Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Use millis instead of micros() * Fix spelling --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent af22983 commit eefd41a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

RF24Network.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ uint16_t RF24NetworkHeader::next_id = 1;
5252
#if defined(RF24_LINUX)
5353
/******************************************************************/
5454
template<class radio_t>
55-
ESBNetwork<radio_t>::ESBNetwork(radio_t& _radio) : radio(_radio), frame_size(MAX_FRAME_SIZE)
55+
ESBNetwork<radio_t>::ESBNetwork(radio_t& _radio) : radio(_radio), frame_size(RF24NETWORK_MAX_FRAME_SIZE)
5656
{
5757
networkFlags = 0;
5858
returnSysMsgs = 0;
@@ -144,7 +144,7 @@ uint8_t ESBNetwork<radio_t>::update(void)
144144
#if defined(ENABLE_DYNAMIC_PAYLOADS) && !defined(XMEGA_D3)
145145
frame_size = radio.getDynamicPayloadSize();
146146
#else
147-
frame_size = MAX_FRAME_SIZE;
147+
frame_size = RF24NETWORK_MAX_FRAME_SIZE;
148148
#endif
149149
if (!frame_size) {
150150
return NETWORK_CORRUPTION;
@@ -459,10 +459,7 @@ uint8_t ESBNetwork<radio_t>::enqueue(RF24NetworkHeader* header)
459459
frag_queue.header.reserved = 0;
460460
return false;
461461
}
462-
if (frag_queue.header.reserved == 0
463-
|| (header->type != NETWORK_LAST_FRAGMENT && header->reserved != frag_queue.header.reserved)
464-
|| frag_queue.header.id != header->id
465-
|| (header->type == NETWORK_LAST_FRAGMENT && frag_queue.header.reserved != 1)) {
462+
if (frag_queue.header.reserved == 0 || (header->type != NETWORK_LAST_FRAGMENT && header->reserved != frag_queue.header.reserved) || frag_queue.header.id != header->id || (header->type == NETWORK_LAST_FRAGMENT && frag_queue.header.reserved != 1)) {
466463
#if defined(RF24NETWORK_DEBUG_FRAGMENTATION) || defined(RF24NETWORK_DEBUG_MINIMAL)
467464
printf_P(PSTR("Drop frag %d Out of order\n\r"), header->reserved);
468465
#endif
@@ -489,7 +486,6 @@ uint8_t ESBNetwork<radio_t>::enqueue(RF24NetworkHeader* header)
489486
#if defined(DISABLE_USER_PAYLOADS)
490487
return 0;
491488
#endif
492-
493489
if ((uint16_t)(MAX_PAYLOAD_SIZE) - (next_frame - frame_queue) >= frag_queue.message_size) {
494490
memcpy(next_frame, &frag_queue, 10);
495491
memcpy(next_frame + 10, frag_queue.message_buffer, frag_queue.message_size);
@@ -788,7 +784,9 @@ bool ESBNetwork<radio_t>::main_write(RF24NetworkHeader& header, const void* mess
788784
ok = _write(header, ((char*)message) + offset, fragmentLen, writeDirect);
789785

790786
if (!ok) {
791-
delay(2);
787+
uint32_t timer = millis() + 2;
788+
while (millis() < timer) {
789+
}
792790
++retriesPerFrag;
793791
}
794792
else {

RF24Network.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@
203203
#define USER_TX_MULTICAST 4
204204

205205
#if defined NRF52_RADIO_LIBRARY
206-
#define MAX_FRAME_SIZE 123 // Size of individual radio frames is larger with NRF52
206+
#define RF24NETWORK_MAX_FRAME_SIZE 123 // Size of individual radio frames is larger with NRF52
207207
#else
208-
#define MAX_FRAME_SIZE 32 // Size of individual radio frames
208+
#define RF24NETWORK_MAX_FRAME_SIZE 32 // Size of individual radio frames
209209
#endif
210210

211211
#define FRAME_HEADER_SIZE 10 // Size of RF24Network frames - data
@@ -765,7 +765,7 @@ class ESBNetwork
765765
* outgoing or incoming).
766766
* @note The first 8 bytes of this buffer is latest handled frame's RF24NetworkHeader data.
767767
*/
768-
uint8_t frame_buffer[MAX_FRAME_SIZE];
768+
uint8_t frame_buffer[RF24NETWORK_MAX_FRAME_SIZE];
769769

770770
/**
771771
* **Linux platforms only**
@@ -956,7 +956,7 @@ class ESBNetwork
956956

957957
uint8_t frame_size; /* The outgoing frame's total size including the header info. Ranges [8, MAX_PAYLOAD_SIZE] */
958958

959-
unsigned int max_frame_payload_size = MAX_FRAME_SIZE - sizeof(RF24NetworkHeader); /* always 24 bytes to compensate for the frame's header */
959+
unsigned int max_frame_payload_size = RF24NETWORK_MAX_FRAME_SIZE - sizeof(RF24NetworkHeader); /* always 24 bytes to compensate for the frame's header */
960960

961961
#if defined(RF24_LINUX)
962962
std::queue<RF24NetworkFrame> frame_queue;

0 commit comments

Comments
 (0)