Browse Source

refactor to use config instead of init() methods

this prepares us for radiolib release 8
pull/2912/head
Wessel Nieboer 3 weeks ago
parent
commit
a6c750f699
No known key found for this signature in database GPG Key ID: 929C8E45E33B5FD2
  1. 21
      src/helpers/radiolib/CustomLLCC68.h
  2. 29
      src/helpers/radiolib/CustomSX1262.h
  3. 21
      src/helpers/radiolib/CustomSX1268.h
  4. 14
      src/helpers/radiolib/CustomSX1276.h
  5. 14
      variants/ebyte_eora_s3/target.cpp
  6. 14
      variants/minewsemi_me25ls01/target.cpp
  7. 11
      variants/rak3x72/target.cpp
  8. 14
      variants/t1000-e/target.cpp
  9. 14
      variants/thinknode_m3/target.cpp
  10. 12
      variants/tiny_relay/target.cpp
  11. 11
      variants/wio-e5-dev/target.cpp
  12. 11
      variants/wio-e5-mini/target.cpp
  13. 16
      variants/wio_wm1110/target.cpp

21
src/helpers/radiolib/CustomLLCC68.h

@ -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
@ -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: ");

29
src/helpers/radiolib/CustomSX1262.h

@ -19,22 +19,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");
@ -53,12 +58,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: ");

21
src/helpers/radiolib/CustomSX1268.h

@ -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
@ -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: ");

14
src/helpers/radiolib/CustomSX1276.h

@ -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
@ -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);

14
variants/ebyte_eora_s3/target.cpp

@ -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);

14
variants/minewsemi_me25ls01/target.cpp

@ -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);

11
variants/rak3x72/target.cpp

@ -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: ");

14
variants/t1000-e/target.cpp

@ -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);

14
variants/thinknode_m3/target.cpp

@ -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);

12
variants/tiny_relay/target.cpp

@ -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: ");

11
variants/wio-e5-dev/target.cpp

@ -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: ");

11
variants/wio-e5-mini/target.cpp

@ -33,7 +33,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: ");

16
variants/wio_wm1110/target.cpp

@ -41,15 +41,23 @@ bool radio_init() {
board.enableSensorPower(true);
#ifdef LR11X0_DIO3_TCXO_VOLTAGE
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
radio.tcxoVoltage = LR11X0_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.8f;
radio.tcxoVoltage = 1.8f;
#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);

Loading…
Cancel
Save