Fix: CC1101 radio stays permanently disabled after an init hang (radioInit stuck false) - #679
Open
bledrunner wants to merge 3 commits into
Open
Fix: CC1101 radio stays permanently disabled after an init hang (radioInit stuck false)#679bledrunner wants to merge 3 commits into
bledrunner wants to merge 3 commits into
Conversation
When the CC1101 init hangs and the watchdog reboots the ESP, the NVS "radioInit" flag is left false. transceiver_config_t::apply() then did "if(!radioInit) return;" on every subsequent boot without ever resetting the flag, so the radio was never re-initialized again. The web UI and the HA websocket keep working, but no RF is transmitted and shades stop responding - a reboot does not help because each boot reads false again. Only a /saveRadio POST recovered it. This retries init for up to 3 consecutive incomplete boots and only then gives up (booting cleanly with the radio off to avoid a hard boot loop). The counter resets on a successful init or a /saveRadio POST. Also stop advancing the rolling code while the radio is not initialized, otherwise commands issued during the dead window drift the stored code ahead of the motor and desync the remote once the radio recovers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After the ESP reboots while the CC1101 radio is being initialized (e.g. a WDT reset mid-init), the web UI and the Home Assistant websocket keep working, but shades stop responding to any command from the UI or HA. Rebooting does not help — every boot behaves the same. Only the original Somfy remote still works, and only a
/saveRadioPOST brings the radio back.Matches user reports such as #535 ("not responding after some times").
Root cause —
transceiver_config_t::apply()inSomfy.cppThe flag is written
falsebefore init and back totrueafter, so that a hang during init is detected on the next boot. But the detection path (if(!radioInit) return;) never writes the flag back totrue. Once it isfalse, every subsequent boot readsfalseand skips radio init forever. The radio stays dead until a manual/saveRadio.Fix
initCrashesNVS counter) and only then give up — booting cleanly with the radio off to avoid a hard boot loop with genuinely dead hardware. The counter resets on a successful init or a/saveRadioPOST.SomfyRemote::getNextRollingCode()no longer advances the stored rolling code whileradioInitis false, so commands issued during the dead window don't drift the code ahead of the motor and desync the remote once the radio recovers.Notes