I am testing the LoRa functionality of a Heltec ESP32 V2 board. I can easily send and receive packets using the Heltec library with an Arduino IDE. I then implemented a function to send an Acknowledge after the receiver receives a packet. While doing this I found that there is quite large delays and I started to search for the reason.
When sending a packet my code looks like this:
And I found that there is a huge delay (>500ms) for the function Lora.endPacket(). I looked up this function in the Heltec library and it looks like this:
// put in TX mode
writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX);
// wait for TX done
while((readRegister(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0);
// clear IRQ’s
The readRegister() and writeRegister() functions work without measurable delay, the problem is created by the while look in the code above. This loop is passed extremely often before the register signals that the transmission is done.
Can it be that transmitting a packet takes more than 500ms? Is this normal? Why does this take so long? Can this be shortened? Any help highly appreciated.