diff --git a/tasmota/tasmota_xdrv_driver/xdrv_73_3_lora_sx127x.ino b/tasmota/tasmota_xdrv_driver/xdrv_73_3_lora_sx127x.ino index ba1147b79..ab789dbea 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_73_3_lora_sx127x.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_73_3_lora_sx127x.ino @@ -27,8 +27,11 @@ * - LoRa_DIO0 \*********************************************************************************************/ +//#define USE_LORA_SX127X_CAD + #include // extern LoRaClass LoRa; +#ifdef USE_LORA_SX127X_CAD void LoraOnCadDoneSx127x(boolean signalDetected) { if (signalDetected) { // detect preamble #ifdef USE_LORA_DEBUG @@ -39,6 +42,7 @@ void LoraOnCadDoneSx127x(boolean signalDetected) { LoRa.channelActivityDetection(); // try next activity dectection } } +#endif // USE_LORA_SX127X_CAD // this function is called when a complete packet is received by the module void LoraOnReceiveSx127x(int packet_size) { @@ -69,9 +73,9 @@ int LoraReceiveSx127x(char* data) { Lora.rssi = LoRa.packetRssi(); Lora.snr = LoRa.packetSnr(); - +#ifdef USE_LORA_SX127X_CAD LoRa.channelActivityDetection(); // put the radio into CAD mode - +#endif // USE_LORA_SX127X_CAD return packet_size; } @@ -112,10 +116,13 @@ bool LoraInitSx127x(void) { LoRa.setPins(Pin(GPIO_LORA_CS), Pin(GPIO_LORA_RST), Pin(GPIO_LORA_DI0)); if (LoRa.begin(Lora.frequency * 1000 * 1000)) { LoraConfigSx127x(); - LoRa.onCadDone(LoraOnCadDoneSx127x); // register the channel activity dectection callback LoRa.onReceive(LoraOnReceiveSx127x); -// LoRa.receive(); +#ifdef USE_LORA_SX127X_CAD + LoRa.onCadDone(LoraOnCadDoneSx127x); // register the channel activity dectection callback LoRa.channelActivityDetection(); +#else + LoRa.receive(); +#endif // USE_LORA_SX127X_CAD return true; } return false; diff --git a/tasmota/tasmota_xdrv_driver/xdrv_73_9_lora.ino b/tasmota/tasmota_xdrv_driver/xdrv_73_9_lora.ino index 64d73bb79..3c0d8d979 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_73_9_lora.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_73_9_lora.ino @@ -76,6 +76,7 @@ void LoraInit(void) { LoraDefaults(); char hardware[20]; + strcpy_P(hardware, PSTR("Not")); if (false) { } #ifdef USE_LORA_SX127X @@ -104,9 +105,6 @@ void LoraInit(void) { } } #endif // USE_LORA_SX126X - else { - strcpy_P(hardware, PSTR("Not")); - } AddLog(LOG_LEVEL_DEBUG, PSTR("LOR: %s initialized"), hardware); } }