uPyLoRaWAN: receiving with interrupt callback not working

Hi,

I have set the dio_0 pin number in config.py and changed the code in examples/LoRaReceiver.py as following:

def receive(lora):
    print('LoRa Receiver Callback')
    
    def cb(payload):
        lora.blink_led()
        print(payload)
    
    lora.on_receive(cb)
    lora.receive()

But it didn’t work - couldn’t receive any data. It only worked with while True loop as shown in the original example.

Did I miss something? Pls help!

It’s an AI-Thinker Ra-02 LoRa module with ESP32. The MicroPython firmware is V1.13 stable.

I used the sx127x driver in the master branch, and the readme title is uPyLora.

About this issue

Most upvoted comments

You need to change the if statement inside the handle_on_receive to: if irq_flags & IRQ_RX_DONE_MASK == IRQ_RX_DONE_MASK:, then it will work.

So it should look like:

            if irq_flags & IRQ_RX_DONE_MASK == IRQ_RX_DONE_MASK:
                if self._on_receive_cb:
                    print('msg coming in')
                    payload = self.read_payload()
                    self._on_receive_cb(payload)