diff --git a/examples/SX128x/SX128x_Channel_Activity_Detection_Interrupt/SX128x_Channel_Activity_Detection_Interrupt.ino b/examples/SX128x/SX128x_Channel_Activity_Detection_Interrupt/SX128x_Channel_Activity_Detection_Interrupt.ino index 8a57e181b..8e3ab594a 100644 --- a/examples/SX128x/SX128x_Channel_Activity_Detection_Interrupt/SX128x_Channel_Activity_Detection_Interrupt.ino +++ b/examples/SX128x/SX128x_Channel_Activity_Detection_Interrupt/SX128x_Channel_Activity_Detection_Interrupt.ino @@ -31,6 +31,21 @@ SX1280 radio = new Module(10, 2, 3, 9); Radio radio = new RadioModule(); */ +// flag to indicate that a packet was detected or CAD timed out +volatile bool scanFlag = false; + +// this function is called when a complete packet +// is received by the module +// IMPORTANT: this function MUST be 'void' type +// and MUST NOT have any arguments! +#if defined(ESP8266) || defined(ESP32) + ICACHE_RAM_ATTR +#endif +void setFlag(void) { + // something happened, set the flag + scanFlag = true; +} + void setup() { Serial.begin(9600); @@ -60,21 +75,6 @@ void setup() { } } -// flag to indicate that a packet was detected or CAD timed out -volatile bool scanFlag = false; - -// this function is called when a complete packet -// is received by the module -// IMPORTANT: this function MUST be 'void' type -// and MUST NOT have any arguments! -#if defined(ESP8266) || defined(ESP32) - ICACHE_RAM_ATTR -#endif -void setFlag(void) { - // something happened, set the flag - scanFlag = true; -} - void loop() { // check if the flag is set if(scanFlag) { diff --git a/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino b/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino index 0ca0406ca..984db2428 100644 --- a/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino +++ b/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino @@ -39,6 +39,21 @@ SX1280 radio = new Module(10, 2, 3, 9); Radio radio = new RadioModule(); */ +// flag to indicate that a packet was received +volatile bool receivedFlag = false; + +// this function is called when a complete packet +// is received by the module +// IMPORTANT: this function MUST be 'void' type +// and MUST NOT have any arguments! +#if defined(ESP8266) || defined(ESP32) + ICACHE_RAM_ATTR +#endif +void setFlag(void) { + // we got a packet, set the flag + receivedFlag = true; +} + void setup() { Serial.begin(9600); @@ -79,21 +94,6 @@ void setup() { // radio.scanChannel(); } -// flag to indicate that a packet was received -volatile bool receivedFlag = false; - -// this function is called when a complete packet -// is received by the module -// IMPORTANT: this function MUST be 'void' type -// and MUST NOT have any arguments! -#if defined(ESP8266) || defined(ESP32) - ICACHE_RAM_ATTR -#endif -void setFlag(void) { - // we got a packet, set the flag - receivedFlag = true; -} - void loop() { // check if the flag is set if(receivedFlag) { diff --git a/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino b/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino index 1c760d5a2..340efd1d5 100644 --- a/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino +++ b/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino @@ -38,6 +38,21 @@ Radio radio = new RadioModule(); // save transmission state between loops int transmissionState = RADIOLIB_ERR_NONE; +// flag to indicate that a packet was sent +volatile bool transmittedFlag = false; + +// this function is called when a complete packet +// is transmitted by the module +// IMPORTANT: this function MUST be 'void' type +// and MUST NOT have any arguments! +#if defined(ESP8266) || defined(ESP32) + ICACHE_RAM_ATTR +#endif +void setFlag(void) { + // we sent a packet, set the flag + transmittedFlag = true; +} + void setup() { Serial.begin(9600); @@ -71,21 +86,6 @@ void setup() { */ } -// flag to indicate that a packet was sent -volatile bool transmittedFlag = false; - -// this function is called when a complete packet -// is transmitted by the module -// IMPORTANT: this function MUST be 'void' type -// and MUST NOT have any arguments! -#if defined(ESP8266) || defined(ESP32) - ICACHE_RAM_ATTR -#endif -void setFlag(void) { - // we sent a packet, set the flag - transmittedFlag = true; -} - // counter to keep track of transmitted packets int count = 0;