Skip to content

Lora onReceive Callback not triggered, but data received in loop() #127

Closed
@acbrandao

Description

@acbrandao

Strange behavior, I tried altering the LoRaDuplexCallback example, integrating it into my TTGO Lora board. Sender is sending as expected, and data is reaching my receiver node, but the Callback is not getting triggered. Code segment looks like this..

 setup()
{
...
  LoRa.onReceive(onReceive);  //register the Callback
  LoRa.receive();
  Serial.println("LoRa init succeeded.");
...
}

void onReceive(int packetSize) {
...
 //IT NEVER prints this line or any other code    
  Serial.println("Received packet size:"+(String)packetSize );
... 
}

If however I place the receive inside the main Loop() as below it works?

    {
     int  rssi = LoRa.packetRssi();
    
    Serial.print("Received packet '");
    Serial.println("Packet  RCVD "+String(packetSize)+"bytes" );
    
    // read packet
    String packet="";                   // Clear packet
    while (LoRa.available()) 
    packet += (char)LoRa.read(); // Assemble new packet    
    Serial.println(packet);
  }

Do I need to do anything else beside register the OnReceive for it to work?
Hardware: TTGO Lora OLED v.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions