sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.6k stars 621 forks source link

onRecive() method never triggered. #661

Open Alain-Godo opened 10 months ago

Alain-Godo commented 10 months ago

Hi everyone!!! I have the following issue. When I receive the data in a sync way all is fine (using the loop for example) but the callback function is never triggered using the onReceive() method.

IDE: PlatformIO Board: ESP32 DOIT DEVKIT V1 Pin used: HSPI + 4 (Reset) + 2 (DIO0)

Setup code:

hspi = new SPIClass(HSPI); hspi->begin(); lora2.setSPI(*hspi);

lora2.setPins(15,4,2); Serial.println("Begining 2..."); Serial.println(lora2.begin(915E6)); lora2.onReceive(lora2Callback); lora2.receive();

Callback function:

void lora2Callback(int packet_size) { Serial.print("Received packet: '");

// read packet
while (lora2.available()) {
Serial.print((char)lora2.read());
}

// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(lora2.packetRssi());

}

Note:

I tried changing the DIO0 pin that is related to the interrupt but still doesn't work.

qiweimao commented 3 weeks ago

Try to keep your callback extremely short. It's a system interrupt. This problem bugged me for days.

Read this issue to solve all your confusions: link