1
1
/*
2
2
* FOSSA Ground Station Example
3
3
*
4
- * Tested on Arduino Uno and SX1278 , can be used with any LoRa radio
5
- * from the SX127x or SX126x series. Make sure radio type (line 21 )
6
- * and pin mapping (lines 26 - 29 ) match your hardware!
4
+ * Tested on Arduino Uno and SX1268 , can be used with any LoRa radio
5
+ * from the SX126x series. Make sure radio type (line 37 )
6
+ * and pin mapping (lines 23 - 25 ) match your hardware!
7
7
*
8
8
* References:
9
9
*
19
19
#include < RadioLib.h>
20
20
#include < FOSSA-Comms.h>
21
21
22
- #define RADIO_TYPE SX1278 // type of radio module to be used
23
- // #define RADIO_SX126X // also uncomment this line when using SX126x!!!
24
-
25
22
// pin definitions
26
23
#define CS 10
27
- #define DIO0 2
28
- #define DIO1 3
24
+ #define DIO1 2
29
25
#define BUSY 9
30
26
31
27
// modem configuration
32
28
#define FREQUENCY 436.7 // MHz
33
29
#define BANDWIDTH 125.0 // kHz
34
30
#define SPREADING_FACTOR 11
35
31
#define CODING_RATE 8 // 4/8
36
- #define SYNC_WORD_7X 0xFF // sync word when using SX127x
37
- #define SYNC_WORD_6X 0x0F0F // SX126x
32
+ #define SYNC_WORD 0x0F0F // sync word
33
+ #define OUTPUT_POWER 21 // dBm
34
+ #define CURRENT_LIMIT 200 // mA
38
35
39
36
// set up radio module
40
- #ifdef RADIO_SX126X
41
- RADIO_TYPE radio = new Module(CS, DIO0, BUSY);
42
- #else
43
- RADIO_TYPE radio = new Module(CS, DIO0, DIO1);
44
- #endif
37
+ SX1268 radio = new Module(CS, DIO1, BUSY);
45
38
46
39
// flags
47
40
volatile bool interruptEnabled = true ;
@@ -199,19 +192,14 @@ void setup() {
199
192
Serial.println (F (" FOSSA Ground Station Demo Code" ));
200
193
201
194
// initialize the radio
202
- #ifdef RADIO_SX126X
203
- int state = radio.begin (FREQUENCY,
204
- BANDWIDTH,
205
- SPREADING_FACTOR,
206
- CODING_RATE,
207
- SYNC_WORD_6X);
208
- #else
209
195
int state = radio.begin (FREQUENCY,
210
196
BANDWIDTH,
211
197
SPREADING_FACTOR,
212
198
CODING_RATE,
213
- SYNC_WORD_7X);
214
- #endif
199
+ SYNC_WORD,
200
+ OUTPUT_POWER,
201
+ CURRENT_LIMIT);
202
+
215
203
if (state == ERR_NONE) {
216
204
Serial.println (F (" Radio initialization successful!" ));
217
205
} else {
@@ -221,11 +209,7 @@ void setup() {
221
209
}
222
210
223
211
// attach the ISR to radio interrupt
224
- #ifdef RADIO_SX126X
225
212
radio.setDio1Action (onInterrupt);
226
- #else
227
- radio.setDio0Action (onInterrupt);
228
- #endif
229
213
230
214
// begin listening for packets
231
215
radio.startReceive ();
@@ -272,11 +256,7 @@ void loop() {
272
256
}
273
257
274
258
// set radio mode to reception
275
- #ifdef RADIO_SX126X
276
259
radio.setDio1Action (onInterrupt);
277
- #else
278
- radio.setDio0Action (onInterrupt);
279
- #endif
280
260
radio.startReceive ();
281
261
interruptEnabled = true ;
282
262
}
@@ -392,7 +372,7 @@ void loop() {
392
372
}
393
373
394
374
} else {
395
- Serial.println (F (" Reception failed, code " ));
375
+ Serial.print (F (" Reception failed, code " ));
396
376
Serial.println (state);
397
377
398
378
}
0 commit comments