37 lines
769 B
C++
37 lines
769 B
C++
|
|
#include <LoRa.h>
|
|
#include "utilities.h"
|
|
|
|
void setup()
|
|
{
|
|
initBoard();
|
|
// When the power is turned on, a delay is required.
|
|
delay(1500);
|
|
|
|
Serial.println("LoRa Receiver");
|
|
|
|
LoRa.setPins(RADIO_CS_PIN, RADIO_RST_PIN, RADIO_DI0_PIN);
|
|
if (!LoRa.begin(868E6)) {
|
|
Serial.println("Starting LoRa failed!");
|
|
while (1);
|
|
}
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
// try to parse packet
|
|
int packetSize = LoRa.parsePacket();
|
|
if (packetSize) {
|
|
// received a packet
|
|
Serial.print("Received packet '");
|
|
|
|
// read packet
|
|
while (LoRa.available()) {
|
|
Serial.print((char)LoRa.read());
|
|
}
|
|
|
|
// print RSSI of packet
|
|
Serial.print("' with RSSI ");
|
|
Serial.println(LoRa.packetRssi());
|
|
}
|
|
}
|