From 24be1747d01555eb6c5db171084956735ab3d06c Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 24 Jun 2023 22:12:11 +0200 Subject: [PATCH] [SX126x] Renamed basic examples to _Blocking --- ...x_Channel_Activity_Detection_Blocking.ino} | 25 ++++++++------ .../SX126x_Receive_Blocking.ino} | 10 +++--- .../SX126x_Transmit_Blocking.ino} | 34 +++++++++++-------- .../SX126x_Transmit_Interrupt.ino | 31 +++++++++-------- 4 files changed, 57 insertions(+), 43 deletions(-) rename examples/SX126x/{SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino => SX126x_Channel_Activity_Detection_Blocking/SX126x_Channel_Activity_Detection_Blocking.ino} (64%) rename examples/SX126x/{SX126x_Receive/SX126x_Receive.ino => SX126x_Receive_Blocking/SX126x_Receive_Blocking.ino} (91%) rename examples/SX126x/{SX126x_Transmit/SX126x_Transmit.ino => SX126x_Transmit_Blocking/SX126x_Transmit_Blocking.ino} (71%) diff --git a/examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino b/examples/SX126x/SX126x_Channel_Activity_Detection_Blocking/SX126x_Channel_Activity_Detection_Blocking.ino similarity index 64% rename from examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino rename to examples/SX126x/SX126x_Channel_Activity_Detection_Blocking/SX126x_Channel_Activity_Detection_Blocking.ino index 850347a2..0d2380dd 100644 --- a/examples/SX126x/SX126x_Channel_Activity_Detection/SX126x_Channel_Activity_Detection.ino +++ b/examples/SX126x/SX126x_Channel_Activity_Detection_Blocking/SX126x_Channel_Activity_Detection_Blocking.ino @@ -1,18 +1,23 @@ /* - RadioLib SX126x Channel Activity Detection Example + RadioLib SX126x Blocking Channel Activity Detection Example - This example uses SX1262 to scan the current LoRa - channel and detect ongoing LoRa transmissions. - Unlike SX127x CAD, SX126x can detect any part - of LoRa transmission, not just the preamble. + This example uses SX1262 to scan the current LoRa + channel and detect ongoing LoRa transmissions. + Unlike SX127x CAD, SX126x can detect any part + of LoRa transmission, not just the preamble. - Other modules from SX126x family can also be used. + Other modules from SX126x family can also be used. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem + Using blocking CAD is not recommended, as it will lead + to significant amount of timeouts, inefficient use of processor + time and can some miss packets! + Instead, interrupt CAD is recommended. - For full API reference, see the GitHub Pages - https://jgromes.github.io/RadioLib/ + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library diff --git a/examples/SX126x/SX126x_Receive/SX126x_Receive.ino b/examples/SX126x/SX126x_Receive_Blocking/SX126x_Receive_Blocking.ino similarity index 91% rename from examples/SX126x/SX126x_Receive/SX126x_Receive.ino rename to examples/SX126x/SX126x_Receive_Blocking/SX126x_Receive_Blocking.ino index d00f4f64..75fda8f6 100644 --- a/examples/SX126x/SX126x_Receive/SX126x_Receive.ino +++ b/examples/SX126x/SX126x_Receive_Blocking/SX126x_Receive_Blocking.ino @@ -1,5 +1,5 @@ /* - RadioLib SX126x Receive Example + RadioLib SX126x Blocking Receive Example This example listens for LoRa transmissions using SX126x Lora modules. To successfully receive data, the following settings have to be the same @@ -13,6 +13,11 @@ Other modules from SX126x family can also be used. + Using blocking receive is not recommended, as it will lead + to significant amount of timeouts, inefficient use of processor + time and can some miss packets! + Instead, interrupt receive is recommended. + For default module settings, see the wiki page https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem @@ -56,9 +61,6 @@ void loop() { Serial.print(F("[SX1262] Waiting for incoming transmission ... ")); // you can receive data as an Arduino String - // NOTE: receive() is a blocking method! - // See example ReceiveInterrupt for details - // on non-blocking reception method. String str; int state = radio.receive(str); diff --git a/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino b/examples/SX126x/SX126x_Transmit_Blocking/SX126x_Transmit_Blocking.ino similarity index 71% rename from examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino rename to examples/SX126x/SX126x_Transmit_Blocking/SX126x_Transmit_Blocking.ino index a287034e..a9aa4953 100644 --- a/examples/SX126x/SX126x_Transmit/SX126x_Transmit.ino +++ b/examples/SX126x/SX126x_Transmit_Blocking/SX126x_Transmit_Blocking.ino @@ -1,19 +1,23 @@ /* - RadioLib SX126x Transmit Example + RadioLib SX126x Blocking Transmit Example - This example transmits packets using SX1262 LoRa radio module. - Each packet contains up to 256 bytes of data, in the form of: - - Arduino String - - null-terminated char array (C-string) - - arbitrary binary data (byte array) + This example transmits packets using SX1262 LoRa radio module. + Each packet contains up to 256 bytes of data, in the form of: + - Arduino String + - null-terminated char array (C-string) + - arbitrary binary data (byte array) - Other modules from SX126x family can also be used. + Other modules from SX126x family can also be used. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem + Using blocking transmit is not recommended, as it will lead + to inefficient use of processor time! + Instead, interrupt transmit is recommended. - For full API reference, see the GitHub Pages - https://jgromes.github.io/RadioLib/ + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library @@ -58,15 +62,15 @@ void setup() { */ } +// counter to keep track of transmitted packets +int count = 0; + void loop() { Serial.print(F("[SX1262] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to // 256 characters long - // NOTE: transmit() is a blocking method! - // See example SX126x_Transmit_Interrupt for details - // on non-blocking transmission method. - int state = radio.transmit("Hello World!"); + int state = radio.transmit("Hello World! #" + String(count++)); // you can also transmit byte array up to 256 bytes long /* diff --git a/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino b/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino index 6bf9be2b..20acbcb4 100644 --- a/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino +++ b/examples/SX126x/SX126x_Transmit_Interrupt/SX126x_Transmit_Interrupt.ino @@ -1,20 +1,20 @@ /* - RadioLib SX126x Transmit with Interrupts Example + RadioLib SX126x Transmit with Interrupts Example - This example transmits LoRa packets with one second delays - between them. Each packet contains up to 256 bytes - of data, in the form of: - - Arduino String - - null-terminated char array (C-string) - - arbitrary binary data (byte array) + This example transmits LoRa packets with one second delays + between them. Each packet contains up to 256 bytes + of data, in the form of: + - Arduino String + - null-terminated char array (C-string) + - arbitrary binary data (byte array) - Other modules from SX126x family can also be used. + Other modules from SX126x family can also be used. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem - For full API reference, see the GitHub Pages - https://jgromes.github.io/RadioLib/ + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library @@ -85,6 +85,9 @@ void setFlag(void) { transmittedFlag = true; } +// counter to keep track of transmitted packets +int count = 0; + void loop() { // check if the previous transmission finished if(transmittedFlag) { @@ -118,13 +121,13 @@ void loop() { // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = radio.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World! #" + String(count++)); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = radio.startTransmit(byteArr, 8); + transmissionState = radio.startTransmit(byteArr, 8); */ } }