mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-28 12:42:00 +00:00
Add error handling for SPI command failures in LR11x0, RF95, and SX128x interfaces
This commit is contained in:
@@ -91,10 +91,21 @@ template <typename T> bool LR11x0Interface<T>::init()
|
|||||||
LOG_DEBUG("Set RF1 switch to %s", getFreq() < 1e9 ? "SubGHz" : "2.4GHz");
|
LOG_DEBUG("Set RF1 switch to %s", getFreq() < 1e9 ? "SubGHz" : "2.4GHz");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Allow extra time for TCXO to stabilize after power-on
|
||||||
|
delay(10);
|
||||||
|
|
||||||
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage);
|
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage);
|
||||||
|
|
||||||
|
// Retry if we get SPI command failed - some units need extra TCXO stabilization time
|
||||||
|
if (res == RADIOLIB_ERR_SPI_CMD_FAILED) {
|
||||||
|
LOG_WARN("LR11x0 init failed with %d (SPI_CMD_FAILED), retrying after delay...", res);
|
||||||
|
delay(100);
|
||||||
|
res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage);
|
||||||
|
}
|
||||||
|
|
||||||
// \todo Display actual typename of the adapter, not just `LR11x0`
|
// \todo Display actual typename of the adapter, not just `LR11x0`
|
||||||
LOG_INFO("LR11x0 init result %d", res);
|
LOG_INFO("LR11x0 init result %d", res);
|
||||||
if (res == RADIOLIB_ERR_CHIP_NOT_FOUND)
|
if (res == RADIOLIB_ERR_CHIP_NOT_FOUND || res == RADIOLIB_ERR_SPI_CMD_FAILED)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LR11x0VersionInfo_t version;
|
LR11x0VersionInfo_t version;
|
||||||
|
|||||||
@@ -177,6 +177,9 @@ bool RF95Interface::init()
|
|||||||
|
|
||||||
int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength);
|
int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength);
|
||||||
LOG_INFO("RF95 init result %d", res);
|
LOG_INFO("RF95 init result %d", res);
|
||||||
|
if (res == RADIOLIB_ERR_CHIP_NOT_FOUND || res == RADIOLIB_ERR_SPI_CMD_FAILED)
|
||||||
|
return false;
|
||||||
|
|
||||||
LOG_INFO("Frequency set to %f", getFreq());
|
LOG_INFO("Frequency set to %f", getFreq());
|
||||||
LOG_INFO("Bandwidth set to %f", bw);
|
LOG_INFO("Bandwidth set to %f", bw);
|
||||||
LOG_INFO("Power output set to %d", power);
|
LOG_INFO("Power output set to %d", power);
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ template <typename T> bool SX128xInterface<T>::init()
|
|||||||
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength);
|
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength);
|
||||||
// \todo Display actual typename of the adapter, not just `SX128x`
|
// \todo Display actual typename of the adapter, not just `SX128x`
|
||||||
LOG_INFO("SX128x init result %d", res);
|
LOG_INFO("SX128x init result %d", res);
|
||||||
|
if (res == RADIOLIB_ERR_CHIP_NOT_FOUND || res == RADIOLIB_ERR_SPI_CMD_FAILED)
|
||||||
|
return false;
|
||||||
|
|
||||||
if ((config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24) && (res == RADIOLIB_ERR_INVALID_FREQUENCY)) {
|
if ((config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24) && (res == RADIOLIB_ERR_INVALID_FREQUENCY)) {
|
||||||
LOG_WARN("Radio only supports 2.4GHz LoRa. Adjusting Region and rebooting");
|
LOG_WARN("Radio only supports 2.4GHz LoRa. Adjusting Region and rebooting");
|
||||||
|
|||||||
Reference in New Issue
Block a user