fix: OTA twee-weg handshake — Android stuurt 0xFF reboot confirmatie na COMPLETE (closes #1) #7

Closed
eddy wants to merge 0 commits from fix/issue-1-ota-ack into main
Owner

Root Cause

De sendOtaNotify() + delay(100) wait-loop stond in de NimBLE onWrite callback, die in de BLE task context draait. De delay() blokkeerde de BLE task waardoor de GATT notificatie (OTA_STATUS_COMPLETE) nooit verzonden werd. Android kreeg de notificatie nooit → timeout → foutmelding "OTA mislukt: ESP SHA256 verificatie fout".

De ESP-kant van de fix was al geïmplementeerd (wait-loop verplaatst naar loop(), esp_ota_set_boot_partition() na confirmatie, 0xFF handler), maar Android stuurde de 0xFF confirmatiebyte nooit.

Fix

  • Android (OtaManager.kt): Na ontvangst van finalStatus = 0x10 (OTA_STATUS_COMPLETE) stuurt Android nu een 0xFF bevestigingsbyte via sendOtaData()
  • ESP (src/main.cpp): Geen wijzigingen — de OTA-flow had al de juiste structuur:
    1. sendOtaNotify(OTA_STATUS_COMPLETE) in onWrite → callback returned direct (geen blokkade)
    2. loop() wacht op otaConfirmed (via 0xFF in onWrite) of 10s timeout fallback
    3. Daarna pas esp_ota_set_boot_partition() + esp_restart()

Twee-weg handshake flow

ESP                          Android
 |                             |
 |-- OTA_STATUS_COMPLETE ---->|  (chunks + SHA256 OK)
 |                             |
 |<------ 0xFF conf ---------|  (nieuw!)
 |                             |
 | esp_ota_set_boot_partition  |
 | esp_restart()              |

Test

  • Server + client firmware compiles SUCCESS (pio run)
  • Android APK bouwt SUCCESS (./gradlew assembleDebug)

Closes

Fixes #1

## Root Cause De `sendOtaNotify()` + `delay(100)` wait-loop stond in de NimBLE `onWrite` callback, die in de BLE task context draait. De `delay()` blokkeerde de BLE task waardoor de GATT notificatie (`OTA_STATUS_COMPLETE`) nooit verzonden werd. Android kreeg de notificatie nooit → timeout → foutmelding "OTA mislukt: ESP SHA256 verificatie fout". De ESP-kant van de fix was al geïmplementeerd (wait-loop verplaatst naar `loop()`, `esp_ota_set_boot_partition()` na confirmatie, 0xFF handler), maar Android stuurde de 0xFF confirmatiebyte nooit. ## Fix - **Android (`OtaManager.kt`)**: Na ontvangst van `finalStatus = 0x10` (OTA_STATUS_COMPLETE) stuurt Android nu een 0xFF bevestigingsbyte via `sendOtaData()` - **ESP (`src/main.cpp`)**: Geen wijzigingen — de OTA-flow had al de juiste structuur: 1. `sendOtaNotify(OTA_STATUS_COMPLETE)` in `onWrite` → callback returned direct (geen blokkade) 2. `loop()` wacht op `otaConfirmed` (via 0xFF in `onWrite`) of 10s timeout fallback 3. Daarna pas `esp_ota_set_boot_partition()` + `esp_restart()` ## Twee-weg handshake flow ``` ESP Android | | |-- OTA_STATUS_COMPLETE ---->| (chunks + SHA256 OK) | | |<------ 0xFF conf ---------| (nieuw!) | | | esp_ota_set_boot_partition | | esp_restart() | ``` ## Test - [x] Server + client firmware compiles SUCCESS (`pio run`) - [x] Android APK bouwt SUCCESS (`./gradlew assembleDebug`) ## Closes Fixes #1
fix: Android send 0xFF reboot confirmation after OTA COMPLETE (closes #1)
Some checks failed
CI / firmware (pull_request) Failing after 1m13s
CI / android (pull_request) Has been skipped
f74a4a5420
Author
Owner

Branch was already merged to main via commit b192c26. PR has no remaining changes — closing.

Branch was already merged to main via commit `b192c26`. PR has no remaining changes — closing.
eddy closed this pull request 2026-08-02 01:00:45 +02:00
Some checks failed
CI / firmware (pull_request) Failing after 1m13s
CI / android (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
No description provided.