Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Best practice is when you set up a new repeater, choose a public key that is not

The `<number>` unit is in seconds and is incremented by 4. `set agc.reset.interval 4` works well to cure deafness.

This is a very low-cost operation. AGC reset is done by simply setting `state = STATE_IDLE;` in function `RadioLibWrapper::resetAGC()` in `RadioLibWrappers.cpp`
This is a low-cost operation (a few milliseconds). The reset performs a warm sleep to power down the radio's analog frontend, recalibrates all blocks (ADC, PLL, image rejection, oscillators), and resets the noise floor tracking. See `RadioLibWrapper::resetAGC()` in `RadioLibWrappers.cpp`.


### 3.8. Q: How do I make my repeater an observer on the mesh?
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"SPI": "*",
"Wire": "*",
"jgromes/RadioLib": "^7.6.0",
"jgromes/RadioLib": "^7.7.1",
"rweather/Crypto": "^0.4.0",
"adafruit/RTClib": "^2.1.3",
"melopero/Melopero RV3028": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ monitor_speed = 115200
lib_deps =
SPI
Wire
jgromes/RadioLib @ ^7.6.0
jgromes/RadioLib @ ^7.7.1
rweather/Crypto @ ^0.4.0
adafruit/RTClib @ ^2.1.3
melopero/Melopero RV3028 @ ^1.1.0
Expand Down
21 changes: 14 additions & 7 deletions src/helpers/radiolib/CustomLLCC68.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ class CustomLLCC68 : public LLCC68 {
#endif
{
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
tcxoVoltage = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
tcxoVoltage = 1.6f;
#endif

ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
#ifdef LORA_CR
uint8_t cr = LORA_CR;
cfg.codingRate = LORA_CR;
#else
uint8_t cr = 5;
cfg.codingRate = 5;
#endif
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 16;

#if defined(P_LORA_SCLK)
#ifdef NRF52_PLATFORM
Expand All @@ -42,11 +49,11 @@ class CustomLLCC68 : public LLCC68 {
if (spi) spi->begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
#endif
int status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
int status = begin(cfg);
// if radio init fails with -707/-706, try again with tcxo voltage set to 0.0f
if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) {
tcxo = 0.0f;
status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
tcxoVoltage = 0.0f;
status = begin(cfg);
}
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Expand Down
29 changes: 17 additions & 12 deletions src/helpers/radiolib/CustomSX1262.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,27 @@ class CustomSX1262 : public SX1262 {
#endif
{
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
tcxoVoltage = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
tcxoVoltage = 1.6f;
#endif

#ifdef LORA_CR
uint8_t cr = LORA_CR;
#else
uint8_t cr = 5;
#ifdef SX126X_USE_REGULATOR_LDO
useRegulatorLDO = SX126X_USE_REGULATOR_LDO;
#endif

#ifdef SX126X_USE_REGULATOR_LDO
constexpr bool useRegulatorLDO = SX126X_USE_REGULATOR_LDO;
ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
#ifdef LORA_CR
cfg.codingRate = LORA_CR;
#else
constexpr bool useRegulatorLDO = false;
cfg.codingRate = 5;
#endif
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 16;

MESH_DEBUG_PRINTLN("SX1262 regulator requested: %s", useRegulatorLDO ? "LDO" : "DC-DC");

Expand All @@ -51,12 +56,12 @@ class CustomSX1262 : public SX1262 {
if (spi) spi->begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
#endif
int status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo, useRegulatorLDO);
int status = begin(cfg);
// if radio init fails with -707/-706, try again with tcxo voltage set to 0.0f
if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) {
MESH_DEBUG_PRINTLN("SX1262 init failed with error %d, retrying with TCXO at 0.0V", status);
tcxo = 0.0f;
status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo, useRegulatorLDO);
tcxoVoltage = 0.0f;
status = begin(cfg);
}
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Expand Down
21 changes: 14 additions & 7 deletions src/helpers/radiolib/CustomSX1268.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ class CustomSX1268 : public SX1268 {
#endif
{
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
tcxoVoltage = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
tcxoVoltage = 1.6f;
#endif

ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
#ifdef LORA_CR
uint8_t cr = LORA_CR;
cfg.codingRate = LORA_CR;
#else
uint8_t cr = 5;
cfg.codingRate = 5;
#endif
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 16;

#if defined(P_LORA_SCLK)
#ifdef NRF52_PLATFORM
Expand All @@ -42,11 +49,11 @@ class CustomSX1268 : public SX1268 {
if (spi) spi->begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
#endif
int status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
int status = begin(cfg);
// if radio init fails with -707/-706, try again with tcxo voltage set to 0.0f
if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) {
tcxo = 0.0f;
status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
tcxoVoltage = 0.0f;
status = begin(cfg);
}
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Expand Down
14 changes: 10 additions & 4 deletions src/helpers/radiolib/CustomSX1276.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@ class CustomSX1276 : public SX1276 {
bool std_init(SPIClass* spi = NULL)
#endif
{
ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
#ifdef LORA_CR
uint8_t cr = LORA_CR;
cfg.codingRate = LORA_CR;
#else
uint8_t cr = 5;
cfg.codingRate = 5;
#endif
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 16;

#if defined(P_LORA_SCLK)
#ifdef NRF52_PLATFORM
Expand All @@ -39,8 +46,7 @@ class CustomSX1276 : public SX1276 {
if (spi) spi->begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
#endif
int status = begin(LORA_FREQ, LORA_BW, LORA_SF, cr, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16);
// if radio init fails with -707/-706, try again with tcxo voltage set to 0.0f
int status = begin(cfg);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
Expand Down
28 changes: 5 additions & 23 deletions src/helpers/radiolib/SX126xReset.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,14 @@
#include <RadioLib.h>

// Full receiver reset for all SX126x-family chips (SX1262, SX1268, LLCC68, STM32WLx).
// Warm sleep powers down analog, Calibrate(0x7F) refreshes ADC/PLL/image calibration,
// then re-applies RX settings that calibration may reset.
// RadioLib 7.7.0+ provides resetAGC(): warm sleep powers down analog, Calibrate(0x7F)
// refreshes ADC/PLL/image calibration, image is re-calibrated for the operating
// frequency, and DIO2 RF switch / RX boosted gain are re-applied automatically.
inline void sx126xResetAGC(SX126x* radio) {
radio->sleep(true);
radio->standby(RADIOLIB_SX126X_STANDBY_RC, true);
radio->resetAGC();

uint8_t calData = RADIOLIB_SX126X_CALIBRATE_ALL;
radio->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_CALIBRATE, &calData, 1, true, false);
radio->mod->hal->delay(5);
uint32_t start = millis();
while (radio->mod->hal->digitalRead(radio->mod->getGpio())) {
if (millis() - start > 50) break;
radio->mod->hal->yield();
}

// Calibrate(0x7F) defaults image calibration to 902-928MHz band.
// Re-calibrate for the actual operating frequency.
radio->calibrateImage(radio->freqMHz);

#ifdef SX126X_DIO2_AS_RF_SWITCH
radio->setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio->setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
#ifdef SX126X_REGISTER_PATCH
// for improved RX with Heltec v4 — calibration may reset this
uint8_t r_data = 0;
radio->readRegister(0x8B5, &r_data, 1);
r_data |= 0x01;
Expand Down
14 changes: 11 additions & 3 deletions variants/ebyte_eora_s3/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,23 @@ bool radio_init() {
rtc_clock.begin(Wire);

#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
radio.tcxoVoltage = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
radio.tcxoVoltage = 1.6f;
#endif

#if defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
cfg.codingRate = LORA_CR;
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 8;
int status = radio.begin(cfg);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
Expand Down
14 changes: 11 additions & 3 deletions variants/minewsemi_me25ls01/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,22 @@ bool radio_init() {
//rtc_clock.begin(Wire);

#ifdef LR11X0_DIO3_TCXO_VOLTAGE
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
radio.tcxoVoltage = LR11X0_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
radio.tcxoVoltage = 1.6f;
#endif

SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
cfg.codingRate = LORA_CR;
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 16;
int status = radio.begin(cfg);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
Expand Down
11 changes: 10 additions & 1 deletion variants/rak3x72/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ bool radio_init() {

radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);

int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, STM32WL_TCXO_VOLTAGE, 0);
radio.tcxoVoltage = STM32WL_TCXO_VOLTAGE;
ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
cfg.codingRate = LORA_CR;
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 16;
int status = radio.begin(cfg);

if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Expand Down
14 changes: 11 additions & 3 deletions variants/t1000-e/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,22 @@ bool radio_init() {
//rtc_clock.begin(Wire);

#ifdef LR11X0_DIO3_TCXO_VOLTAGE
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
radio.tcxoVoltage = LR11X0_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
radio.tcxoVoltage = 1.6f;
#endif

SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
cfg.codingRate = LORA_CR;
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 16;
int status = radio.begin(cfg);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
Expand Down
14 changes: 11 additions & 3 deletions variants/thinknode_m3/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,22 @@ bool radio_init() {
rtc_clock.begin(Wire);

#ifdef LR11X0_DIO3_TCXO_VOLTAGE
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
radio.tcxoVoltage = LR11X0_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
radio.tcxoVoltage = 1.6f;
#endif

SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
cfg.codingRate = LORA_CR;
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 16;
int status = radio.begin(cfg);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
Expand Down
12 changes: 10 additions & 2 deletions variants/tiny_relay/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ bool radio_init()

radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);

int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16,
STM32WL_TCXO_VOLTAGE, 0);
radio.tcxoVoltage = STM32WL_TCXO_VOLTAGE;
ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
cfg.codingRate = LORA_CR;
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 16;
int status = radio.begin(cfg);

if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Expand Down
11 changes: 10 additions & 1 deletion variants/wio-e5-dev/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ bool radio_init() {

radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);

int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, 1.7, 0);
radio.tcxoVoltage = 1.7f;
ConfigLoRa_t cfg;
cfg.frequency = LORA_FREQ;
cfg.bandwidth = LORA_BW;
cfg.spreadingFactor = LORA_SF;
cfg.codingRate = LORA_CR;
cfg.syncWord = RADIOLIB_LORA_SYNC_WORD_PRIVATE;
cfg.power = LORA_TX_POWER;
cfg.preambleLength = 16;
int status = radio.begin(cfg);

if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Expand Down
Loading