diff --git a/crossbow.ino b/crossbow.ino index bfd88d6..61d146c 100644 --- a/crossbow.ino +++ b/crossbow.ino @@ -487,7 +487,7 @@ void onReceive(int packetSize) //We have a packet candidate that might contain a valid QSP packet radioState.bytesToRead = packetSize; for (int i = 0; i < packetSize; i++) { - radioState.data[i] = LoRa.read(); + radioState.data[i] = LoRa.fastRead(); } radioState.rssi = getRadioRssi(); radioState.snr = getRadioSnr(); diff --git a/lora.cpp b/lora.cpp index c7966a9..9ccb8d6 100644 --- a/lora.cpp +++ b/lora.cpp @@ -238,15 +238,19 @@ int LoRaClass::available() return (readRegister(REG_RX_NB_BYTES) - _packetIndex); } +int LoRaClass::fastRead() { + _packetIndex++; + + return readRegister(REG_FIFO); +} + int LoRaClass::read() { if (!available()) { return -1; } - _packetIndex++; - - return readRegister(REG_FIFO); + return fastRead(); } void LoRaClass::onReceive(void(*callback)(int)) diff --git a/lora.h b/lora.h index ef9e992..2c237dd 100644 --- a/lora.h +++ b/lora.h @@ -34,6 +34,7 @@ public: size_t write(const uint8_t *buffer, size_t size); int available(); int read(); + int fastRead(); void onReceive(void(*callback)(int));