File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -182,7 +182,25 @@ int Arduino_ESP32_OTA::download(const char * ota_url)
182
182
DEBUG_VERBOSE (" %s: Length of OTA binary according to HTTP header = %d bytes" , __FUNCTION__, content_length_val);
183
183
184
184
/* Read the OTA header ... */
185
- _client->read (_ota_header.buf , sizeof (OtaHeader));
185
+ bool is_http_data_timeout = false ;
186
+ for (int i = 0 ; i < sizeof (OtaHeader) && !is_http_data_timeout; i++)
187
+ {
188
+ for (unsigned long const start = millis ();;)
189
+ {
190
+ is_http_data_timeout = (millis () - start) > ARDUINO_ESP32_OTA_BINARY_BYTE_RECEIVE_TIMEOUT_ms;
191
+ if (is_http_data_timeout)
192
+ {
193
+ DEBUG_ERROR (" %s: timeout waiting data" , __FUNCTION__);
194
+ break ;
195
+ }
196
+ if (_client->available ())
197
+ {
198
+ _ota_header.buf [i] = _client->read ();
199
+ break ;
200
+ }
201
+ }
202
+ }
203
+ // _client->read(_ota_header.buf, sizeof(OtaHeader));
186
204
187
205
/* ... and check first length ... */
188
206
if (_ota_header.header .len != (content_length_val - sizeof (_ota_header.header .len ) - sizeof (_ota_header.header .crc32 ))) {
You can’t perform that action at this time.
0 commit comments