fix autobug: don't fail updates (for now) if the spiffs has problems

1.2-legacy
Kevin Hester 2021-01-06 11:10:01 +08:00
rodzic 89fd3e16d8
commit 518e2438e8
2 zmienionych plików z 18 dodań i 8 usunięć

Wyświetl plik

@ -892,7 +892,7 @@ class MeshService : Service(), Logging {
// Do our startup init
try {
connectTimeMsec = System.currentTimeMillis()
SoftwareUpdateService.sendProgress(this, ProgressNotStarted) // Kinda crufty way of reiniting software update
SoftwareUpdateService.sendProgress(this, ProgressNotStarted, true) // Kinda crufty way of reiniting software update
startConfig()
} catch (ex: InvalidProtocolBufferException) {

Wyświetl plik

@ -194,8 +194,16 @@ class SoftwareUpdateService : JobIntentService(), Logging {
}
fun sendProgress(context: Context, p: Int) {
if(progress != p) {
/**
* Update our progress indication for GUIs
*
* @param isAppload if false, we don't report failure indications (because we consider spiffs non critical for now). But do report to analytics
*/
fun sendProgress(context: Context, p: Int, isAppload: Boolean) {
if(!isAppload && progress < 0)
reportError("Error while writing spiffs $progress") // See if this is happening in the wild
if(progress != p && (progress >= 0 || isAppload)) {
progress = p
val intent = Intent(ACTION_UPDATE_PROGRESS).putExtra(
@ -280,7 +288,7 @@ class SoftwareUpdateService : JobIntentService(), Logging {
errormsg("Ignoring failure to update spiffs on old appload")
}
assets.appLoad?.let { doUpdate(context, sync, it, FLASH_REGION_APPLOAD) }
sendProgress(context, ProgressSuccess)
sendProgress(context, ProgressSuccess, true)
}
// writable region codes in the ESP32 update code
@ -292,6 +300,8 @@ class SoftwareUpdateService : JobIntentService(), Logging {
* you can use it for the software update.
*/
private fun doUpdate(context: Context, sync: SafeBluetooth, assetName: String, flashRegion: Int = FLASH_REGION_APPLOAD) {
val isAppload = flashRegion == FLASH_REGION_APPLOAD
try {
val g = sync.gatt!!
val service = g.services.find { it.uuid == SW_UPDATE_UUID }
@ -306,7 +316,7 @@ class SoftwareUpdateService : JobIntentService(), Logging {
info("Starting firmware update for $assetName, flash region $flashRegion")
sendProgress(context,0)
sendProgress(context,0, isAppload)
val totalSizeDesc = getCharacteristic(SW_UPDATE_TOTALSIZE_CHARACTER)
val dataDesc = getCharacteristic(SW_UPDATE_DATA_CHARACTER)
val crc32Desc = getCharacteristic(SW_UPDATE_CRC32_CHARACTER)
@ -354,7 +364,7 @@ class SoftwareUpdateService : JobIntentService(), Logging {
// yet
val maxProgress = if(flashRegion != FLASH_REGION_APPLOAD)
50 else 100
sendProgress(context, firmwareNumSent * maxProgress / firmwareSize)
sendProgress(context, firmwareNumSent * maxProgress / firmwareSize, isAppload)
debug("sending block ${progress}%")
var blockSize = 512 - 3 // Max size MTU excluding framing
@ -384,7 +394,7 @@ class SoftwareUpdateService : JobIntentService(), Logging {
sync.readCharacteristic(updateResultDesc)
.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0)
if (updateResult != 0) {
sendProgress(context, ProgressUpdateFailed)
sendProgress(context, ProgressUpdateFailed, isAppload)
throw Exception("Device update failed, reason=$updateResult")
}
@ -395,7 +405,7 @@ class SoftwareUpdateService : JobIntentService(), Logging {
}
}
} catch (ex: BLEException) {
sendProgress(context, ProgressBleException)
sendProgress(context, ProgressBleException, isAppload)
throw ex // Unexpected BLE exception
}
}