cjhdev / lora_device_lib

A LoRaWAN Device Library
https://ldl.readthedocs.io/en/latest/
MIT License
33 stars 8 forks source link

Radio interrupt not raised when message received in SF11 and SF12 #11

Closed cjhdev closed 4 years ago

cjhdev commented 4 years ago

This bug is in 0.4.0 but it's possibly been around longer.

Normally, a radio waiting to receive a packet will raise one of two interrupt lines to signal:

  1. RX complete: a message was received
  2. RX timeout: no preamble was detected

LDL uses a guard timer to reset the chip if no interrupt is raised within an extended period of time. If this timer expires, LDL produces a chip error event and performs a chip reset.

I've been reproducing this bug by waiting for OTAA to increase the spreading factor to 11 (or 12) before starting the network server to answer the join request at that spreading factor. If there is no message sent, the timeout interrupt is raised. If there is a message sent, then no interrupt is raised.

I'm going to start the investigation by adding trace level messages to the radio driver to compare register access between modes that work and modes that don't.

cjhdev commented 4 years ago

I've found that in 0.4.0 the SX1276 radio driver writes to RegPllHop instead of RegTcxo. This is because the address for RegTcxo is different between 1272 and 1276.

I'm not sure what that does to the transceiver, but I know for sure it means that the XTAL isn't configured properly. Fixing this register access seems to fix the problem.

cjhdev commented 4 years ago

Actually, this bug appears to caused by the MBED event queue. I can't see how I'm misusing this feature so I will simply remove it as a dependency in the wrapper.

cjhdev commented 4 years ago

Fixed in 0.4.2