@@ -439,11 +439,14 @@ void ArduinoIoTCloudTCP::onOTARequest()
439
439
}
440
440
441
441
/* Request binary via http-get */
442
+ /*
442
443
char get_msg[128];
443
444
snprintf(get_msg, 128, "GET /ota/%s HTTP/1.1", _ota_url.c_str());
444
445
DBG_VERBOSE("ArduinoIoTCloudTCP::%s \"%s\"", __FUNCTION__, get_msg);
445
446
446
447
ota_client.println(get_msg);
448
+ */
449
+ ota_client.println (" GET /ota/wifi1010-sha256-remote.ota HTTP/1.1" );
447
450
ota_client.println (" Host: www.107-systems.org" );
448
451
ota_client.println (" Connection: close" );
449
452
ota_client.println ();
@@ -453,26 +456,30 @@ void ArduinoIoTCloudTCP::onOTARequest()
453
456
size_t bytes_recv = 0 ;
454
457
String http_header;
455
458
456
- while (ota_client. available () )
459
+ for (; _ota_error == static_cast < int >(OTAError::None); )
457
460
{
458
- char const c = ota_client.read ();
459
- Serial.print (c);
460
-
461
- /* Check if header is complete. */
462
- if (!is_header_complete)
461
+ while (ota_client.available ())
463
462
{
464
- http_header += c;
465
- is_header_complete = http_header.endsWith (" \r\n\r\n " );
466
- break ;
463
+ char const c = ota_client.read ();
464
+
465
+ /* Check if header is complete. */
466
+ if (!is_header_complete)
467
+ {
468
+ http_header += c;
469
+ is_header_complete = http_header.endsWith (" \r\n\r\n " );
470
+ break ;
471
+ }
472
+
473
+ /* If we reach this point then the HTTP header has
474
+ * been received and we can feed the incoming binary
475
+ * data into the OTA state machine.
476
+ */
477
+ if (_ota_logic.onOTADataReceived (reinterpret_cast <uint8_t const *>(&c), 1 ) == 200 )
478
+ {
479
+ _ota_error = static_cast <int >(_ota_logic.update ());
480
+ bytes_recv += 200 ;
481
+ }
467
482
}
468
-
469
- /* If we reach this point then the HTTP header has
470
- * been received and we can feed the incoming binary
471
- * data into the OTA state machine.
472
- */
473
- _ota_logic.onOTADataReceived (reinterpret_cast <uint8_t const *>(&c), 1 );
474
- _ota_error = static_cast <int >(_ota_logic.update ());
475
- DBG_VERBOSE (" ArduinoIoTCloudTCP::%s %d bytes received" , __FUNCTION__, ++bytes_recv);
476
483
}
477
484
}
478
485
}
0 commit comments