Skip to content

Commit

Permalink
Dropped support for SX127x-based ground stations (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgromes committed Dec 9, 2019
1 parent e9ca4d4 commit bb69348
Showing 1 changed file with 13 additions and 33 deletions.
46 changes: 13 additions & 33 deletions Code/GroundStation/GroundStation.ino
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* FOSSA Ground Station Example
*
* Tested on Arduino Uno and SX1278, can be used with any LoRa radio
* from the SX127x or SX126x series. Make sure radio type (line 21)
* and pin mapping (lines 26 - 29) match your hardware!
* Tested on Arduino Uno and SX1268, can be used with any LoRa radio
* from the SX126x series. Make sure radio type (line 37)
* and pin mapping (lines 23 - 25) match your hardware!
*
* References:
*
Expand All @@ -19,29 +19,22 @@
#include <RadioLib.h>
#include <FOSSA-Comms.h>

#define RADIO_TYPE SX1278 // type of radio module to be used
//#define RADIO_SX126X // also uncomment this line when using SX126x!!!

// pin definitions
#define CS 10
#define DIO0 2
#define DIO1 3
#define DIO1 2
#define BUSY 9

// modem configuration
#define FREQUENCY 436.7 // MHz
#define BANDWIDTH 125.0 // kHz
#define SPREADING_FACTOR 11
#define CODING_RATE 8 // 4/8
#define SYNC_WORD_7X 0xFF // sync word when using SX127x
#define SYNC_WORD_6X 0x0F0F // SX126x
#define SYNC_WORD 0x0F0F // sync word
#define OUTPUT_POWER 21 // dBm
#define CURRENT_LIMIT 200 // mA

// set up radio module
#ifdef RADIO_SX126X
RADIO_TYPE radio = new Module(CS, DIO0, BUSY);
#else
RADIO_TYPE radio = new Module(CS, DIO0, DIO1);
#endif
SX1268 radio = new Module(CS, DIO1, BUSY);

// flags
volatile bool interruptEnabled = true;
Expand Down Expand Up @@ -199,19 +192,14 @@ void setup() {
Serial.println(F("FOSSA Ground Station Demo Code"));

// initialize the radio
#ifdef RADIO_SX126X
int state = radio.begin(FREQUENCY,
BANDWIDTH,
SPREADING_FACTOR,
CODING_RATE,
SYNC_WORD_6X);
#else
int state = radio.begin(FREQUENCY,
BANDWIDTH,
SPREADING_FACTOR,
CODING_RATE,
SYNC_WORD_7X);
#endif
SYNC_WORD,
OUTPUT_POWER,
CURRENT_LIMIT);

if(state == ERR_NONE) {
Serial.println(F("Radio initialization successful!"));
} else {
Expand All @@ -221,11 +209,7 @@ void setup() {
}

// attach the ISR to radio interrupt
#ifdef RADIO_SX126X
radio.setDio1Action(onInterrupt);
#else
radio.setDio0Action(onInterrupt);
#endif

// begin listening for packets
radio.startReceive();
Expand Down Expand Up @@ -272,11 +256,7 @@ void loop() {
}

// set radio mode to reception
#ifdef RADIO_SX126X
radio.setDio1Action(onInterrupt);
#else
radio.setDio0Action(onInterrupt);
#endif
radio.startReceive();
interruptEnabled = true;
}
Expand Down Expand Up @@ -392,7 +372,7 @@ void loop() {
}

} else {
Serial.println(F("Reception failed, code "));
Serial.print(F("Reception failed, code "));
Serial.println(state);

}
Expand Down

0 comments on commit bb69348

Please sign in to comment.