From 3a07f0aa022d01e60f2895088812cb5bc8eeef39 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 24 Jun 2023 22:17:13 +0200 Subject: [PATCH] [SX128x] Renamed basic examples to _Blocking --- ...x_Channel_Activity_Detection_Blocking.ino} | 21 ++++++----- .../SX128x_Receive_Blocking.ino} | 36 ++++++++++--------- .../SX128x_Transmit_Blocking.ino} | 34 ++++++++++-------- .../SX128x_Transmit_Interrupt.ino | 31 ++++++++-------- 4 files changed, 68 insertions(+), 54 deletions(-) rename examples/SX128x/{SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino => SX128x_Channel_Activity_Detection_Blocking/SX128x_Channel_Activity_Detection_Blocking.ino} (65%) rename examples/SX128x/{SX128x_Receive/SX128x_Receive.ino => SX128x_Receive_Blocking/SX128x_Receive_Blocking.ino} (74%) rename examples/SX128x/{SX128x_Transmit/SX128x_Transmit.ino => SX128x_Transmit_Blocking/SX128x_Transmit_Blocking.ino} (70%) diff --git a/examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino b/examples/SX128x/SX128x_Channel_Activity_Detection_Blocking/SX128x_Channel_Activity_Detection_Blocking.ino similarity index 65% rename from examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino rename to examples/SX128x/SX128x_Channel_Activity_Detection_Blocking/SX128x_Channel_Activity_Detection_Blocking.ino index 96b1cb72..fef3ccc0 100644 --- a/examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino +++ b/examples/SX128x/SX128x_Channel_Activity_Detection_Blocking/SX128x_Channel_Activity_Detection_Blocking.ino @@ -1,16 +1,21 @@ /* - RadioLib SX128x Channel Activity Detection Example + RadioLib SX128x Blocking Channel Activity Detection Example - This example uses SX1280 to scan the current LoRa - channel and detect ongoing LoRa transmissions. + This example uses SX1280 to scan the current LoRa + channel and detect ongoing LoRa transmissions. - Other modules from SX128x family can also be used. + Other modules from SX128x family can also be used. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---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#sx128x---lora-modem + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library diff --git a/examples/SX128x/SX128x_Receive/SX128x_Receive.ino b/examples/SX128x/SX128x_Receive_Blocking/SX128x_Receive_Blocking.ino similarity index 74% rename from examples/SX128x/SX128x_Receive/SX128x_Receive.ino rename to examples/SX128x/SX128x_Receive_Blocking/SX128x_Receive_Blocking.ino index 28dc8047..2ba27130 100644 --- a/examples/SX128x/SX128x_Receive/SX128x_Receive.ino +++ b/examples/SX128x/SX128x_Receive_Blocking/SX128x_Receive_Blocking.ino @@ -1,23 +1,28 @@ /* - RadioLib SX128x Receive Example + RadioLib SX128x 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 - on both transmitter and receiver: - - carrier frequency - - bandwidth - - spreading factor - - coding rate - - sync word - - preamble length + This example listens for LoRa transmissions using SX126x Lora modules. + To successfully receive data, the following settings have to be the same + on both transmitter and receiver: + - carrier frequency + - bandwidth + - spreading factor + - coding rate + - sync word + - preamble length - Other modules from SX128x family can also be used. + Other modules from SX128x 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#sx128x---lora-modem + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---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 @@ -53,9 +58,6 @@ void loop() { Serial.print(F("[SX1280] 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/SX128x/SX128x_Transmit/SX128x_Transmit.ino b/examples/SX128x/SX128x_Transmit_Blocking/SX128x_Transmit_Blocking.ino similarity index 70% rename from examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino rename to examples/SX128x/SX128x_Transmit_Blocking/SX128x_Transmit_Blocking.ino index e525698a..cc222a61 100644 --- a/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino +++ b/examples/SX128x/SX128x_Transmit_Blocking/SX128x_Transmit_Blocking.ino @@ -1,19 +1,23 @@ /* - RadioLib SX128x Transmit Example + RadioLib SX128x Blocking Transmit Example - This example transmits packets using SX1280 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 SX1280 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 SX128x family can also be used. + Other modules from SX128x family can also be used. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---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#sx128x---lora-modem + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library @@ -62,15 +66,15 @@ void setup() { */ } +// counter to keep track of transmitted packets +int count = 0; + void loop() { Serial.print(F("[SX1280] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to // 256 characters long - // NOTE: transmit() is a blocking method! - // See example SX128x_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/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino b/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino index 9a490030..21252f62 100644 --- a/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino +++ b/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino @@ -1,20 +1,20 @@ /* - RadioLib SX128x Transmit with Interrupts Example + RadioLib SX128x 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 SX128x family can also be used. + Other modules from SX128x family can also be used. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---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 @@ -82,6 +82,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) { @@ -111,13 +114,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); */ } }