arduino/Examples/LoRaTests/lib/arduino-LoRa/examples/LoRaSenderNonBlocking/LoRaSenderNonBlocking.ino

36 lines
681 B
Arduino
Raw Normal View History

2019-06-21 16:12:29 +00:00
#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++;
}