diff --git a/examples/ArduinoLoRa/LoRaReceiver/LoRaReceiver.ino b/examples/ArduinoLoRa/LoRaReceiver/LoRaReceiver.ino index fb35fae..e67d858 100644 --- a/examples/ArduinoLoRa/LoRaReceiver/LoRaReceiver.ino +++ b/examples/ArduinoLoRa/LoRaReceiver/LoRaReceiver.ino @@ -2,6 +2,21 @@ #include #include "LoRaBoards.h" +#ifndef CONFIG_RADIO_FREQ +#define CONFIG_RADIO_FREQ 868.0 +#endif +#ifndef CONFIG_RADIO_OUTPUT_POWER +#define CONFIG_RADIO_OUTPUT_POWER 17 +#endif +#ifndef CONFIG_RADIO_BW +#define CONFIG_RADIO_BW 125.0 +#endif + + +#if !defined(USING_SX1276) && !defined(USING_SX1278) +#error "LoRa example is only allowed to run SX1276/78. For other RF models, please run examples/RadioLibExamples +#endif + void setup() { setupBoards(); @@ -16,10 +31,30 @@ void setup() #endif LoRa.setPins(RADIO_CS_PIN, RADIO_RST_PIN, RADIO_DIO0_PIN); - if (!LoRa.begin(LORA_FREQ_CONFIG)) { + if (!LoRa.begin(CONFIG_RADIO_FREQ * 1000000)) { Serial.println("Starting LoRa failed!"); while (1); } + + LoRa.setTxPower(CONFIG_RADIO_OUTPUT_POWER); + + LoRa.setSignalBandwidth(CONFIG_RADIO_BW * 1000); + + LoRa.setSpreadingFactor(10); + + LoRa.setPreambleLength(16); + + LoRa.setSyncWord(0xAB); + + LoRa.disableCrc(); + + LoRa.disableInvertIQ(); + + LoRa.setCodingRate4(7); + + // put the radio into receive mode + LoRa.receive(); + } void loop() diff --git a/examples/ArduinoLoRa/LoRaSender/LoRaSender.ino b/examples/ArduinoLoRa/LoRaSender/LoRaSender.ino index b545fa8..a9b5312 100644 --- a/examples/ArduinoLoRa/LoRaSender/LoRaSender.ino +++ b/examples/ArduinoLoRa/LoRaSender/LoRaSender.ino @@ -2,6 +2,21 @@ #include #include "LoRaBoards.h" +#ifndef CONFIG_RADIO_FREQ +#define CONFIG_RADIO_FREQ 868.0 +#endif +#ifndef CONFIG_RADIO_OUTPUT_POWER +#define CONFIG_RADIO_OUTPUT_POWER 17 +#endif +#ifndef CONFIG_RADIO_BW +#define CONFIG_RADIO_BW 125.0 +#endif + + +#if !defined(USING_SX1276) && !defined(USING_SX1278) +#error "LoRa example is only allowed to run SX1276/78. For other RF models, please run examples/RadioLibExamples +#endif + int counter = 0; void setup() @@ -17,10 +32,26 @@ void setup() Serial.println("LoRa Sender"); LoRa.setPins(RADIO_CS_PIN, RADIO_RST_PIN, RADIO_DIO0_PIN); - if (!LoRa.begin(LORA_FREQ_CONFIG)) { + if (!LoRa.begin(CONFIG_RADIO_FREQ * 1000000)) { Serial.println("Starting LoRa failed!"); while (1); } + + LoRa.setTxPower(CONFIG_RADIO_OUTPUT_POWER); + + LoRa.setSignalBandwidth(CONFIG_RADIO_BW * 1000); + + LoRa.setSpreadingFactor(10); + + LoRa.setPreambleLength(16); + + LoRa.setSyncWord(0xAB); + + LoRa.disableCrc(); + + LoRa.disableInvertIQ(); + + LoRa.setCodingRate4(7); } void loop()