Fix flash dialog stacking and key exchange reliability

1. Dismiss waiting dialog when flash progress dialog starts,
   preventing orphaned spinner dialog after flash completes.
2. Increase key exchange retries from 3 to 5 and initial delay
   from 500ms to 1000ms to give ESP more time to be ready
   after USB permission grant.
This commit is contained in:
eddy 2026-07-26 17:14:50 +02:00
commit 5acde17efb

View file

@ -204,6 +204,8 @@ class SettingsActivity : AppCompatActivity() {
}
private fun doFlashing(usbManager: UsbManager, device: UsbDevice) {
dialog?.dismiss()
dialog = null
showProgressDialog("Firmware Flashen", "Initialiseren...", STYLE_HORIZONTAL)
flasher = EspFlasher(this)
@ -338,8 +340,8 @@ class SettingsActivity : AppCompatActivity() {
try {
setupCdcControl(connection, device)
for (attempt in 1..3) {
Thread.sleep(500)
for (attempt in 1..5) {
Thread.sleep(1000L)
flushReadBuffer(connection, epIn)
@ -392,7 +394,7 @@ class SettingsActivity : AppCompatActivity() {
Log.w(TAG, "Attempt $attempt: no KEY response, retrying")
}
return KeyResult.Error("Geen sleutel gevonden na 3 pogingen")
return KeyResult.Error("Geen sleutel gevonden na 5 pogingen")
} catch (e: Exception) {
Log.e(TAG, "Key exchange error", e)
return KeyResult.Error("Fout: ${e.message}")