Skip to content

Fix LEDs glitching at startup (ESP32 only)#5337

Open
DedeHai wants to merge 6 commits intowled:mainfrom
DedeHai:bootup_wifiglitchfix
Open

Fix LEDs glitching at startup (ESP32 only)#5337
DedeHai wants to merge 6 commits intowled:mainfrom
DedeHai:bootup_wifiglitchfix

Conversation

@DedeHai
Copy link
Collaborator

@DedeHai DedeHai commented Feb 2, 2026

This PR fixes the brief halt of LED animations by storing wifi credentials in non volatile memory which makes WiFi connect almost instantly after boot.
If multiple WiFi are configured, only the first one is stored and will benefit from this fix.

ESP8266 does not support this "fast connenct" feature.

To still prevent flash wear, the stored credentials are compared to config credentials and only updated if they changed. This comparison and updating is done only once at bootup.

Summary by CodeRabbit

  • Improvements
    • Reduced unnecessary flash writes on ESP32 devices to extend device lifespan.
    • Better detection and synchronization when stored WiFi credentials differ from current settings.
    • More reliable and efficient WiFi connection handling, with faster behavior after initial setup.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

Walkthrough

Added ESP32-specific one-time flash cache check in initConnection to compare stored WiFi credentials with in-memory config, set a flag to trigger an NVM update on next WiFi.begin if different, and default subsequent operations to RAM storage to avoid flash wear.

Changes

Cohort / File(s) Summary
WiFi configuration / NVM storage
wled00/wled.cpp
Added ESP32-only logic in initConnection: on first call read flash via esp_wifi_get_config, compare cached SSID/password to multiWiFi[0], set updateWiFiNVM if different, force flash storage for the next write when needed, and switch to RAM storage on subsequent calls to reduce flash wear. ESP8266 paths unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • blazoncek
  • netmindz
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix LEDs glitching at startup (ESP32 only)' clearly and accurately summarizes the main change: addressing LED animation glitches during ESP32 startup by improving WiFi connection speed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@wled00/wled.cpp`:
- Around line 678-679: The comparison is reading STA settings from the AP union
member (cachedConfig.ap.ssid / cachedConfig.ap.password) which is semantically
wrong; update the code to use the STA union member (cachedConfig.sta.ssid and
cachedConfig.sta.password) when comparing against multiWiFi[0].clientSSID and
multiWiFi[0].clientPass (the code around the strncmp checks), ensuring you
reference the STA fields for ESP_IF_WIFI_STA usage.

@DedeHai
Copy link
Collaborator Author

DedeHai commented Feb 2, 2026

Tested working on ESP32, C3, S3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant