99*/
1010#include < AIoTC_Config.h>
1111
12- #if OTA_ENABLED && ! defined(OFFLOADED_DOWNLOAD)
12+ #if OTA_ENABLED && ! defined(OFFLOADED_DOWNLOAD) && ! defined(HAS_NOTECARD)
1313#include " OTAInterfaceDefault.h"
1414#include " ../OTA.h"
1515
@@ -32,6 +32,8 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::startOTA() {
3232 assert (OTACloudProcessInterface::context != nullptr );
3333 assert (context == nullptr );
3434
35+ DEBUG_DEBUG (" OTADefaultCloudProcessInterface::%s initializing download from \" %s\" " , __FUNCTION__, OTACloudProcessInterface::context->url );
36+
3537 context = new Context (
3638 OTACloudProcessInterface::context->url ,
3739 [this ](uint8_t c) {
@@ -58,27 +60,27 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::startOTA() {
5860 http_client->endRequest ();
5961
6062 if (res == HTTP_ERROR_CONNECTION_FAILED) {
61- DEBUG_VERBOSE (" OTA ERROR: http client error connecting to server \" %s:%d\" " ,
63+ DEBUG_ERROR (" OTA ERROR: HTTP client error connecting to server \" %s:%d\" " ,
6264 context->parsed_url .host (), context->parsed_url .port ());
6365 return ServerConnectErrorFail;
6466 } else if (res == HTTP_ERROR_TIMED_OUT) {
65- DEBUG_VERBOSE (" OTA ERROR: http client timeout \" %s\" " , OTACloudProcessInterface::context->url );
67+ DEBUG_ERROR (" OTA ERROR: HTTP client timeout \" %s\" " , OTACloudProcessInterface::context->url );
6668 return OtaHeaderTimeoutFail;
6769 } else if (res != HTTP_SUCCESS) {
68- DEBUG_VERBOSE (" OTA ERROR: http client returned %d on get \" %s\" " , res, OTACloudProcessInterface::context->url );
70+ DEBUG_ERROR (" OTA ERROR: HTTP client returned %d on GET \" %s\" " , res, OTACloudProcessInterface::context->url );
6971 return OtaDownloadFail;
7072 }
7173
7274 int statusCode = http_client->responseStatusCode ();
7375
7476 if (statusCode != 200 ) {
75- DEBUG_VERBOSE (" OTA ERROR: get response on \" %s\" returned status %d" , OTACloudProcessInterface::context->url , statusCode);
77+ DEBUG_ERROR (" OTA ERROR: GET response on \" %s\" returned status %d" , OTACloudProcessInterface::context->url , statusCode);
7678 return HttpResponseFail;
7779 }
7880
79- // The following call is required to save the header value , keep it
81+ // The following call is required to save the header value ( keep it)
8082 if (http_client->contentLength () == HttpClient::kNoContentLengthHeader ) {
81- DEBUG_VERBOSE (" OTA ERROR: the response header doesn't contain \" ContentLength\" field" );
83+ DEBUG_ERROR (" OTA ERROR: The response header doesn't contain \" ContentLength\" field" );
8284 return HttpHeaderErrorFail;
8385 }
8486
@@ -107,15 +109,15 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::fetch() {
107109 http_res = http_client->read (context->buffer , context->buf_len );
108110
109111 if (http_res < 0 ) {
110- DEBUG_VERBOSE (" OTA ERROR: Download read error %d" , http_res);
112+ DEBUG_ERROR (" OTA ERROR: Download read error %d" , http_res);
111113 res = OtaDownloadFail;
112114 goto exit;
113115 }
114116
115117 parseOta (context->buffer , http_res);
116118
117119 if (context->writeError ) {
118- DEBUG_VERBOSE (" OTA ERROR: File write error" );
120+ DEBUG_ERROR (" OTA ERROR: File write error" );
119121 res = ErrorWriteUpdateFileFail;
120122 goto exit;
121123 }
@@ -130,17 +132,17 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::fetch() {
130132 // validate CRC
131133 context->calculatedCrc32 ^= 0xFFFFFFFF ; // finalize CRC
132134 if (context->header .header .crc32 == context->calculatedCrc32 ) {
133- DEBUG_VERBOSE ( " Ota download completed successfully" );
135+ DEBUG_DEBUG ( " OTADefaultCloudProcessInterface::%s OTA download completed successfully" , __FUNCTION__ );
134136 res = FlashOTA;
135137 } else {
136138 res = OtaHeaderCrcFail;
137139 }
138140 } else if (context->downloadState == OtaDownloadError) {
139- DEBUG_VERBOSE (" OTA ERROR: OtaDownloadError" );
141+ DEBUG_ERROR (" OTA ERROR: OtaDownloadError" );
140142
141143 res = OtaDownloadFail;
142144 } else if (context->downloadState == OtaDownloadMagicNumberMismatch) {
143- DEBUG_VERBOSE (" OTA ERROR: Magic number mismatch" );
145+ DEBUG_ERROR (" OTA ERROR: Magic number mismatch" );
144146 res = OtaHeaderMagicNumberFail;
145147 }
146148
@@ -196,7 +198,7 @@ void OTADefaultCloudProcessInterface::parseOta(uint8_t* buffer, size_t buf_len)
196198 context->downloadedSize += (cursor-buffer);
197199
198200 if ((millis () - context->lastReportTime ) > 10000 ) { // Report the download progress each X millisecond
199- DEBUG_VERBOSE (" OTA Download Progress %d/%d" , context->downloadedSize , contentLength);
201+ DEBUG_VERBOSE (" OTADefaultCloudProcessInterface::%s [%d] OTA Download Progress %d/%d" , __FUNCTION__, :: millis () , context->downloadedSize , contentLength);
200202
201203 reportStatus (context->downloadedSize );
202204 context->lastReportTime = millis ();
0 commit comments