Crossbow LRS, I was doing this wrong...
Last update on Crossbow LRS DIY RC link I'm currently building was 2 weeks ago. Back then, it did not went well: crashed an airplane beyond field repair. Last weekend I was able to do what I planned, but that did not went well as well. This time from completely different reason...
Link was catching failsafe every few minutes, even when RX was only few meters away from TX. To make things worse, link needed few seconds to recover. And twice it got stuck and required RX restart. It took me quite some time to discover what was the reason of that and a way to fix it.
To give you a full picture:
- Link is build using LoRa32u4 II Arduino compatible boards that utilizes HPD13 868MHz LoRa radio module. HPD13 uses Semtech SX1276 radio chipset
- SX1276 has 256 bytes of memory is divided equally for RX and TX FIFO queue
- I was testing in LoRa rich environment
- To reduce the probability of race conditions on SPI access and ISR locking, radio RX fifo was read in main loop. Radio interrupt was only setting a flag that data is present
The reason for hanging link was a combination of all points above: From time to time, when radio received a rouge long LoRa packet (by long I mean longer than 128 bytes), both RX and TX were stuck processing it and as a result buffer was never fully emptied and protocol state set to IDLE. In theory, there was a air protocol reset routine, but since SX1276 FIFO was overloaded, it was not working like I expected.
The solution (or at least I hope it will solve the problem) is as follows:
- Radio interrupt checks if received packet size is a probable air protocol packet. Since its between 7 and 12 bytes, everything else is rejected
- When probable packet is detected (size between 7 and 12 bytes), it is copied to temporary buffer, read and decoded in main loop
- Radio buffers are flushed after each packet (put SX1276 in sleep and wake again)
Right now, link is up and running on a bench with other LoRa stations talking around for 2 hours. Not a single failsafe or any other problem so far. Look good. Unfortunately it is raining, so not further live testing this weekend I'm afraid.
By the way, there were good things during my last test too. At 500m distance link still had around 80dB of link budget left. That means I should be able to reach my goal: 5km range is within reach!
I'm Paweł Spychalski and I do things. Mainly software development, FPV drones and amateur cinematography. Here are my YouTube channels: