-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(radio): don't hang on a transient SPI failure talking to the LoRa chip #11234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,7 +290,8 @@ template <typename T> bool LR11x0Interface<T>::reconfigure() | |
| RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING); | ||
|
|
||
| err = lora.setSyncWord(syncWord); | ||
| assert(err == RADIOLIB_ERR_NONE); | ||
| if (err != RADIOLIB_ERR_NONE) | ||
| RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING); | ||
|
|
||
| if (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_LORA_24) { // clamp if wide freq range | ||
| limitPower(LR1120_MAX_POWER); | ||
|
|
@@ -299,14 +300,16 @@ template <typename T> bool LR11x0Interface<T>::reconfigure() | |
| } | ||
|
|
||
| err = lora.setPreambleLength(preambleLength); | ||
| assert(err == RADIOLIB_ERR_NONE); | ||
| if (err != RADIOLIB_ERR_NONE) | ||
| RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING); | ||
|
|
||
| err = lora.setFrequency(getFreq()); | ||
| if (err != RADIOLIB_ERR_NONE) | ||
| RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING); | ||
|
|
||
| err = lora.setOutputPower(power); | ||
| assert(err == RADIOLIB_ERR_NONE); | ||
| if (err != RADIOLIB_ERR_NONE) | ||
| RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING); | ||
|
|
||
| // Apply RX gain mode - valid in STDBY, matches resetAGC() pattern | ||
| err = lora.setRxBoostedGainMode(config.lora.sx126x_rx_boosted_gain); | ||
|
|
@@ -331,10 +334,9 @@ template <typename T> void LR11x0Interface<T>::setStandby() | |
|
|
||
| if (err != RADIOLIB_ERR_NONE) { | ||
| LOG_DEBUG("LR11x0 standby failed, err %d", err); | ||
| RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_RADIO_SPI_BUG); | ||
| } | ||
|
|
||
| assert(err == RADIOLIB_ERR_NONE); | ||
|
|
||
| isReceiving = false; // If we were receiving, not any more | ||
| activeReceiveStart = 0; | ||
| disableInterrupt(); | ||
|
|
@@ -377,9 +379,10 @@ template <typename T> void LR11x0Interface<T>::startReceive() | |
| // We use a 16 bit preamble so this should save some power by letting radio sit in standby mostly. | ||
| int err = | ||
| lora.startReceive(RADIOLIB_LR11X0_RX_TIMEOUT_INF, MESHTASTIC_RADIOLIB_IRQ_RX_FLAGS, RADIOLIB_IRQ_RX_DEFAULT_MASK, 0); | ||
| if (err) | ||
| if (err) { | ||
| LOG_ERROR("StartReceive error: %d", err); | ||
| assert(err == RADIOLIB_ERR_NONE); | ||
| RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_RADIO_SPI_BUG); | ||
| } | ||
|
Comment on lines
+382
to
+385
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Do not enter the receive-success path after These branches record the failure but continue into software receive bookkeeping, interrupt setup, or RX-flag processing. Restore the non-receiving state and return through failure cleanup before executing success-only logic.
📍 Affects 5 files
🤖 Prompt for AI Agents |
||
|
|
||
| RadioLibInterface::startReceive(); | ||
|
|
||
|
|
@@ -407,7 +410,8 @@ template <typename T> bool LR11x0Interface<T>::isChannelActive() | |
| if (result == RADIOLIB_LORA_DETECTED) | ||
| return true; | ||
|
|
||
| assert(result != RADIOLIB_ERR_WRONG_MODEM); | ||
| if (result == RADIOLIB_ERR_WRONG_MODEM) | ||
| RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_RADIO_SPI_BUG); | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Do not report partial radio configuration as successful.
Each listed branch records
INVALID_RADIO_SETTING, but the surroundingreconfigure()method still restarts reception and returnstrue. Track setter failure for every required setting and skip the restart when configuration is incomplete. The existing contract insrc/mesh/LR20x0Interface.cppat Lines 282-322 provides the expected pattern.src/mesh/LR11x0Interface.cpp#L293-L294: propagatesetSyncWord()failure.src/mesh/LR11x0Interface.cpp#L303-L312: propagatesetPreambleLength(),setFrequency(), andsetOutputPower()failures.src/mesh/RF95Interface.cpp#L231-L246: propagate the three changed setter failures.src/mesh/SX126xInterface.cpp#L212-L227: propagate the three changed setter failures.src/mesh/SX128xInterface.cpp#L134-L155: propagatesetSyncWord(),setPreambleLength(), andsetOutputPower()failures.📍 Affects 4 files
src/mesh/LR11x0Interface.cpp#L293-L294(this comment)src/mesh/LR11x0Interface.cpp#L303-L312src/mesh/RF95Interface.cpp#L231-L246src/mesh/SX126xInterface.cpp#L212-L227src/mesh/SX128xInterface.cpp#L134-L155🤖 Prompt for AI Agents