mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix autobug during software update, treat sync timeouts just like async timeouts
This commit is contained in:
parent
8f3745c71b
commit
bd29a93a71
3 changed files with 50 additions and 40 deletions
|
|
@ -205,7 +205,7 @@ class SoftwareUpdateService : JobIntentService(), Logging {
|
|||
verStringToInt(if (swVer.isEmpty() || swVer == "unset") "99.99.99" else swVer)
|
||||
|
||||
(curVer > deviceVersion) && (deviceVersion >= minVer)
|
||||
// true
|
||||
true
|
||||
} catch (ex: Exception) {
|
||||
errormsg("Error finding swupdate info", ex)
|
||||
false // If we fail parsing our update info
|
||||
|
|
@ -313,25 +313,30 @@ class SoftwareUpdateService : JobIntentService(), Logging {
|
|||
firmwareNumSent += blockSize
|
||||
}
|
||||
|
||||
// We have finished sending all our blocks, so post the CRC so our state machine can advance
|
||||
val c = firmwareCrc.value
|
||||
info("Sent all blocks, crc is $c")
|
||||
sync.writeCharacteristic(
|
||||
crc32Desc,
|
||||
toNetworkByteArray(c.toInt(), BluetoothGattCharacteristic.FORMAT_UINT32)
|
||||
)
|
||||
try {
|
||||
// We have finished sending all our blocks, so post the CRC so our state machine can advance
|
||||
val c = firmwareCrc.value
|
||||
info("Sent all blocks, crc is $c")
|
||||
sync.writeCharacteristic(
|
||||
crc32Desc,
|
||||
toNetworkByteArray(c.toInt(), BluetoothGattCharacteristic.FORMAT_UINT32)
|
||||
)
|
||||
|
||||
// we just read the update result if !0 we have an error
|
||||
val updateResult =
|
||||
sync.readCharacteristic(updateResultDesc)
|
||||
.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0)
|
||||
if (updateResult != 0) {
|
||||
progress = -2
|
||||
throw Exception("Device update failed, reason=$updateResult")
|
||||
// we just read the update result if !0 we have an error
|
||||
val updateResult =
|
||||
sync.readCharacteristic(updateResultDesc)
|
||||
.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0)
|
||||
if (updateResult != 0) {
|
||||
progress = -2
|
||||
throw Exception("Device update failed, reason=$updateResult")
|
||||
}
|
||||
|
||||
// Device will now reboot
|
||||
} catch (ex: BLEException) {
|
||||
// We might get SyncContinuation timeout on the final write, assume the device simply rebooted to run the new load and we missed it
|
||||
errormsg("Assuming successful update", ex)
|
||||
}
|
||||
|
||||
// Device will now reboot
|
||||
|
||||
progress = -1 // success
|
||||
}
|
||||
} catch (ex: BLEException) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue