diff --git a/examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino b/examples/SX127x/SX127x_Channel_Activity_Detection_Blocking/SX127x_Channel_Activity_Detection_Blocking.ino similarity index 58% rename from examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino rename to examples/SX127x/SX127x_Channel_Activity_Detection_Blocking/SX127x_Channel_Activity_Detection_Blocking.ino index ad7126d4..6a23001a 100644 --- a/examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino +++ b/examples/SX127x/SX127x_Channel_Activity_Detection_Blocking/SX127x_Channel_Activity_Detection_Blocking.ino @@ -1,19 +1,24 @@ /* - RadioLib SX127x Channel Activity Detection Example + RadioLib SX127x Blocking Channel Activity Detection Example - This example scans the current LoRa channel and detects - valid LoRa preambles. Preamble is the first part of - LoRa transmission, so this can be used to check - if the LoRa channel is free, or if you should start - receiving a message. + This example scans the current LoRa channel and detects + valid LoRa preambles. Preamble is the first part of + LoRa transmission, so this can be used to check + if the LoRa channel is free, or if you should start + receiving a message. - Other modules from SX127x/RFM9x family can also be used. + Other modules from SX127x/RFM9x family can also be used. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---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#sx127xrfm9x---lora-modem + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library diff --git a/examples/SX127x/SX127x_Receive/SX127x_Receive.ino b/examples/SX127x/SX127x_Receive_Blocking/SX127x_Receive_Blocking.ino similarity index 72% rename from examples/SX127x/SX127x_Receive/SX127x_Receive.ino rename to examples/SX127x/SX127x_Receive_Blocking/SX127x_Receive_Blocking.ino index e67fbc82..bdfae6d5 100644 --- a/examples/SX127x/SX127x_Receive/SX127x_Receive.ino +++ b/examples/SX127x/SX127x_Receive_Blocking/SX127x_Receive_Blocking.ino @@ -1,23 +1,28 @@ /* - RadioLib SX127x Receive Example + RadioLib SX127x Blocking Receive Example - This example listens for LoRa transmissions using SX127x 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 SX127x 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 SX127x/RFM9x family can also be used. + Other modules from SX127x/RFM9x family can also be used. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem + 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 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#sx127xrfm9x---lora-modem + + 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("[SX1278] 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/SX127x/SX127x_Transmit/SX127x_Transmit.ino b/examples/SX127x/SX127x_Transmit_Blocking/SX127x_Transmit_Blocking.ino similarity index 70% rename from examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino rename to examples/SX127x/SX127x_Transmit_Blocking/SX127x_Transmit_Blocking.ino index f8c0533a..467b11e9 100644 --- a/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino +++ b/examples/SX127x/SX127x_Transmit_Blocking/SX127x_Transmit_Blocking.ino @@ -1,19 +1,23 @@ /* - RadioLib SX127x Transmit Example + RadioLib SX127x Blocking Transmit Example - This example transmits packets using SX1278 LoRa radio module. - Each packet contains up to 255 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 SX1278 LoRa radio module. + Each packet contains up to 255 bytes of data, in the form of: + - Arduino String + - null-terminated char array (C-string) + - arbitrary binary data (byte array) - Other modules from SX127x/RFM9x family can also be used. + Other modules from SX127x/RFM9x family can also be used. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---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#sx127xrfm9x---lora-modem + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library @@ -55,15 +59,15 @@ void setup() { */ } +// counter to keep track of transmitted packets +int count = 0; + void loop() { Serial.print(F("[SX1278] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to // 255 characters long - // NOTE: transmit() is a blocking method! - // See example SX127x_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/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino b/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino index b0551083..640eec5a 100644 --- a/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino +++ b/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino @@ -1,20 +1,20 @@ /* - RadioLib SX127x Transmit with Interrupts Example + RadioLib SX127x Transmit with Interrupts Example - This example transmits LoRa packets with one second delays - between them. Each packet contains up to 255 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 255 bytes + of data, in the form of: + - Arduino String + - null-terminated char array (C-string) + - arbitrary binary data (byte array) - Other modules from SX127x/RFM9x family can also be used. + Other modules from SX127x/RFM9x family can also be used. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---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 @@ -63,7 +63,7 @@ void setup() { /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - state = radio.startTransmit(byteArr, 8); + transmissionState = radio.startTransmit(byteArr, 8); */ } @@ -115,13 +115,13 @@ void loop() { // you can transmit C-string or Arduino string up to // 255 characters long - transmissionState = radio.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World! #" + String(count++)); // you can also transmit byte array up to 255 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = radio.startTransmit(byteArr, 8); + transmissionState = radio.startTransmit(byteArr, 8); */ } }