sparkfun / SparkFun_QwiicRF_Library

Arduino Library for the QwiicRF LoRa Radio Board
4 stars 2 forks source link

sendReliable timing issue #2

Open finnbear opened 5 years ago

finnbear commented 5 years ago

In my testing, a short delay (10-500ms) is necessary after calling sendReliable. If the delay is removed, the code below will enter a state in which every "sendReliable" call does actually send a radio packet but is marked as successful even if the recipient is unplugged.

The resolution would be to either update the example code to incorporate such a delay, fix the library/firmware, or tell me what I am doing wrong with my edits to the example code.

#include <QwiicRF.h>

QwiicRF Radio;
String message = "Hello";
int success = 0;
int total = 0;

void setup() {
  Radio.begin(0x35);
  Radio.setReliableSendTimeout(5);
  Serial.begin(9600);

}

void loop() {
  long start = millis();
  if(Radio.sendReliable(message)) {
    Serial.print("Sending...");

    delay(500); // <---- This line

    while (Radio.waitingForAck()) {
      delay(1000);
    }
    total += 1;
    if (Radio.reliableFailed()) {
      Serial.print("Failure => ");    
    } else {
      success += 1;
      Serial.print("Success => ");
    }
    Serial.print(success);
    Serial.print(" out of ");
    Serial.print(total);
    Serial.print(" were successful (");
    Serial.print((millis() - start) * 0.001);
    Serial.println(")");
  }
  delay(1000);
}
santaimpersonator commented 4 years ago

As mentioned on the product page:

Experimental Product: SparkX products are rapidly produced to bring you the most cutting edge technology as it becomes available. These products are tested but come with no guarantees. Live technical support is not available for SparkX products. Head on over to our forum for support or to ask a question.

That being said, I am not very familiar using this product; however, my guess is that this is just the transmission time (w/ a few attempts) and processing time required for that function. Although this is not the channel used for technical issues, I will leave this issue open in case it does end up being an issue with the code.