30
30
31
31
#ifndef HOST
32
32
#include < Arduino.h>
33
+ #include < Arduino_DebugUtils.h>
33
34
#else
34
35
#include < algorithm> /* for std::min, otherwise Arduino defines min() */
35
36
using namespace std ;
@@ -123,6 +124,7 @@ void OTALogic::onOTADataReceived(uint8_t const * const data, size_t const length
123
124
124
125
OTAState OTALogic::handle_Init ()
125
126
{
127
+ DBG_VERBOSE (__func__);
126
128
if (_ota_storage->init ()) {
127
129
return OTAState::Idle;
128
130
} else {
@@ -141,6 +143,7 @@ OTAState OTALogic::handle_Idle()
141
143
142
144
OTAState OTALogic::handle_StartDownload ()
143
145
{
146
+ DBG_VERBOSE (__func__);
144
147
if (_ota_storage->open (" UPDATE.BIN.TMP" )) {
145
148
return OTAState::WaitForHeader;
146
149
} else {
@@ -151,6 +154,7 @@ OTAState OTALogic::handle_StartDownload()
151
154
152
155
OTAState OTALogic::handle_WaitForHeader ()
153
156
{
157
+ DBG_VERBOSE (__func__);
154
158
if (_mqtt_ota_buf.num_bytes >= OTA_BINARY_HEADER_SIZE) {
155
159
return OTAState::HeaderReceived;
156
160
}
@@ -159,6 +163,7 @@ OTAState OTALogic::handle_WaitForHeader()
159
163
160
164
OTAState OTALogic::handle_HeaderReceived ()
161
165
{
166
+ DBG_VERBOSE (__func__);
162
167
/* The OTA header has been received, let's extract it
163
168
* from the MQTT OTA receive buffer.
164
169
*/
@@ -179,6 +184,9 @@ OTAState OTALogic::handle_HeaderReceived()
179
184
_ota_bin_data.hdr_len = ota_header.header .len ;
180
185
_ota_bin_data.hdr_crc32 = ota_header.header .crc32 ;
181
186
187
+ DBG_VERBOSE (" %s: OTA binary len = %d" , __func__, _ota_bin_data.hdr_len );
188
+ DBG_VERBOSE (" %s: OTA binary crc32 = %X" , __func__, _ota_bin_data.hdr_crc32 );
189
+
182
190
/* Reset the counter which is responsible for keeping tabs on how many bytes have been received */
183
191
_ota_bin_data.bytes_received = 0 ;
184
192
@@ -218,6 +226,8 @@ OTAState OTALogic::handle_BinaryReceived()
218
226
_ota_bin_data.bytes_received += _mqtt_ota_buf.num_bytes ;
219
227
_mqtt_ota_buf.num_bytes = 0 ;
220
228
229
+ DBG_VERBOSE (" %s: %d bytes received" , __func__, _ota_bin_data.bytes_received );
230
+
221
231
if (_ota_bin_data.bytes_received >= _ota_bin_data.hdr_len ) {
222
232
_ota_storage->close ();
223
233
_ota_bin_data.crc32 = crc_finalize (_ota_bin_data.crc32 );
@@ -229,6 +239,7 @@ OTAState OTALogic::handle_BinaryReceived()
229
239
230
240
OTAState OTALogic::handle_Verify ()
231
241
{
242
+ DBG_VERBOSE (__func__);
232
243
if (_ota_bin_data.crc32 == _ota_bin_data.hdr_crc32 ) {
233
244
return OTAState::Rename;
234
245
} else {
@@ -240,6 +251,7 @@ OTAState OTALogic::handle_Verify()
240
251
241
252
OTAState OTALogic::handle_Rename ()
242
253
{
254
+ DBG_VERBOSE (__func__);
243
255
if (_ota_storage->rename (" UPDATE.BIN.TMP" , " UPDATE.BIN" )) {
244
256
_ota_storage->deinit ();
245
257
return OTAState::Reset;
@@ -252,6 +264,7 @@ OTAState OTALogic::handle_Rename()
252
264
253
265
OTAState OTALogic::handle_Reset ()
254
266
{
267
+ DBG_VERBOSE (__func__);
255
268
#if !defined(HOST) && !defined(ESP8266)
256
269
/* After completion of the reset a second stage bootloader
257
270
* such as the SFU is examining the OTA storage medium for
0 commit comments