Skip to content

fix(firmware): surface error state when BLE OTA connection attempts are exhausted#5700

Merged
jamesarich merged 1 commit into
mainfrom
jamesarich/fix-ble-ota-updates
Jun 1, 2026
Merged

fix(firmware): surface error state when BLE OTA connection attempts are exhausted#5700
jamesarich merged 1 commit into
mainfrom
jamesarich/fix-ble-ota-updates

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

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() returned false on failure without emitting FirmwareUpdateState.Error. The caller returned null, and the ViewModel had no fallback for this case — leaving the UI permanently frozen.

Changes

File Change
SecureDfuHandler.kt Throw DfuException.ConnectionFailed after all attempts exhausted (caught by existing error handler)
Esp32OtaUpdateHandler.kt Remove dead-code return false, use Unit return — structural consistency
FirmwareUpdateViewModel.kt Defense-in-depth: if startUpdate() returns without terminal state, transition to Error

Research & Validation

Cross-referenced against:

  • Nordic DFU Library (NordicSemiconductor/Android-DFU-Library) — always reports errors to the user; never silently swallows connection failures
  • Meshtastic firmware (meshtastic/firmware) — confirmed Heltec Tracker v1.2 is ESP32-S3 using OTA Loader partition; nRF52 devices use Adafruit Legacy DFU (service 0x1530)
  • Existing timeouts (15s connect, 10s scan × 3 retries × 4 attempts) are consistent with Nordic reference values

Testing

  • ./gradlew :feature:firmware:compileKotlinJvm
  • ./gradlew :feature:firmware:allTests
  • ./gradlew :feature:firmware:detekt ✅ (after spotlessApply)

…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>
@github-actions github-actions Bot added the bugfix PR tag label Jun 1, 2026
@jamesarich jamesarich added this pull request to the merge queue Jun 1, 2026
Merged via the queue into main with commit cc3b88d Jun 1, 2026
18 checks passed
@jamesarich jamesarich deleted the jamesarich/fix-ble-ota-updates branch June 1, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: BLE OTA Updates do not appear to work anymore

1 participant