[SX127x] Fixed CAD interrupt example

This commit is contained in:
jgromes 2022-10-23 20:40:13 +02:00
parent 1316a805f3
commit c3fa027108

View file

@ -30,11 +30,9 @@ SX1278 radio = new Module(10, 2, 9, 3);
// https://github.com/jgromes/RadioShield
//SX1278 radio = RadioShield.ModuleA;
// save state between loops
int scanState = RADIOLIB_ERR_NONE;
void setup() {
Serial.begin(9600);
// Serial port speed must be high enough for this example
Serial.begin(115200);
// initialize SX1278 with default settings
Serial.print(F("[SX1278] Initializing ... "));
@ -110,22 +108,21 @@ void setFlagDetected(void) {
}
void loop() {
// check if we got a preamble
if(detectedFlag) {
// check if we need to restart channel activity detection
if(detectedFlag || timeoutFlag) {
// disable the interrupt service routine while
// processing the data
enableInterrupt = false;
// reset flag
detectedFlag = false;
// LoRa preamble was detected
Serial.print(F("[SX1278] Preamble detected!"));
}
// check if we need to restart channel activity detection
if(detectedFlag || timeoutFlag) {
// check if we got a preamble
if(detectedFlag) {
// LoRa preamble was detected
Serial.println(F("[SX1278] Preamble detected!"));
} else {
// nothing was detected
Serial.println(F("[SX1278] Channel free!"));
}
// start scanning the channel
Serial.print(F("[SX1278] Starting scan for LoRa preamble ... "));
@ -138,5 +135,13 @@ void loop() {
Serial.println(state);
}
// reset flags
timeoutFlag = false;
detectedFlag = false;
// enable interrupts again
enableInterrupt = true;
}
}