Closed markusschweitzer closed 3 years ago
Did you connect MCU to LoRa DIO0? By right, in the library, the sending will be skipped if a packet is receiving.
After sending, should call LoRa.receive() again to go back RX mode.
Yes, the ISR gets called correctly (DIO0 is connected), I read all the data and send a response packet :/
By right, you can not send a message during a receive. This is chip limitation.
Send after the receiving is complete. And sending outside the ISR callback.
Ok, I wasnt aware of that. Is there any way to do this without a periodic call in the loop() function?
By right, you should not do any processing inside the ISR also. ISR should set a flag only. Then you can process sending or receiving in the main loop or in a FreeRTOS task. Or you can create FreeRTOS task in the ISR.
But again, ISR should be as simple as setting a flag only if possible. :D Make it works before making it nice. Put sending part in loop is simpler. Delay the TX a bit after the RX.
void onReceive(int packetSize) {
// received a packet
Serial.print("Received packet '");
// read packet
for (int i = 0; i < packetSize; i++) {
Serial.print((char)LoRa.read()); <========= SHOULD NOT DO THIS IN ISR
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
}
I moved everything to the loop method (now without the interrupt, just parsePacket).
How much should I delay the TX after the whole packet is read (with LoRa.read())? It seems to get better wehn I add mor Serial.println in between...
100ms is more than enough.
Seems solved.
Hi, Im using the latest version from git and this example: https://github.com/sandeepmistry/arduino-LoRa/blob/master/examples/LoRaReceiverCallback/LoRaReceiverCallback.ino
When I try to send a packet in the receive callback, (beginPacket, write, endPacket) the receiver sends the packet, but doesnt receive anymore.
Calling Lora.idle() and LoRa.receive() after the sending helps for a few packets, but eventually it stops receiving.
Any idea how I can make this work?
best regards, markus