sandeepmistry / arduino-LoRa

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

LoRa.end(); to detatch interupt ? Lora + ArduinoOTA , OTA update Sometime Crash #590

Open T1j3ff opened 1 year ago

T1j3ff commented 1 year ago

Had issue were OTA update would often crash

Sending invitation to 192.168.1.191 
Uploading: [                                                            ] 0% 
07:37:03 [ERROR]: Error Uploading
07:37:03 [ERROR]: Error Uploading

This begun happening after enabling interrupt with LoRa.onReceive() LoRa.onTxDone()

Serial trace on the ESP32:

07:37:02.769 -> Start updating sketch
07:37:02.769 -> Progress: 0%
07:37:02.769 -> Progress: 0%
07:37:02.769 -> Progress: 0%
07:37:02.769 -> Progress: 0%
07:37:02.816 -> Progress: 0%
07:37:02.863 -> 
07:37:02.863 -> assert failed: xQueueSemaphoreTake queue.c:1554 (!( ( xTaskGetSchedulerState() == ( ( BaseType_t ) 0 ) ) && ( xTicksToWait != 0 ) ))
07:37:02.863 -> 
07:37:02.863 -> 
07:37:02.863 -> Backtrace:0x40083739:0x3ffbedfc |<-CORRUPTED
07:37:02.863 -> 
07:37:02.863 -> 
07:37:02.863 -> 
07:37:02.863 -> 
07:37:02.863 -> ELF file SHA256: 0000000000000000
07:37:02.863 -> 
07:37:02.863 -> Rebooting...

I've resolved the issue with adding code to disable lora interrupts when starting an OTA update

.onStart([]() {
      LoRa.end(); //added to stop interrupts disrupting the OTA 
      detachInterrupt(digitalPinToInterrupt(2));  //added to stop interrupts disrupting the OTA  

Might not be the cleanest way to do it

Not a big deal on the Lora code itself But I would Have expected LoRa.end(); to detach the interrupt pin itself :)