[SX127x] Fixed CAD interrupt example
This commit is contained in:
parent
1316a805f3
commit
c3fa027108
1 changed files with 21 additions and 16 deletions
|
@ -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;
|
||||
|
||||
// check if we got a preamble
|
||||
if(detectedFlag) {
|
||||
// LoRa preamble was detected
|
||||
Serial.print(F("[SX1278] Preamble detected!"));
|
||||
|
||||
Serial.println(F("[SX1278] Preamble detected!"));
|
||||
} else {
|
||||
// nothing was detected
|
||||
Serial.println(F("[SX1278] Channel free!"));
|
||||
}
|
||||
|
||||
// check if we need to restart channel activity detection
|
||||
if(detectedFlag || timeoutFlag) {
|
||||
// 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue