sandeepmistry / arduino-LoRa

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

Add setRxSingleTimeout(...) #576

Open marius-ne opened 2 years ago

marius-ne commented 2 years ago

Dear LoRa Contributors,

first, thanks for your wonderful work! I implemented your library myself and was very happy with it, except that you couldn't change the timeout for the Rx Single Mode. So I went ahead and added that.

I hope you are happy with my contribution.

Best regards Marius

marius-ne commented 2 years ago

Setting a timeout of 1023 symbols with a symbol duration of 1.024 ms (2^SF / BW) would result in a maximum timeout of approximately 1 second (precisely 1.048 s). After that the Timeout Interrupt would be triggered.

Kongduino commented 2 years ago

Just one nitpick. REG_MODEM_CONFIG_2 contains only two bits of the timeout, ie bits 9 and 1 in position 1 and 0. You should probably do something like this to be on the safe side:


writeRegister(REG_MODEM_CONFIG_2, readRegister(REG_MODEM_CONFIG_2) | ((symbols >> 8)&0x03));
marius-ne commented 2 years ago

I think that's cared for by the input check, the maximum value is 10 bits long, so the other values in REG_MODEM_CONFIG_2 will not be affected.