-
-
Notifications
You must be signed in to change notification settings - Fork 651
CAD detection #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CAD detection #50
Conversation
Fortunately, their values are the same as in RegIrqFlagsMask but in the code we access register RegIrqFlags.
Made in binary notation to be more easily checkeable against the data sheet. This way it's possible to handle CAD (channel activity detection) the following way: - setInterruptMode(0, LORA_IRQ_MODE_CADDONE) - configure interrupt service routine in Arduino for LoRa DIO0 pin - cad() - LoRa.readInterrupts() & LORA_IRQ_FLAG_CAD_DETECTED
Many times these functions run in a while(); loop and that causes a lot of unnecessary writes to registers when nothing happens in the LoRa chip. Save some time by writing when only it's necessary.
Contrary to the data sheet, it's not possible to change to CAD mode from e.g. RXSINGLE. Going to STANDBY first makes it happen.
It's required everywhere where the symbol length exceeds 16 ms
The valid range is between 0x11-0xff
@szotsaki thanks for submitting! Could you please explain the use case for this feature and add an example sketch. In general, I'm not too keen to expose interrupt flags to the user. |
Yes, of course, I'll upload an example in a few days. Right now the current design closes the implementation of the IRQ handling and there're some problems with it, too. Like it spends way too much time in the ISR. Normally, only a variable assignment should be done there but now a complete, many-line function is written inside (in case of I also think it's better to give the user the freedom how he wants to handle his interrupts. Do we want to create a separate function for I think these are the two main reasons I'd support having the user's responsibility to write his interrupt code. However, I accept any good reasoning against my view :). Some examples for
|
Sorry for the delay, I uploaded an example how to use the interrupts and CAD detection. I tried to document as much as possible. |
Thanks for the updates and clarification. On first glance the new API's expose too much of the underlying features of the radios to the sketch, so are not consistent with the current library APIs. |
@szotsaki where is sample of cad detection? Thanks |
It's in commit 6f254b0 (in directory |
@szotsaki i cant find it on your repo or anywhere on github :) when will you upload? |
It's a pull request so it will be available in the Please, if you find any issues, report it here. |
@szotsaki thanks for super cool share!! your the best bro |
@szotsaki thanks for awesome repo! can you share a simple example for cad detection and connection please thanks bro |
Please use the |
Very nice my friend ! i remember i visit there before, i believe together we will create better repo than lorawan:) Thanks Mr. @szotsaki |
In trying to test this I was unable to get it to work but I'm really interested in getting CAD support integrated. Things that need to be done or talked about.
Nice work so far @szotsaki, look forward to this landing * I believe this commit contains the conflicting code f5cae9c |
I migrated this pull request and all my other, long-pending pull requests from here to my own repo into the master branch (effectively creating a fork of this repository). You can find it here: https://github.com/szotsaki/arduino-LoRa I use CAD detection successfully so if anything doesn't work for you, please tell me (or open a bug report in my repo) and I'll try to help you.
Done when merged all branches together into master.
Could you please elaborate on this one a bit? I'd like to use common coding standard as much as possible, please point me where I diverged.
I think you mean
Hmm, unfortunately I don't have anything in my mind right now how I could do that while keeping its flexibility. Do you have anything in mind?
In my opinion this is not a good design choice because
Good news, already added :). Just use the following three-liner (with comments for you): pinMode(LORA_DIO0_PIN_TO_ARDUINO, INPUT);
setInterruptMode(0 /*DIO0*/, LORA_IRQ_DIO0_CADDONE /*CAD_DONE on DIO0*/);
attachInterrupt(digitalPinToInterrupt(LORA_DIO0_PIN_TO_ARDUINO), your_irq_fn, RISING); If you have any suggestion how to improve the code, I'm glad to hear that. Thank you for the suggestions so far! @halukmy An example for CAD detection with interrupts can be found here. |
@szotsaki awesomeeeeee, can you share an cad example with us? |
It's possible to handle LoRa CAD (channel activity detection) the following way via interrupts:
LoRa.setInterruptMode(0, LORA_IRQ_MODE_CADDONE)
LoRa.cad()
LoRa.readInterrupts() & LORA_IRQ_FLAG_CAD_DETECTED
LoRa.clearInterrupts(LORA_IRQ_FLAG_CAD_DETECTED | LORA_IRQ_FLAG_CAD_DONE);
I didn't want to add an internal IRQ handling routine (like
handleDio0RiseRx
) because that would be too slow for an ISR routine or simply not ideal for someone who wants to implement this in his/her own taste.