1.1.36 - autobug - cope with devices that have malformatted flash

pull/217/head
Kevin Hester 2021-01-09 14:50:32 +08:00
rodzic e458c85cb8
commit ed1a0e7fe0
2 zmienionych plików z 15 dodań i 6 usunięć

Wyświetl plik

@ -31,8 +31,8 @@ android {
applicationId "com.geeksville.mesh"
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
targetSdkVersion 29
versionCode 20135 // format is Mmmss (where M is 1+the numeric major number
versionName "1.1.35"
versionCode 20136 // format is Mmmss (where M is 1+the numeric major number
versionName "1.1.36"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {

Wyświetl plik

@ -13,6 +13,11 @@ import com.geeksville.util.exceptionReporter
import java.util.*
import java.util.zip.CRC32
/**
* Some misformatted ESP32s have problems
*/
class DeviceRejectedException() : BLEException("Device rejected filesize")
/**
* Move this somewhere as a generic network byte order function
*/
@ -292,6 +297,11 @@ class SoftwareUpdateService : JobIntentService(), Logging {
// If we can't update spiffs (because not supported by target), do not fail
errormsg("Ignoring failure to update spiffs on old appload")
}
catch(_: DeviceRejectedException) {
// the spi filesystem of this device is malformatted
reportError("Device rejected invalid spiffs partition")
}
assets.appLoad?.let { doUpdate(context, sync, it, FLASH_REGION_APPLOAD) }
sendProgress(context, ProgressSuccess, true)
}
@ -340,10 +350,9 @@ class SoftwareUpdateService : JobIntentService(), Logging {
catch(ex: BLECharacteristicNotFoundException) {
errormsg("Can't set flash programming region (old appload?")
if(flashRegion != FLASH_REGION_APPLOAD) {
errormsg("Can't set flash programming region (old appload?)")
throw ex
}
warn("Ignoring setting appload flashRegion (old appload?")
warn("Ignoring setting appload flashRegion")
}
context.assets.open(assetName).use { firmwareStream ->
@ -360,8 +369,8 @@ class SoftwareUpdateService : JobIntentService(), Logging {
// Our write completed, queue up a readback
val totalSizeReadback = sync.readCharacteristic(totalSizeDesc)
.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT32, 0)
if (totalSizeReadback == 0) // FIXME - handle this case
throw Exception("Device rejected file size")
if (totalSizeReadback == 0)
throw DeviceRejectedException()
// Send all the blocks
while (firmwareNumSent < firmwareSize) {