WiFi LoRa 32 V3 receive is blocking and receive timeout doesn't work

Hi everyone,

I’m having trouble setting the receive timeout on V3 boards using the simple receiver example. Below is my code and I have a timeout of 100ms for Radio.Rx() function and the code doesn’t work unfortunately. I’d like to implement a non-blocking receive/RX operation so I can do other things while waiting for RX. Anyone has a working example for V3 boards?

#include "LoRaWan_APP.h"
#include "Arduino.h"


#define RF_FREQUENCY                                915000000 // Hz

#define TX_OUTPUT_POWER                             14        // dBm

#define LORA_BANDWIDTH                              0         // [0: 125 kHz,
                                                              //  1: 250 kHz,
                                                              //  2: 500 kHz,
                                                              //  3: Reserved]
#define LORA_SPREADING_FACTOR                       7         // [SF7..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]
#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT                         0         // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON                  false
#define LORA_IQ_INVERSION_ON                        false

#define RX_TIMEOUT_VALUE                            1
#define BUFFER_SIZE                                 30 // Define the payload size here

char txpacket[BUFFER_SIZE];
char rxpacket[BUFFER_SIZE];

static RadioEvents_t RadioEvents;

int16_t txNumber;

int16_t rssi,rxSize;

bool lora_idle = true;

uint32_t timeout = 100;

void setup() {
    Serial.begin(115200);
    Mcu.begin();
    
    txNumber=0;
    rssi=0;
  
    RadioEvents.RxDone = OnRxDone;
    RadioEvents.RxTimeout = OnRxTimeout;

    Radio.Init( &RadioEvents );
    Radio.SetChannel( RF_FREQUENCY );
    Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
                               LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
                               LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
                               0, true, 0, 0, LORA_IQ_INVERSION_ON, false );
    Radio.Rx(timeout);
}



void loop()
{
  if(lora_idle)
  {
    lora_idle = false;
    Serial.println("into RX mode");
    Radio.Rx(timeout);
  }
  Radio.IrqProcess( );
}

void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
{
    rssi=rssi;
    rxSize=size;
    memcpy(rxpacket, payload, size );
    rxpacket[size]='\0';
    Radio.Sleep( );
    Serial.printf("\r\nreceived packet \"%s\" with rssi %d , length %d\r\n",rxpacket,rssi,rxSize);
    lora_idle = true;
}

void OnRxTimeout() {
  Radio.Sleep( );
  Serial.println("RX Timeout ---------------------------------------------------------------------------------");
  lora_idle = true;
}

This thread may be of interest:


It starts off talking about the CubeCell but then goes on to discuss the same with a Wireless Stick Lite, which should be the same as the WiFi LoRa 32 in this context. Indeed, I’ve just run the sketch up on a WiFi LoRa 32 V3 board and it works as described.

Unfortunately, I think the modification that was made to the ESP32 radio.c file (uncomment the call to RadioIrqProcess()) to achieve this result caused problems somewhere else, which is probably why the call was commented out in the first place. And, unfortunately again, I don’t seem to have made a note as to what that problem was, I can only see that my current version of the file has the call commented out once again. I’ll go back through my notes and let you know if I find anything more on that but, as I recall, this exercise was a bit of a diversion and I just reverted to the original version (of the radio.c file) and went on with what I was doing at the time.

EDIT: My notes just make the observation that, while the factory test sketch seemed to run OK, this modification (to the radio.c file) resulted in constant resetting of the processor when running one of my applications, so I backed out the change. I haven’t investigated this any further.