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:
parent
e116f2b493
commit
5acde17efb
1 changed files with 5 additions and 3 deletions
|
|
@ -204,6 +204,8 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doFlashing(usbManager: UsbManager, device: UsbDevice) {
|
private fun doFlashing(usbManager: UsbManager, device: UsbDevice) {
|
||||||
|
dialog?.dismiss()
|
||||||
|
dialog = null
|
||||||
showProgressDialog("Firmware Flashen", "Initialiseren...", STYLE_HORIZONTAL)
|
showProgressDialog("Firmware Flashen", "Initialiseren...", STYLE_HORIZONTAL)
|
||||||
|
|
||||||
flasher = EspFlasher(this)
|
flasher = EspFlasher(this)
|
||||||
|
|
@ -338,8 +340,8 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
try {
|
try {
|
||||||
setupCdcControl(connection, device)
|
setupCdcControl(connection, device)
|
||||||
|
|
||||||
for (attempt in 1..3) {
|
for (attempt in 1..5) {
|
||||||
Thread.sleep(500)
|
Thread.sleep(1000L)
|
||||||
|
|
||||||
flushReadBuffer(connection, epIn)
|
flushReadBuffer(connection, epIn)
|
||||||
|
|
||||||
|
|
@ -392,7 +394,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
Log.w(TAG, "Attempt $attempt: no KEY response, retrying")
|
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) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Key exchange error", e)
|
Log.e(TAG, "Key exchange error", e)
|
||||||
return KeyResult.Error("Fout: ${e.message}")
|
return KeyResult.Error("Fout: ${e.message}")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue