From 9bad00ed39cb6cd36297a6ee984a4f329eb92246 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 24 Jun 2023 22:03:28 +0200 Subject: [PATCH] [STM32WL] Renamed basic examples to _Blocking --- .../STM32WLx_Receive_Blocking.ino} | 44 ++++++++++--------- .../STM32WLx_Transmit_Blocking.ino} | 42 ++++++++++-------- .../STM32WLx_Transmit_Interrupt.ino | 29 ++++++------ 3 files changed, 62 insertions(+), 53 deletions(-) rename examples/STM32WLx/{STM32WLx_Receive/STM32WLx_Receive.ino => STM32WLx_Receive_Blocking/STM32WLx_Receive_Blocking.ino} (73%) rename examples/STM32WLx/{STM32WLx_Transmit/STM32WLx_Transmit.ino => STM32WLx_Transmit_Blocking/STM32WLx_Transmit_Blocking.ino} (71%) diff --git a/examples/STM32WLx/STM32WLx_Receive/STM32WLx_Receive.ino b/examples/STM32WLx/STM32WLx_Receive_Blocking/STM32WLx_Receive_Blocking.ino similarity index 73% rename from examples/STM32WLx/STM32WLx_Receive/STM32WLx_Receive.ino rename to examples/STM32WLx/STM32WLx_Receive_Blocking/STM32WLx_Receive_Blocking.ino index b5f15965..ae2cbdb1 100644 --- a/examples/STM32WLx/STM32WLx_Receive/STM32WLx_Receive.ino +++ b/examples/STM32WLx/STM32WLx_Receive_Blocking/STM32WLx_Receive_Blocking.ino @@ -1,27 +1,32 @@ /* - RadioLib STM32WLx Receive Example + RadioLib STM32WLx Blocking Receive Example - This example listens for LoRa transmissions using STM32WL MCU with - integrated (SX126x) LoRa radio. + This example listens for LoRa transmissions using STM32WL MCU with + integrated (SX126x) LoRa radio. - 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 + 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 assumes Nucleo WL55JC1 is used. For other Nucleo boards - or standalone STM32WL, some configuration such as TCXO voltage and - RF switch control may have to be adjusted. + This example assumes Nucleo WL55JC1 is used. For other Nucleo boards + or standalone STM32WL, some configuration such as TCXO voltage and + RF switch control may have to be adjusted. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---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#sx126x---lora-modem + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library @@ -75,9 +80,6 @@ void loop() { Serial.print(F("[STM32WL] 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/STM32WLx/STM32WLx_Transmit/STM32WLx_Transmit.ino b/examples/STM32WLx/STM32WLx_Transmit_Blocking/STM32WLx_Transmit_Blocking.ino similarity index 71% rename from examples/STM32WLx/STM32WLx_Transmit/STM32WLx_Transmit.ino rename to examples/STM32WLx/STM32WLx_Transmit_Blocking/STM32WLx_Transmit_Blocking.ino index 7455cafd..961a4754 100644 --- a/examples/STM32WLx/STM32WLx_Transmit/STM32WLx_Transmit.ino +++ b/examples/STM32WLx/STM32WLx_Transmit_Blocking/STM32WLx_Transmit_Blocking.ino @@ -1,23 +1,27 @@ /* - RadioLib STM32WLx Transmit Example + RadioLib STM32WLx Blocking Transmit Example - This example transmits packets using STM32WL MCU with integrated - (SX126x) LoRa radio. + This example transmits packets using STM32WL MCU with integrated + (SX126x) LoRa radio. - 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 assumes Nucleo WL55JC1 is used. For other Nucleo boards - or standalone STM32WL, some configuration such as TCXO voltage and - RF switch control may have to be adjusted. + 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 assumes Nucleo WL55JC1 is used. For other Nucleo boards + or standalone STM32WL, some configuration such as TCXO voltage and + RF switch control may have to be adjusted. - 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 @@ -67,15 +71,15 @@ void setup() { } } +// counter to keep track of transmitted packets +int count = 0; + void loop() { Serial.print(F("[STM32WL] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to // 256 characters long - // NOTE: transmit() is a blocking method! - // See example STM32WLx_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/STM32WLx/STM32WLx_Transmit_Interrupt/STM32WLx_Transmit_Interrupt.ino b/examples/STM32WLx/STM32WLx_Transmit_Interrupt/STM32WLx_Transmit_Interrupt.ino index 900e52d2..bcd3f718 100644 --- a/examples/STM32WLx/STM32WLx_Transmit_Interrupt/STM32WLx_Transmit_Interrupt.ino +++ b/examples/STM32WLx/STM32WLx_Transmit_Interrupt/STM32WLx_Transmit_Interrupt.ino @@ -1,18 +1,18 @@ /* - RadioLib STM32WLx Transmit with Interrupts Example + RadioLib STM32WLx 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) - 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 @@ -95,6 +95,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) { @@ -128,13 +131,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); */ } }