Update RadioLib

This commit is contained in:
lewisxhe
2024-09-19 11:12:36 +08:00
parent 210367a171
commit 5794daa8aa
301 changed files with 115546 additions and 12703 deletions
@@ -59,7 +59,7 @@ void setup() {
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
while (true) { delay(10); }
}
// initialize the second LoRa instance with
@@ -74,13 +74,13 @@ void setup() {
// sync word: 0x34 (public network/LoRaWAN)
// output power: 2 dBm
// preamble length: 20 symbols
state = radio2.begin(915.0, 500.0, 6, 5, 0x34, 20);
state = radio2.begin(915.0, 500.0, 6, 5, 0x34, 2, 20);
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
while (true) { delay(10); }
}
// you can also change the settings at runtime
@@ -89,56 +89,56 @@ void setup() {
// set carrier frequency to 433.5 MHz
if (radio1.setFrequency(433.5) == RADIOLIB_ERR_INVALID_FREQUENCY) {
Serial.println(F("Selected frequency is invalid for this module!"));
while (true);
while (true) { delay(10); }
}
// set bandwidth to 250 kHz
if (radio1.setBandwidth(250.0) == RADIOLIB_ERR_INVALID_BANDWIDTH) {
Serial.println(F("Selected bandwidth is invalid for this module!"));
while (true);
while (true) { delay(10); }
}
// set spreading factor to 10
if (radio1.setSpreadingFactor(10) == RADIOLIB_ERR_INVALID_SPREADING_FACTOR) {
Serial.println(F("Selected spreading factor is invalid for this module!"));
while (true);
while (true) { delay(10); }
}
// set coding rate to 6
if (radio1.setCodingRate(6) == RADIOLIB_ERR_INVALID_CODING_RATE) {
Serial.println(F("Selected coding rate is invalid for this module!"));
while (true);
while (true) { delay(10); }
}
// set LoRa sync word to 0xAB
if (radio1.setSyncWord(0xAB) != RADIOLIB_ERR_NONE) {
Serial.println(F("Unable to set sync word!"));
while (true);
while (true) { delay(10); }
}
// set output power to 10 dBm (accepted range is -17 - 22 dBm)
if (radio1.setOutputPower(10) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
Serial.println(F("Selected output power is invalid for this module!"));
while (true);
while (true) { delay(10); }
}
// set over current protection limit to 80 mA (accepted range is 45 - 240 mA)
// NOTE: set value to 0 to disable overcurrent protection
if (radio1.setCurrentLimit(80) == RADIOLIB_ERR_INVALID_CURRENT_LIMIT) {
Serial.println(F("Selected current limit is invalid for this module!"));
while (true);
while (true) { delay(10); }
}
// set LoRa preamble length to 15 symbols (accepted range is 0 - 65535)
if (radio1.setPreambleLength(15) == RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH) {
Serial.println(F("Selected preamble length is invalid for this module!"));
while (true);
while (true) { delay(10); }
}
// disable CRC
if (radio1.setCRC(false) == RADIOLIB_ERR_INVALID_CRC_CONFIGURATION) {
Serial.println(F("Selected CRC is invalid for this module!"));
while (true);
while (true) { delay(10); }
}
// Some SX126x modules have TCXO (temperature compensated crystal
@@ -146,7 +146,7 @@ void setup() {
// the following method can be used.
if (radio1.setTCXO(2.4) == RADIOLIB_ERR_INVALID_TCXO_VOLTAGE) {
Serial.println(F("Selected TCXO voltage is invalid for this module!"));
while (true);
while (true) { delay(10); }
}
// Some SX126x modules use DIO2 as RF switch. To enable
@@ -155,7 +155,7 @@ void setup() {
// it can't be used as interrupt pin!
if (radio1.setDio2AsRfSwitch() != RADIOLIB_ERR_NONE) {
Serial.println(F("Failed to set DIO2 as RF switch!"));
while (true);
while (true) { delay(10); }
}
Serial.println(F("All settings succesfully changed!"));