You've already forked arduino-LoRa
mirror of
https://github.com/sandeepmistry/arduino-LoRa.git
synced 2025-06-15 18:01:42 +03:00
non blocking functions added (#62)
This commit is contained in:
committed by
Sandeep Mistry
parent
07bfead143
commit
9d2a8c9c82
35
examples/LoRaSenderNonBlocking/LoRaSenderNonBlocking.ino
Normal file
35
examples/LoRaSenderNonBlocking/LoRaSenderNonBlocking.ino
Normal file
@ -0,0 +1,35 @@
|
||||
#include <SPI.h>
|
||||
#include <LoRa.h>
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("LoRa Sender non-blocking");
|
||||
|
||||
if (!LoRa.begin(915E6)) {
|
||||
Serial.println("Starting LoRa failed!");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// wait until the radio is ready to send a packet
|
||||
while (LoRa.beginPacket() == 0) {
|
||||
Serial.print("waiting for radio ... ");
|
||||
delay(100);
|
||||
}
|
||||
|
||||
Serial.print("Sending packet non-blocking: ");
|
||||
Serial.println(counter);
|
||||
|
||||
// send in async / non-blocking mode
|
||||
LoRa.beginPacket();
|
||||
LoRa.print("hello ");
|
||||
LoRa.print(counter);
|
||||
LoRa.endPacket(true); // true = async / non-blocking mode
|
||||
|
||||
counter++;
|
||||
}
|
Reference in New Issue
Block a user