|
1 |
| -#include <SPI.h> |
2 |
| -#include <LoRa.h> |
3 |
| - |
4 |
| -#ifdef ARDUINO_SAMD_MKRWAN1300 |
5 |
| -#error "This example is not compatible with the Arduino MKR WAN 1300 board!" |
6 |
| -#endif |
7 |
| - |
8 |
| -void setup() { |
9 |
| - Serial.begin(9600); |
10 |
| - while (!Serial); |
11 |
| - |
12 |
| - Serial.println("LoRa Receiver Callback"); |
13 |
| - |
14 |
| - if (!LoRa.begin(915E6)) { |
15 |
| - Serial.println("Starting LoRa failed!"); |
16 |
| - while (1); |
17 |
| - } |
18 |
| - |
19 |
| - // register the receive callback |
20 |
| - LoRa.onReceive(onReceive); |
21 |
| - |
22 |
| - // put the radio into receive mode |
23 |
| - LoRa.receive(); |
24 |
| -} |
25 |
| - |
26 |
| -void loop() { |
27 |
| - // do nothing |
28 |
| -} |
29 |
| - |
30 |
| -void onReceive(int packetSize) { |
31 |
| - // received a packet |
32 |
| - Serial.print("Received packet '"); |
33 |
| - |
34 |
| - // read packet |
35 |
| - for (int i = 0; i < packetSize; i++) { |
36 |
| - Serial.print((char)LoRa.read()); |
37 |
| - } |
38 |
| - |
39 |
| - // print RSSI of packet |
40 |
| - Serial.print("' with RSSI "); |
41 |
| - Serial.println(LoRa.packetRssi()); |
42 |
| -} |
43 |
| - |
| 1 | +#include <SPI.h> |
| 2 | +#include <LoRa.h> |
| 3 | + |
| 4 | +#ifdef ARDUINO_SAMD_MKRWAN1300 |
| 5 | +#error "This example is not compatible with the Arduino MKR WAN 1300 board!" |
| 6 | +#endif |
| 7 | + |
| 8 | +void setup() { |
| 9 | + Serial.begin(9600); |
| 10 | + while (!Serial); |
| 11 | + |
| 12 | + Serial.println("LoRa Receiver Callback"); |
| 13 | + |
| 14 | + if (!LoRa.begin(915E6)) { |
| 15 | + Serial.println("Starting LoRa failed!"); |
| 16 | + while (1); |
| 17 | + } |
| 18 | + |
| 19 | + // Uncomment the next line to disable the default AGC and set LNA gain, values between 1 - 6 are supported |
| 20 | + // LoRa.setGain(6); |
| 21 | + |
| 22 | + // register the receive callback |
| 23 | + LoRa.onReceive(onReceive); |
| 24 | + |
| 25 | + // put the radio into receive mode |
| 26 | + LoRa.receive(); |
| 27 | +} |
| 28 | + |
| 29 | +void loop() { |
| 30 | + // do nothing |
| 31 | +} |
| 32 | + |
| 33 | +void onReceive(int packetSize) { |
| 34 | + // received a packet |
| 35 | + Serial.print("Received packet '"); |
| 36 | + |
| 37 | + // read packet |
| 38 | + for (int i = 0; i < packetSize; i++) { |
| 39 | + Serial.print((char)LoRa.read()); |
| 40 | + } |
| 41 | + |
| 42 | + // print RSSI of packet |
| 43 | + Serial.print("' with RSSI "); |
| 44 | + Serial.println(LoRa.packetRssi()); |
| 45 | +} |
0 commit comments