//============================================================================= // sendWithRetry() - overrides the base to allow increasing power when repeated ACK requests fail //============================================================================= bool RFM69_ATC::sendWithRetry(uint8_t toAddress, const void* buffer, uint8_t bufferSize, uint8_t retries, uint8_t retryWaitTime) { uint32_t sentTime; for (uint8_t i = 0; i <= retries; i++) { send(toAddress, buffer, bufferSize, true); sentTime = millis(); while (millis() - sentTime < retryWaitTime) { if (ACKReceived(toAddress)) { return true; } } } if (_transmitLevel < 31) _transmitLevel++; return false; }
// to increase the chance of getting a packet across, call this function instead of send // and it handles all the ACK requesting/retrying for you :) // The only twist is that you have to manually listen to ACK requests on the other side and send back the ACKs // The reason for the semi-automaton is that the lib is interrupt driven and // requires user action to read the received data and decide what to do with it // replies usually take only 5..8ms at 50kbps@915MHz bool RFM69::sendWithRetry(uint8_t toAddress, const void* buffer, uint8_t bufferSize, uint8_t retries, uint8_t retryWaitTime) { uint32_t sentTime; for (uint8_t i = 0; i <= retries; i++) { send(toAddress, buffer, bufferSize, true); sentTime = millis(); while (millis() - sentTime < retryWaitTime) { if (ACKReceived(toAddress)) { //Serial.print(" ~ms:"); Serial.print(millis() - sentTime); return true; } } //Serial.print(" RETRY#"); Serial.println(i + 1); } return false; }