diff --git a/src/ota/interface/OTAInterfaceDefault.cpp b/src/ota/interface/OTAInterfaceDefault.cpp index d39ec0f2..1b0a34fd 100644 --- a/src/ota/interface/OTAInterfaceDefault.cpp +++ b/src/ota/interface/OTAInterfaceDefault.cpp @@ -35,10 +35,9 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::startOTA() { context = new Context( OTACloudProcessInterface::context->url, [this](uint8_t c) { - // int res = - this->writeFlash(&c, 1); - - // TODO report error in write flash, throw it? + if (this->writeFlash(&c, 1) != 1) { + this->context->writeError = true; + } } ); @@ -107,6 +106,12 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::fetch() { } parseOta(context->buffer, http_res); + + if(context->writeError) { + DEBUG_VERBOSE("OTA ERROR: File write error"); + res = ErrorWriteUpdateFileFail; + goto exit; + } } while((context->downloadState == OtaDownloadFile || context->downloadState == OtaDownloadHeader) && millis() - start < downloadTime); @@ -234,6 +239,7 @@ OTADefaultCloudProcessInterface::Context::Context( , headerCopiedBytes(0) , downloadedSize(0) , lastReportTime(0) + , writeError(false) , decoder(putc) { } static const uint32_t crc_table[256] = { diff --git a/src/ota/interface/OTAInterfaceDefault.h b/src/ota/interface/OTAInterfaceDefault.h index 8f7aaf18..9e09d3cf 100644 --- a/src/ota/interface/OTAInterfaceDefault.h +++ b/src/ota/interface/OTAInterfaceDefault.h @@ -74,6 +74,7 @@ class OTADefaultCloudProcessInterface: public OTACloudProcessInterface { uint32_t headerCopiedBytes; uint32_t downloadedSize; uint32_t lastReportTime; + bool writeError; // LZSS decoder LZSSDecoder decoder;