File tree Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -93,24 +93,25 @@ OTACloudProcessInterface::State OTADefaultCloudProcessInterface::fetch() {
93
93
uint32_t start = millis ();
94
94
95
95
do {
96
- if (http_client->available () == 0 ) {
97
- goto exit;
98
- }
99
-
100
- http_res = http_client->read (context->buffer , context->buf_len );
96
+ if (http_client->available ()) {
97
+ http_res = http_client->read (context->buffer , context->buf_len );
101
98
102
- if (http_res < 0 ) {
103
- DEBUG_VERBOSE (" OTA ERROR: Download read error %d" , http_res);
104
- res = OtaDownloadFail;
105
- goto exit;
106
- }
99
+ if (http_res < 0 ) {
100
+ DEBUG_VERBOSE (" OTA ERROR: Download read error %d" , http_res);
101
+ res = OtaDownloadFail;
102
+ goto exit;
103
+ }
107
104
108
- parseOta (context->buffer , http_res);
105
+ parseOta (context->buffer , http_res);
109
106
110
- if (context->writeError ) {
111
- DEBUG_VERBOSE (" OTA ERROR: File write error" );
112
- res = ErrorWriteUpdateFileFail;
113
- goto exit;
107
+ if (context->writeError ) {
108
+ DEBUG_VERBOSE (" OTA ERROR: File write error" );
109
+ res = ErrorWriteUpdateFileFail;
110
+ goto exit;
111
+ }
112
+ } else {
113
+ /* Avoid tight loop and allow yield */
114
+ delay (1 );
114
115
}
115
116
} while ((context->downloadState == OtaDownloadFile || context->downloadState == OtaDownloadHeader) &&
116
117
millis () - start < downloadTime);
You can’t perform that action at this time.
0 commit comments