diff --git a/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino b/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino index abf6a582..96a96ffa 100644 --- a/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino +++ b/examples/SX128x/SX128x_BLE_Modem/SX128x_BLE_Modem.ino @@ -11,6 +11,9 @@ modem and use the appropriate configuration methods. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---ble-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -23,25 +26,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 ble = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 ble = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bit rate: 800 kbps - // frequency deviation: 400.0 kHz - // output power: 10 dBm - // preamble length: 16 bits - // data shaping: Gaussian, BT = 0.5 - // CRC: enabled, CRC16 (CCIT) - int state = ble.beginBLE(); + int state = radio.beginBLE(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -50,19 +46,19 @@ void setup() { while (true); } - // if needed, you can switch between LoRa and FSK modes + // if needed, you can switch between any of the modems // - // ble.begin() start LoRa mode (and disable BLE) - // lora.beginBLE() start BLE mode (and disable LoRa) + // radio.begin() start LoRa modem (and disable BLE) + // radio.beginBLE() start BLE modem (and disable LoRa) // the following settings can also // be modified at run-time - state = ble.setFrequency(2410.5); - state = ble.setBitRate(250); - state = ble.setFrequencyDeviation(100.0); - state = ble.setOutputPower(5); - state = ble.setDataShaping(1.0); - state = ble.setAccessAddress(0x12345678); + state = radio.setFrequency(2410.5); + state = radio.setBitRate(250); + state = radio.setFrequencyDeviation(100.0); + state = radio.setOutputPower(5); + state = radio.setDataShaping(1.0); + state = radio.setAccessAddress(0x12345678); if (state != ERR_NONE) { Serial.print(F("Unable to set configuration, code ")); Serial.println(state); @@ -77,11 +73,11 @@ void loop() { // as the LoRa modem, even their interrupt-driven versions // transmit BLE packet - int state = ble.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = ble.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Packet transmitted successfully!")); @@ -96,10 +92,10 @@ void loop() { // receive BLE packet String str; - state = ble.receive(str); + state = radio.receive(str); /* byte byteArr[8]; - int state = ble.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Received packet!")); diff --git a/examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino b/examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino index 6ec30377..cec1560a 100644 --- a/examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino +++ b/examples/SX128x/SX128x_Channel_Activity_Detection/SX128x_Channel_Activity_Detection.ino @@ -6,6 +6,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -18,25 +21,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -50,7 +46,7 @@ void loop() { Serial.print(F("[SX1280] Scanning channel for LoRa transmission ... ")); // start scanning current channel - int state = lora.scanChannel(); + int state = radio.scanChannel(); if (state == LORA_DETECTED) { // LoRa preamble was detected diff --git a/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino b/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino index af680b50..cf2d0e7c 100644 --- a/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino +++ b/examples/SX128x/SX128x_FLRC_Modem/SX128x_FLRC_Modem.ino @@ -9,6 +9,9 @@ modem and use the appropriate configuration methods. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---flrc-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,26 +24,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 flrc = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 flrc = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bit rate: 650 kbps - // coding rate: 3 - // output power: 10 dBm - // preamble length: 16 bits - // data shaping: Gaussian, BT = 0.5 - // sync word: 0x2D 0x01 0x4B 0x1D - // CRC: enabled - int state = flrc.beginFLRC(); + int state = radio.beginFLRC(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -49,20 +44,20 @@ void setup() { while (true); } - // if needed, you can switch between LoRa and FLRC modes + // if needed, you can switch between any of the modems // - // flrc.begin() start LoRa mode (and disable FLRC) - // lora.beginFLRC() start FLRC mode (and disable LoRa) + // radio.begin() start LoRa modem (and disable FLRC) + // radio.beginFLRC() start FLRC modem (and disable LoRa) // the following settings can also // be modified at run-time - state = flrc.setFrequency(2410.5); - state = flrc.setBitRate(520); - state = flrc.setCodingRate(2); - state = flrc.setOutputPower(5); - state = flrc.setDataShaping(1.0); + state = radio.setFrequency(2410.5); + state = radio.setBitRate(520); + state = radio.setCodingRate(2); + state = radio.setOutputPower(5); + state = radio.setDataShaping(1.0); uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67}; - state = flrc.setSyncWord(syncWord, 4); + state = radio.setSyncWord(syncWord, 4); if (state != ERR_NONE) { Serial.print(F("Unable to set configuration, code ")); Serial.println(state); @@ -77,11 +72,11 @@ void loop() { // as the LoRa modem, even their interrupt-driven versions // transmit FLRC packet - int state = flrc.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = flrc.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Packet transmitted successfully!")); @@ -94,12 +89,12 @@ void loop() { Serial.println(state); } - // receive GFSK packet + // receive FLRC packet String str; - state = flrc.receive(str); + state = radio.receive(str); /* byte byteArr[8]; - int state = flrc.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Received packet!")); diff --git a/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino b/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino index adfc5320..4ef75900 100644 --- a/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino +++ b/examples/SX128x/SX128x_GFSK_Modem/SX128x_GFSK_Modem.ino @@ -9,6 +9,9 @@ modem and use the appropriate configuration methods. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---gfsk-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,26 +24,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 gfsk = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bit rate: 800 kbps - // frequency deviation: 400.0 kHz - // output power: 10 dBm - // preamble length: 16 bits - // data shaping: Gaussian, BT = 0.5 - // sync word: 0x2D 0x01 - // CRC: enabled, CRC16 (CCIT) - int state = gfsk.beginGFSK(); + int state = radio.beginGFSK(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -49,20 +44,20 @@ void setup() { while (true); } - // if needed, you can switch between LoRa and FSK modes + // if needed, you can switch between any of the modems // - // gfsk.begin() start LoRa mode (and disable GFSK) - // lora.beginGFSK() start GFSK mode (and disable LoRa) + // radio.begin() start LoRa modem (and disable GFSK) + // radio.beginGFSK() start GFSK modem (and disable LoRa) // the following settings can also // be modified at run-time - state = gfsk.setFrequency(2410.5); - state = gfsk.setBitRate(200); - state = gfsk.setFrequencyDeviation(100.0); - state = gfsk.setOutputPower(5); - state = gfsk.setDataShaping(1.0); + state = radio.setFrequency(2410.5); + state = radio.setBitRate(200); + state = radio.setFrequencyDeviation(100.0); + state = radio.setOutputPower(5); + state = radio.setDataShaping(1.0); uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67, 0x89}; - state = gfsk.setSyncWord(syncWord, 5); + state = radio.setSyncWord(syncWord, 5); if (state != ERR_NONE) { Serial.print(F("Unable to set configuration, code ")); Serial.println(state); @@ -77,11 +72,11 @@ void loop() { // as the LoRa modem, even their interrupt-driven versions // transmit GFSK packet - int state = gfsk.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = gfsk.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Packet transmitted successfully!")); @@ -96,10 +91,10 @@ void loop() { // receive GFSK packet String str; - state = gfsk.receive(str); + state = radio.receive(str); /* byte byteArr[8]; - int state = gfsk.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { Serial.println(F("[SX1280] Received packet!")); diff --git a/examples/SX128x/SX128x_Ranging/SX128x_Ranging.ino b/examples/SX128x/SX128x_Ranging/SX128x_Ranging.ino index 585f948b..f53b1a2d 100644 --- a/examples/SX128x/SX128x_Ranging/SX128x_Ranging.ino +++ b/examples/SX128x/SX128x_Ranging/SX128x_Ranging.ino @@ -8,6 +8,9 @@ Only SX1280 and SX1282 support ranging! + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -20,25 +23,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -54,18 +50,18 @@ void loop() { // start ranging exchange // range as master: true // slave address: 0x12345678 - int state = lora.range(true, 0x12345678); + int state = radio.range(true, 0x12345678); // the other module must be configured as slave with the same address /* - int state = lora.range(false, 0x12345678); + int state = radio.range(false, 0x12345678); */ if (state == ERR_NONE) { // ranging finished successfully Serial.println(F("success!")); Serial.print(F("[SX1280] Distance:\t\t\t")); - Serial.print(lora.getRangingResult()); + Serial.print(radio.getRangingResult()); Serial.println(F(" meters")); } else if (state == ERR_RANGING_TIMEOUT) { diff --git a/examples/SX128x/SX128x_Receive/SX128x_Receive.ino b/examples/SX128x/SX128x_Receive/SX128x_Receive.ino index 0427cf41..ff5adc41 100644 --- a/examples/SX128x/SX128x_Receive/SX128x_Receive.ino +++ b/examples/SX128x/SX128x_Receive/SX128x_Receive.ino @@ -13,6 +13,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -25,25 +28,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -61,12 +57,12 @@ void loop() { // See example ReceiveInterrupt for details // on non-blocking reception method. String str; - int state = lora.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = lora.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { @@ -80,13 +76,13 @@ void loop() { // print the RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[SX1280] RSSI:\t\t")); - Serial.print(lora.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print the SNR (Signal-to-Noise Ratio) // of the last received packet Serial.print(F("[SX1280] SNR:\t\t")); - Serial.print(lora.getSNR()); + Serial.print(radio.getSNR()); Serial.println(F(" dB")); } else if (state == ERR_RX_TIMEOUT) { diff --git a/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino b/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino index 2d6f1664..65e03f7d 100644 --- a/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino +++ b/examples/SX128x/SX128x_Receive_Interrupt/SX128x_Receive_Interrupt.ino @@ -14,6 +14,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -26,25 +29,18 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -55,11 +51,11 @@ void setup() { // set the function that will be called // when new packet is received - lora.setDio1Action(setFlag); + radio.setDio1Action(setFlag); // start listening for LoRa packets Serial.print(F("[SX1280] Starting to listen ... ")); - state = lora.startReceive(); + state = radio.startReceive(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -71,12 +67,12 @@ void setup() { // if needed, 'listen' mode can be disabled by calling // any of the following methods: // - // lora.standby() - // lora.sleep() - // lora.transmit(); - // lora.receive(); - // lora.readData(); - // lora.scanChannel(); + // radio.standby() + // radio.sleep() + // radio.transmit(); + // radio.receive(); + // radio.readData(); + // radio.scanChannel(); } // flag to indicate that a packet was received @@ -111,12 +107,12 @@ void loop() { // you can read received data as an Arduino String String str; - int state = lora.readData(str); + int state = radio.readData(str); // you can also read received data as byte array /* byte byteArr[8]; - int state = lora.readData(byteArr, 8); + int state = radio.readData(byteArr, 8); */ if (state == ERR_NONE) { @@ -129,12 +125,12 @@ void loop() { // print RSSI (Received Signal Strength Indicator) Serial.print(F("[SX1280] RSSI:\t\t")); - Serial.print(lora.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print SNR (Signal-to-Noise Ratio) Serial.print(F("[SX1280] SNR:\t\t")); - Serial.print(lora.getSNR()); + Serial.print(radio.getSNR()); Serial.println(F(" dB")); } else if (state == ERR_CRC_MISMATCH) { @@ -149,7 +145,7 @@ void loop() { } // put module back to listen mode - lora.startReceive(); + radio.startReceive(); // we're ready to receive more packets, // enable interrupt service routine diff --git a/examples/SX128x/SX128x_Settings/SX128x_Settings.ino b/examples/SX128x/SX128x_Settings/SX128x_Settings.ino index 49d218d6..0963d85a 100644 --- a/examples/SX128x/SX128x_Settings/SX128x_Settings.ino +++ b/examples/SX128x/SX128x_Settings/SX128x_Settings.ino @@ -14,6 +14,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -26,32 +29,25 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 loraSX1280 = new Module(10, 2, 3, 9); +SX1280 radio1 = new Module(10, 2, 3, 9); // SX1280 has the following connections: // NSS pin: 8 // DIO1 pin: 4 // NRST pin: 5 // BUSY pin: 6 -SX1281 loraSX1281 = new Module(8, 4, 5, 6); +SX1281 radio2 = new Module(8, 4, 5, 6); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1282 loraSX1282 = RadioShield.ModuleB; +//SX1282 radio3 = RadioShield.ModuleB; void setup() { Serial.begin(9600); // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = loraSX1280.begin(); + int state = radio1.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -71,8 +67,7 @@ void setup() { // coding rate: 5 // output power: 2 dBm // preamble length: 20 symbols - // CRC: enabled - state = loraSX1281.begin(2450.0, 1625.0, 7, 5, 2, 20); + state = radio2.begin(2450.0, 1625.0, 7, 5, 2, 20); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -85,43 +80,43 @@ void setup() { // and check if the configuration was changed successfully // set carrier frequency to 2410.5 MHz - if (loraSX1280.setFrequency(2410.5) == ERR_INVALID_FREQUENCY) { + if (radio1.setFrequency(2410.5) == ERR_INVALID_FREQUENCY) { Serial.println(F("Selected frequency is invalid for this module!")); while (true); } // set bandwidth to 203.125 kHz - if (loraSX1280.setBandwidth(203.125) == ERR_INVALID_BANDWIDTH) { + if (radio1.setBandwidth(203.125) == ERR_INVALID_BANDWIDTH) { Serial.println(F("Selected bandwidth is invalid for this module!")); while (true); } // set spreading factor to 10 - if (loraSX1280.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) { + if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) { Serial.println(F("Selected spreading factor is invalid for this module!")); while (true); } // set coding rate to 6 - if (loraSX1280.setCodingRate(6) == ERR_INVALID_CODING_RATE) { + if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) { Serial.println(F("Selected coding rate is invalid for this module!")); while (true); } // set output power to -2 dBm - if (loraSX1280.setOutputPower(-2) == ERR_INVALID_OUTPUT_POWER) { + if (radio1.setOutputPower(-2) == ERR_INVALID_OUTPUT_POWER) { Serial.println(F("Selected output power is invalid for this module!")); while (true); } // set LoRa preamble length to 16 symbols (accepted range is 2 - 65535) - if (loraSX1280.setPreambleLength(16) == ERR_INVALID_PREAMBLE_LENGTH) { + if (radio1.setPreambleLength(16) == ERR_INVALID_PREAMBLE_LENGTH) { Serial.println(F("Selected preamble length is invalid for this module!")); while (true); } // disable CRC - if (loraSX1280.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) { + if (radio1.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) { Serial.println(F("Selected CRC is invalid for this module!")); while (true); } diff --git a/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino b/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino index b86259cf..a4037def 100644 --- a/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino +++ b/examples/SX128x/SX128x_Transmit/SX128x_Transmit.ino @@ -9,6 +9,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,11 +24,11 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -39,7 +42,7 @@ void setup() { // output power: 10 dBm // preamble length: 12 symbols // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -55,7 +58,7 @@ void setup() { // RX enable: 4 // TX enable: 5 /* - lora.setRfSwitchPins(4, 5); + radio.setRfSwitchPins(4, 5); */ } @@ -67,12 +70,12 @@ void loop() { // NOTE: transmit() is a blocking method! // See example SX128x_Transmit_Interrupt for details // on non-blocking transmission method. - int state = lora.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF}; - int state = lora.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino b/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino index 284244e8..ecdd9312 100644 --- a/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino +++ b/examples/SX128x/SX128x_Transmit_Interrupt/SX128x_Transmit_Interrupt.ino @@ -10,6 +10,9 @@ Other modules from SX128x family can also be used. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -22,11 +25,11 @@ // DIO1 pin: 2 // NRST pin: 3 // BUSY pin: 9 -SX1280 lora = new Module(10, 2, 3, 9); +SX1280 radio = new Module(10, 2, 3, 9); // or using RadioShield // https://github.com/jgromes/RadioShield -//SX1280 lora = RadioShield.ModuleA; +//SX1280 radio = RadioShield.ModuleA; // save transmission state between loops int transmissionState = ERR_NONE; @@ -36,14 +39,7 @@ void setup() { // initialize SX1280 with default settings Serial.print(F("[SX1280] Initializing ... ")); - // carrier frequency: 2400.0 MHz - // bandwidth: 812.5 kHz - // spreading factor: 9 - // coding rate: 7 - // output power: 10 dBm - // preamble length: 12 symbols - // CRC: enabled - int state = lora.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -54,20 +50,20 @@ void setup() { // set the function that will be called // when packet transmission is finished - lora.setDio1Action(setFlag); + radio.setDio1Action(setFlag); // start transmitting the first packet Serial.print(F("[SX1280] Sending first packet ... ")); // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = lora.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - state = lora.startTransmit(byteArr, 8); + state = radio.startTransmit(byteArr, 8); */ } @@ -119,13 +115,13 @@ void loop() { // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = lora.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = lora.startTransmit(byteArr, 8); + int state = radio.startTransmit(byteArr, 8); */ // we're ready to send more packets,