[STM32WL] Renamed basic examples to _Blocking

This commit is contained in:
jgromes 2023-06-24 22:03:28 +02:00
parent 06529844c3
commit 9bad00ed39
3 changed files with 62 additions and 53 deletions

View file

@ -1,5 +1,5 @@
/* /*
RadioLib STM32WLx Receive Example RadioLib STM32WLx Blocking Receive Example
This example listens for LoRa transmissions using STM32WL MCU with This example listens for LoRa transmissions using STM32WL MCU with
integrated (SX126x) LoRa radio. integrated (SX126x) LoRa radio.
@ -17,6 +17,11 @@
or standalone STM32WL, some configuration such as TCXO voltage and or standalone STM32WL, some configuration such as TCXO voltage and
RF switch control may have to be adjusted. RF switch control may have to be adjusted.
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 For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
@ -75,9 +80,6 @@ void loop() {
Serial.print(F("[STM32WL] Waiting for incoming transmission ... ")); Serial.print(F("[STM32WL] Waiting for incoming transmission ... "));
// you can receive data as an Arduino String // 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; String str;
int state = radio.receive(str); int state = radio.receive(str);

View file

@ -1,5 +1,5 @@
/* /*
RadioLib STM32WLx Transmit Example RadioLib STM32WLx Blocking Transmit Example
This example transmits packets using STM32WL MCU with integrated This example transmits packets using STM32WL MCU with integrated
(SX126x) LoRa radio. (SX126x) LoRa radio.
@ -13,6 +13,10 @@
or standalone STM32WL, some configuration such as TCXO voltage and or standalone STM32WL, some configuration such as TCXO voltage and
RF switch control may have to be adjusted. RF switch control may have to be adjusted.
Using blocking transmit is not recommended, as it will lead
to inefficient use of processor time!
Instead, interrupt transmit is recommended.
For default module settings, see the wiki page For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
@ -67,15 +71,15 @@ void setup() {
} }
} }
// counter to keep track of transmitted packets
int count = 0;
void loop() { void loop() {
Serial.print(F("[STM32WL] Transmitting packet ... ")); Serial.print(F("[STM32WL] Transmitting packet ... "));
// you can transmit C-string or Arduino string up to // you can transmit C-string or Arduino string up to
// 256 characters long // 256 characters long
// NOTE: transmit() is a blocking method! int state = radio.transmit("Hello World! #" + String(count++));
// See example STM32WLx_Transmit_Interrupt for details
// on non-blocking transmission method.
int state = radio.transmit("Hello World!");
// you can also transmit byte array up to 256 bytes long // you can also transmit byte array up to 256 bytes long
/* /*

View file

@ -95,6 +95,9 @@ void setFlag(void) {
transmittedFlag = true; transmittedFlag = true;
} }
// counter to keep track of transmitted packets
int count = 0;
void loop() { void loop() {
// check if the previous transmission finished // check if the previous transmission finished
if(transmittedFlag) { if(transmittedFlag) {
@ -128,13 +131,13 @@ void loop() {
// you can transmit C-string or Arduino string up to // you can transmit C-string or Arduino string up to
// 256 characters long // 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 // you can also transmit byte array up to 256 bytes long
/* /*
byte byteArr[] = {0x01, 0x23, 0x45, 0x67, byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
0x89, 0xAB, 0xCD, 0xEF}; 0x89, 0xAB, 0xCD, 0xEF};
int state = radio.startTransmit(byteArr, 8); transmissionState = radio.startTransmit(byteArr, 8);
*/ */
} }
} }