fix(firmware): surface error state when BLE OTA connection attempts are exhausted#5700
Merged
Merged
Conversation
…re exhausted SecureDfuHandler.connectWithRetry() previously returned false on failure, causing the caller to return null without emitting FirmwareUpdateState.Error. This left the UI permanently stuck on "Connecting attempt 4/4". Changes: - SecureDfuHandler: throw DfuException.ConnectionFailed after all attempts are exhausted (matches Nordic DFU library behavior of always reporting errors) - Esp32OtaUpdateHandler: remove dead-code return false, use Unit return type - FirmwareUpdateViewModel: add defense-in-depth check after startUpdate() returns — if state is not terminal, transition to Error Fixes #5695 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Summary
Fixes #5695 — BLE OTA updates get stuck on "Connecting attempt X/Y" and never show an error when all connection attempts fail.
Root Cause
SecureDfuHandler.connectWithRetry()returnedfalseon failure without emittingFirmwareUpdateState.Error. The caller returnednull, and the ViewModel had no fallback for this case — leaving the UI permanently frozen.Changes
SecureDfuHandler.ktDfuException.ConnectionFailedafter all attempts exhausted (caught by existing error handler)Esp32OtaUpdateHandler.ktreturn false, useUnitreturn — structural consistencyFirmwareUpdateViewModel.ktstartUpdate()returns without terminal state, transition toErrorResearch & Validation
Cross-referenced against:
NordicSemiconductor/Android-DFU-Library) — always reports errors to the user; never silently swallows connection failuresmeshtastic/firmware) — confirmed Heltec Tracker v1.2 is ESP32-S3 using OTA Loader partition; nRF52 devices use Adafruit Legacy DFU (service0x1530)Testing
./gradlew :feature:firmware:compileKotlinJvm✅./gradlew :feature:firmware:allTests✅./gradlew :feature:firmware:detekt✅ (after spotlessApply)