Handle WiFi Connection Issues After OTA Updates with Build Version Tracking #668
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 OTA updates, WiFi connectivity sometimes fails and requires manual SSID changes to recover. This issue is often related to Arduino Core version changes that affect WiFi hostname handling, as evidenced by the commented-out lines in
_APSetup()
that mention fixing bugs when switching Arduino Core versions.Solution
This PR implements an automatic WiFi recovery mechanism using LittleFS to track the current build version:
/build_version.txt
on the LittleFS partitionFIRMWARE_VERSION
on every WiFi startupuserConfig
Implementation Details
The solution adds minimal code with surgical changes:
include/settings.h
: AddedBUILD_VERSION_FILENAME
definition for the version file pathsrc/HTTP_Server_Basic.cpp
:readStoredBuildVersion()
andwriteStoredBuildVersion()
startWifi()
with version check logic at startupBenefits
Testing
The logic has been validated with mock tests covering:
This addresses the core issue described in the problem statement while maintaining compatibility with existing functionality.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.registry.nm1.platformio.org
/usr/bin/python3 /home/REDACTED/.local/bin/pio test -e native
(dns block)/usr/bin/python3 /home/REDACTED/.local/bin/pio check --environment=native --flags=--enable=all --suppress=*:*/.pio/*
(dns block)api.registry.platformio.org
/usr/bin/python3 /home/REDACTED/.local/bin/pio test -e native
(dns block)/usr/bin/python3 /home/REDACTED/.local/bin/pio check --environment=native --flags=--enable=all --suppress=*:*/.pio/*
(dns block)collector.platformio.org
/usr/bin/python3 /home/REDACTED/.local/bin/pio test -e native
(dns block)/usr/bin/python3 /home/REDACTED/.local/bin/pio check --environment=native --flags=--enable=all --suppress=*:*/.pio/*
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Created from VS Code via the GitHub Pull Request extension.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.