ASR6502 LoRa Interrupt on Receive?

Is there a way to set an ISR for a receive interrupt on LoRa receive on the ASR6502/CubeCell? I want to go off and do things like read the GPS, update the screen check for user input, and generally not just hang around in Radio.Rx(0) waiting for inbound packets.
This is for raw LoRa mode, not LoraWAN. I just want to set an interrupt handler on a GPIO that the SX1262 toggles when it receives LoRa data. Is this possible? Is there sample code for it?

Thanks,
John

EDIT 2: Removed ‘packetReceived’ boolean (it was a remnant from an earlier test and not used) and updated the Serial Monitor output to reflect the final state of the test code.

Well, I’ve been wondering this myself for quite a while so your question prompted me to revisit this. I won’t bore you with the details of my reasoning but I ultimately went back to the CubeCell factory test sketch (Factory_Test_AB01.ino) as the simplest starting point. That sketch alone looks like it is doing what we want, effectively doing something else while waiting for a packet to come in—in this case sleeping.

To verify that the code would work if we were doing something other than sleeping, I made the following modifications:

  1. Add/modify the following definitions:
typedef enum
{
    PROCESS,
    RX,
    TX
} States_t;

long time, interval;
long start = 0;
long reportPeriod = 1000;
  1. Modify the loop switch statement to include:
	case PROCESS:
		Serial.println("into PROCESS mode");
		break;

This case doesn’t really do anything other than tell me that PROCESS state has been set, so it’s probably entirely unnecessary in the overall scheme of things, but delete the LOWPOWER option and any references to LOWPOWER in any case;

  1. Add the following before the break statement at the end of the TX case:
		state = PROCESS;
  1. Add the following before the break statement at the end of the RX case:
	    state = PROCESS;
  1. Add the following at the end of the main loop, after the call to Radio.IrqProcess():
  while ( state == PROCESS ) {
    doStuff();
  }

EDIT: Better still, just place this loop inside the PROCESS case at 2. above (I don’t know why I didn’t do that to begin with!)

  1. Define the following function:
void doStuff() {
  time = millis();
  interval = time - start;
  if ( interval > reportPeriod ) {
    Serial.println("[doStuff] Doing stuff...");
    start = time;
  }
}
  1. (Deleted at EDIT 2)

  2. I uploaded this to a CubeCell (AB01) V2 module and noted the following output on the Serial Monitor:

09:51:01.536 -> Copyright @2019-2020 Heltec Automation.All rights reserved.
09:51:07.422 -> 
09:51:07.422 -> sending packet "hello1 rssi : 0" , length 15
09:51:07.422 -> into PROCESS mode
09:51:07.422 -> [doStuff] Doing stuff...
09:51:07.456 -> TX done......into RX mode
09:51:09.531 -> into PROCESS mode
09:51:09.531 -> [doStuff] Doing stuff...
09:51:10.519 -> [doStuff] Doing stuff...
09:51:11.524 -> [doStuff] Doing stuff...
09:51:12.544 -> [doStuff] Doing stuff...
09:51:13.546 -> [doStuff] Doing stuff...
09:51:14.545 -> [doStuff] Doing stuff...
09:51:15.541 -> [doStuff] Doing stuff...
09:51:16.539 -> [doStuff] Doing stuff...
09:51:17.551 -> [doStuff] Doing stuff...
09:51:18.516 -> [doStuff] Doing stuff...
09:51:19.526 -> [doStuff] Doing stuff...
09:51:19.846 -> 
09:51:19.846 -> received packet "��E�,�������" with rssi -45 , length 18
09:51:19.846 -> wait to send next packet
09:51:20.872 -> 
09:51:20.872 -> sending packet "hello2 rssi : -45" , length 17
09:51:20.872 -> into PROCESS mode
09:51:20.872 -> [doStuff] Doing stuff...
09:51:20.905 -> TX done......into RX mode
09:51:20.939 -> into PROCESS mode
09:51:21.852 -> [doStuff] Doing stuff...
09:51:22.367 -> 
09:51:22.367 -> received packet "�d��)��6����" with rssi -56 , length 18
09:51:22.367 -> wait to send next packet
09:51:23.388 -> 
09:51:23.388 -> sending packet "hello3 rssi : -56" , length 17
09:51:23.388 -> into PROCESS mode
09:51:23.423 -> [doStuff] Doing stuff...
09:51:23.456 -> TX done......into RX mode
09:51:23.456 -> into PROCESS mode
09:51:23.867 -> 
09:51:23.904 -> received packet "�d��@)��Y��-" with rssi -37 , length 18
09:51:23.904 -> wait to send next packet
09:51:24.924 -> 
09:51:24.924 -> sending packet "hello4 rssi : -37" , length 17
09:51:24.924 -> into PROCESS mode
09:51:24.924 -> [doStuff] Doing stuff...
09:51:24.956 -> TX done......into RX mode
09:51:24.991 -> into PROCESS mode
09:51:25.910 -> [doStuff] Doing stuff...
09:51:26.905 -> [doStuff] Doing stuff...

I have several Nodes in my LoRa network, transmitting packets at 60 second intervals. This sketch makes no attempt to interpret the content of those packets, but they are clearly being received while our sketch is looping around ‘Doing other stuff’. I left most of the other Factory_Test sketch code in place, so it still sends out a packet before waiting for something to be received, but I don’t believe that this would have any bearing on the receiving process.

1 Like