sandeepmistry / arduino-LoRa

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

Add LoRaClass::rxSignalDetected(). #574

Open toyo opened 2 years ago

toyo commented 2 years ago

Added function LoRaClass::rxSignalDetected() returns true when LoRa carrier is detected.

If you want to avoid collision, you should not transmit during this function returns true.

bobricius commented 1 year ago

Thanks! Amazing, this function I searching 2years, is much better and simpler than CAD

halukmy commented 1 year ago

awesome! can you show some examples please? thanks

morganrallen commented 1 year ago

Right, in addition to adding the function to API.md and example should be provided. It could be as simple as calling this function in the loop and displaying "Incoming message" if it returns true. In theory, a message should arrive after this becomes true.

IoTThinks commented 5 months ago

Wow, so great Pull Request. Hope it get reviewed and merged soon.

Let me test the Pull Request this weekend.

morganrallen commented 5 months ago

Also trying to make some time to check this out. But also would like some clarification on this. @toyo are you using this to detect network activity? From my reading of the datasheet I feel like this isn't working the way some people think it is. Adding an example (and update API.md) to this PR would go a long way to getting it merged.

Quoting @bobricius from issue #514

this status bit is documented in datasheet with les than one sentence

While correct, this sentence reads...

The state of the LoRa modem is accessible with the ModemStatus bits in RegModemStat. They can mostly used for debug in Rx mode and the useful indicators are...

Note that it says for debug in Rx mode. I do not believe this method is actually used for activity detection, as I'm guessing you need to put the radio into RX mode first, so why not just use CAD(*)?

@IoTThinks

Hope it get reviewed and merged soon.

Feel free to amend this PR with an example and API update

*) CAD has been merged, but I realized last night a new release hasn't been made since it was. I will make a new release in the next day or so.

toyo commented 5 months ago

@toyo are you using this to detect network activity?

Yes. works with SX1278. It returns true from when it has decoded preamble to the signal end. So, it returns false if it cannot decode preamble correctly.

morganrallen commented 5 months ago

@toyo do you put it into receive mode first?

toyo commented 5 months ago

@toyo do you put it into receive mode first?

Yes, of course.