How to calculate the best CAD settings

Hello,
i am using a module RAK3172 with a program on C and with custom protocol, i have a connection between two devices.
In the semtech documentation I saw parameters for CAD (SF 7, BW 125):

  cadSettings.cadDetMin = 10;
  cadSettings.cadDetPeak = 22;
  cadSettings.cadExitMode = LORA_CAD_RX;
  cadSettings.cadSymbolNum = LORA_CAD_02_SYMBOL;
  cadSettings.cadTimeout = 10000;//10000 * 15.625 us = 156 ms

but these parameters depend on Lora’s settings (SF and BW). And also I didn’t see any information about cadTimeout.

As I understand - we have to turn on devices and tune DetMin and DetPeak for best performance

I have a question - how to calculate correctly CAD setting?
We can test it on our devices and set the best settings, but this is possible only for test devices, not for all in the city.

How to get the best settings for CAD? is it possible to calculate it with some formula?

with regards

There is a document available at Semtech ==> Introduction to Channel Activity

The Channel Activity Detection document (Semtech as well) has some info as well.

To calculate the best CAD settings, consider adjusting parameters like cadDetMin, cadDetPeak, and cadTimeout based on the LoRa settings (SF and BW). Real-world testing is key, as these settings can vary depending on your environment. Have you tried testing different Spreading Factor (SF) and Bandwidth (BW) combinations to find the optimal values for your use case?

Had been working with this RAK article: Channel Activity Detection: Ensuring Your LoRa® Packets Are Sent. It appears to be mostly the same as the first article listed by @beegee.

Created a program that appears to work well using those techniques:
CAD_Test.ino (3.5 KB)

That program is running on RAK19001/RAK11310.

Glad for any comments.

At issue with the basic program is that it does not cope with “channel busy”. Here is my first put on solving that issue:
CAD_Test.ino (4.7 KB)
LoRaP2P_RX_modified.ino (3.4 KB)

Glad for any discussion.

A doctoral dissertation and sample code on that topic is referenced at GitHub - DSG-UPC/Arduino-LoRa-Mesh: A series of simple Arduino projects related to LoRa and mesh networking. The code can likely be transitioned to RAKwireless.