File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -35,10 +35,9 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::startOTA() {
3535 context = new Context (
3636 OTACloudProcessInterface::context->url ,
3737 [this ](uint8_t c) {
38- // int res =
39- this ->writeFlash (&c, 1 );
40-
41- // TODO report error in write flash, throw it?
38+ if (this ->writeFlash (&c, 1 ) != 1 ) {
39+ this ->context ->writeError = true ;
40+ }
4241 }
4342 );
4443
@@ -107,6 +106,12 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::fetch() {
107106 }
108107
109108 parseOta (context->buffer , http_res);
109+
110+ if (context->writeError ) {
111+ DEBUG_VERBOSE (" OTA ERROR: File write error" );
112+ res = ErrorWriteUpdateFileFail;
113+ goto exit;
114+ }
110115 } while ((context->downloadState == OtaDownloadFile || context->downloadState == OtaDownloadHeader) &&
111116 millis () - start < downloadTime);
112117
@@ -234,6 +239,7 @@ OTADefaultCloudProcessInterface::Context::Context(
234239 , headerCopiedBytes(0 )
235240 , downloadedSize(0 )
236241 , lastReportTime(0 )
242+ , writeError(false )
237243 , decoder(putc) { }
238244
239245static const uint32_t crc_table[256 ] = {
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ class OTADefaultCloudProcessInterface: public OTACloudProcessInterface {
7474 uint32_t headerCopiedBytes;
7575 uint32_t downloadedSize;
7676 uint32_t lastReportTime;
77+ bool writeError;
7778
7879 // LZSS decoder
7980 LZSSDecoder decoder;
You can’t perform that action at this time.
0 commit comments