[SX127x] Fixed typos in examples

This commit is contained in:
jgromes 2019-05-24 14:32:07 +02:00
parent 0bafe185a9
commit 1bc2633048
7 changed files with 71 additions and 67 deletions

View file

@ -48,11 +48,11 @@ void loop() {
if (state == PREAMBLE_DETECTED) {
// LoRa preamble was detected
Serial.println(" detected preamble!");
Serial.println(F(" detected preamble!"));
} else if (state == CHANNEL_FREE) {
// no preamble was detected, channel is free
Serial.println(" channel is free!");
Serial.println(F(" channel is free!"));
}

View file

@ -29,7 +29,7 @@ void setup() {
// current limit: 100 mA
// data shaping: Gaussian, BT = 0.3
// sync word: 0x2D 0x01
// OOK modulation: false
// OOK modulation: disabled
int state = fsk.beginFSK();
if (state == ERR_NONE) {
Serial.println(F("success!"));

View file

@ -65,26 +65,26 @@ void loop() {
Serial.println(F("success!"));
// print the data of the packet
Serial.print("[SX1278] Data:\t\t");
Serial.print(F("[SX1278] Data:\t\t"));
Serial.println(str);
// print the RSSI (Received Signal Strength Indicator)
// of the last received packet
Serial.print("[SX1278] RSSI:\t\t");
Serial.print(F("[SX1278] RSSI:\t\t"));
Serial.print(lora.getRSSI());
Serial.println(" dBm");
Serial.println(F(" dBm"));
// print the SNR (Signal-to-Noise Ratio)
// of the last received packet
Serial.print("[SX1278] SNR:\t\t");
Serial.print(F("[SX1278] SNR:\t\t"));
Serial.print(lora.getSNR());
Serial.println(" dBm");
Serial.println(F(" dBm"));
// print frequency error
// of the last received packet
Serial.print("Frequency error:\t");
Serial.print(F("Frequency error:\t"));
Serial.print(lora.getFrequencyError());
Serial.println(" Hz");
Serial.println(F(" Hz"));
} else if (state == ERR_RX_TIMEOUT) {
// timeout occurred while waiting for a packet

View file

@ -1,5 +1,5 @@
/*
RadioLib SX127x Receive with Inerrupts Example
RadioLib SX127x Receive with Interrupts Example
This example listens for LoRa transmissions and tries to
receive them. Once a packet is received, an interrupt is
@ -111,30 +111,30 @@ void loop() {
if (state == ERR_NONE) {
// packet was successfully received
Serial.println("[SX1278] Received packet!");
Serial.println(F("[SX1278] Received packet!"));
// print data of the packet
Serial.print("[SX1278] Data:\t\t");
Serial.print(F("[SX1278] Data:\t\t"));
Serial.println(str);
// print RSSI (Received Signal Strength Indicator)
Serial.print("[SX1278] RSSI:\t\t");
Serial.print(F("[SX1278] RSSI:\t\t"));
Serial.print(lora.getRSSI());
Serial.println(" dBm");
Serial.println(F(" dBm"));
// print SNR (Signal-to-Noise Ratio)
Serial.print("[SX1278] SNR:\t\t");
Serial.print(F("[SX1278] SNR:\t\t"));
Serial.print(lora.getSNR());
Serial.println(" dBm");
Serial.println(F(" dBm"));
// print frequency error
Serial.print("[SX1278] Frequency error:\t");
Serial.print(F("[SX1278] Frequency error:\t"));
Serial.print(lora.getFrequencyError());
Serial.println(" Hz");
Serial.println(F(" Hz"));
} else if (state == ERR_CRC_MISMATCH) {
// packet was received, but is malformed
Serial.println("CRC error!");
Serial.println(F("CRC error!"));
}

View file

@ -20,8 +20,12 @@
// SX1278 module is in slot A on the shield
SX1278 loraSX1278 = RadioShield.ModuleA;
// SX1272 module is in slot B on the shield
SX1272 loraSX1272 = RadioShield.ModuleB;
// if you're not using RadioShield, you can specify
// the connection yourself
// NSS pin: 6
// DIO1 pin: 4
// DIO2 pin: 5
SX1272 loraSX1272 = new Module(6, 4, 5);
void setup() {
Serial.begin(9600);
@ -81,32 +85,32 @@ void setup() {
// set carrier frequency to 433.5 MHz
if (loraSX1278.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
Serial.println("Selected frequency is invalid for this module!");
Serial.println(F("Selected frequency is invalid for this module!"));
while (true);
}
// set bandwidth to 250 kHz
if (loraSX1278.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
Serial.println("Selected bandwidth is invalid for this module!");
Serial.println(F("Selected bandwidth is invalid for this module!"));
while (true);
}
// set spreading factor to 10
if (loraSX1278.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
Serial.println("Selected spreading factor is invalid for this module!");
Serial.println(F("Selected spreading factor is invalid for this module!"));
while (true);
}
// set coding rate to 6
if (loraSX1278.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
Serial.println("Selected coding rate is invalid for this module!");
Serial.println(F("Selected coding rate is invalid for this module!"));
while (true);
}
// set LoRa sync word to 0x14
// NOTE: value 0x34 is reserved for LoRaWAN networks and should not be used
if (loraSX1278.setSyncWord(0x14) != ERR_NONE) {
Serial.println("Unable to set sync word!");
Serial.println(F("Unable to set sync word!"));
while (true);
}
@ -114,20 +118,20 @@ void setup() {
// NOTE: 20 dBm value allows high power operation, but transmission
// duty cycle MUST NOT exceed 1%
if (loraSX1278.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) {
Serial.println("Selected output power is invalid for this module!");
Serial.println(F("Selected output power is invalid for this module!"));
while (true);
}
// set over current protection limit to 80 mA (accepted range is 45 - 240 mA)
// NOTE: set value to 0 to disable overcurrent protection
if (loraSX1278.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) {
Serial.println("Selected current limit is invalid for this module!");
Serial.println(F("Selected current limit is invalid for this module!"));
while (true);
}
// set LoRa preamble length to 15 symbols (accepted range is 6 - 65535)
if (loraSX1278.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
Serial.println("Selected preamble length is invalid for this module!");
Serial.println(F("Selected preamble length is invalid for this module!"));
while (true);
}
@ -135,11 +139,11 @@ void setup() {
// NOTE: set value to 0 to enable autmatic gain control
// leave at 0 unless you know what you're doing
if (loraSX1278.setGain(1) == ERR_INVALID_GAIN) {
Serial.println("Selected gain is invalid for this module!");
Serial.println(F("Selected gain is invalid for this module!"));
while (true);
}
Serial.println("All settings succesfully changed!");
Serial.println(F("All settings succesfully changed!"));
}
void loop() {

View file

@ -58,20 +58,20 @@ void loop() {
if (state == ERR_NONE) {
// the packet was successfully transmitted
Serial.println(" success!");
Serial.println(F(" success!"));
// print measured data rate
Serial.print("[SX1278] Datarate:\t");
Serial.print(F("[SX1278] Datarate:\t"));
Serial.print(lora.getDataRate());
Serial.println(" bps");
Serial.println(F(" bps"));
} else if (state == ERR_PACKET_TOO_LONG) {
// the supplied packet was longer than 256 bytes
Serial.println(" too long!");
Serial.println(F(" too long!"));
} else if (state == ERR_TX_TIMEOUT) {
// timeout occured while transmitting packet
Serial.println(" timeout!");
Serial.println(F(" timeout!"));
}

View file

@ -1,5 +1,5 @@
/*
RadioLib SX127x Transmit with Inerrupts Example
RadioLib SX127x Transmit with Interrupts Example
This example transmits LoRa packets with one second delays
between them. Each packet contains up to 256 bytes