fix(ota): wake for async updates - #144
Merged
Merged
Conversation
ODevStudio
marked this pull request as ready for review
August 13, 2026 11:09
ODevStudio
force-pushed
the
audit/pr-018-wake-elegant-ota
branch
from
August 13, 2026 11:15
7c29c35 to
f944fdb
Compare
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.
Summary
b_softSleepdescribe applied rail state rather than an asynchronous sleep request.Root Cause
WiFi remains active during soft sleep, so ElegantOTA can start from the asynchronous HTTP task while
b_softSleepis true. OTA servicing is inside the awake-only loop section; without a main-loop wake, failure handling cannot clearb_otaand the scale can remain stuck in update mode.The original wake guard also raced with pending remote sleep. BLE and WebSocket callbacks published
b_softSleep = truebeforeWSP_SLEEP_ONactually powered the rails down. OTA could clear that requested state, after which the still-pending command powered the rails down without restoringb_softSleep, leaving the software state and hardware state inconsistent.Implementation
processWsPendingCmds()now publishes soft-sleep state beside the actual rail shutdown.processWsPendingCmds()runs before the OTA wake guard, so a pending sleep is applied and immediately recovered in the same loop pass when OTA is active.Safety / Reliability Impact
Async callbacks still perform no OLED, SPI, I2C, rail, or ADC work. The main loop remains the sole owner of remote sleep hardware transitions, and OTA servicing always reaches a powered, internally consistent state.
Compatibility
No HTTP endpoint, manifest, BLE, USB, WebSocket, storage, or reboot wire contract changes. Starting ElegantOTA while soft asleep now wakes the scale and display. Native, grinder, custom, and hardware targets were intentionally not run.
Regression Coverage
tools/test_ota_reboot_routing_contract.pyexercises pending-sleep plus asynchronous OTA start and requires pending-command dispatch before OTA recovery.tools/test_soft_sleep_ads_wake.pyrequires callbacks to defer state publication, latest wake intent to replace pending sleep, and applied state to change beside rail shutdown.Verification
python tools/test_ota_reboot_routing_contract.pypython tools/test_soft_sleep_ads_wake.pypython tools/test_pull_ota_contract.pypython tools/test_ota_input_isolation_contract.pypython tools/test_charging_wake_contract.pypython tools/test_ble_subscription_contract.pypio run -e esp32s3with an isolatedPLATFORMIO_CORE_DIRgit diff --checkAll passed. The ESP32-S3 build retains only the existing volatile-increment warnings in
src/wifi_setup.cpp.Hardware Verification
Not run. No physical soft-sleep HTTP upload, induced failure, recovery, or reboot was exercised.