File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 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)
182182 DEBUG_VERBOSE (" %s: Length of OTA binary according to HTTP header = %d bytes" , __FUNCTION__, content_length_val);
183183
184184 /* 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));
186204
187205 /* ... and check first length ... */
188206 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