Also adapt code for send function. Added some comments.

This commit is contained in:
Jens Dede 2022-02-25 11:02:39 +01:00
parent e11dc1e059
commit d8d4ee6ffe
No known key found for this signature in database
GPG Key ID: 7BE9726754C19481
1 changed files with 7 additions and 2 deletions

View File

@ -261,7 +261,12 @@ void RFM69::send(uint16_t toAddress, const void* buffer, uint8_t bufferSize, boo
{ {
writeReg(REG_PACKETCONFIG2, (readReg(REG_PACKETCONFIG2) & 0xFB) | RF_PACKET2_RXRESTART); // avoid RX deadlocks writeReg(REG_PACKETCONFIG2, (readReg(REG_PACKETCONFIG2) & 0xFB) | RF_PACKET2_RXRESTART); // avoid RX deadlocks
uint32_t now = millis(); uint32_t now = millis();
while (!canSend() && millis() - now < RF69_CSMA_LIMIT_MS) receiveDone(); while (!canSend() && millis() - now < RF69_CSMA_LIMIT_MS){
receiveDone();
#ifdef ESP8266
delay(1); // Give esp8266-based boards to handle background tasks. Seems to work better than yield();
#endif
}
sendFrame(toAddress, buffer, bufferSize, requestACK, false); sendFrame(toAddress, buffer, bufferSize, requestACK, false);
} }
@ -307,7 +312,7 @@ void RFM69::sendACK(const void* buffer, uint8_t bufferSize) {
while (!canSend() && millis() - now < RF69_CSMA_LIMIT_MS){ while (!canSend() && millis() - now < RF69_CSMA_LIMIT_MS){
receiveDone(); receiveDone();
#ifdef ESP8266 #ifdef ESP8266
delay(1); // Give esp8266-based boards to handle background tasks delay(1); // Give esp8266-based boards to handle background tasks. Seems to work better than yield().
#endif #endif
} }
SENDERID = sender; // TWS: Restore SenderID after it gets wiped out by receiveDone() SENDERID = sender; // TWS: Restore SenderID after it gets wiped out by receiveDone()