Skip to content

Commit fc22b8f

Browse files
committed
Adding various verbose debug output which can be disabled by disabling the DBG_VERBOSE macro within AIoTC_Config.h
1 parent becf54e commit fc22b8f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/utility/ota/OTALogic.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#ifndef HOST
3232
#include <Arduino.h>
33+
#include <Arduino_DebugUtils.h>
3334
#else
3435
#include <algorithm> /* for std::min, otherwise Arduino defines min() */
3536
using namespace std;
@@ -123,6 +124,7 @@ void OTALogic::onOTADataReceived(uint8_t const * const data, size_t const length
123124

124125
OTAState OTALogic::handle_Init()
125126
{
127+
DBG_VERBOSE(__func__);
126128
if (_ota_storage->init()) {
127129
return OTAState::Idle;
128130
} else {
@@ -141,6 +143,7 @@ OTAState OTALogic::handle_Idle()
141143

142144
OTAState OTALogic::handle_StartDownload()
143145
{
146+
DBG_VERBOSE(__func__);
144147
if(_ota_storage->open("UPDATE.BIN.TMP")) {
145148
return OTAState::WaitForHeader;
146149
} else {
@@ -151,6 +154,7 @@ OTAState OTALogic::handle_StartDownload()
151154

152155
OTAState OTALogic::handle_WaitForHeader()
153156
{
157+
DBG_VERBOSE(__func__);
154158
if(_mqtt_ota_buf.num_bytes >= OTA_BINARY_HEADER_SIZE) {
155159
return OTAState::HeaderReceived;
156160
}
@@ -159,6 +163,7 @@ OTAState OTALogic::handle_WaitForHeader()
159163

160164
OTAState OTALogic::handle_HeaderReceived()
161165
{
166+
DBG_VERBOSE(__func__);
162167
/* The OTA header has been received, let's extract it
163168
* from the MQTT OTA receive buffer.
164169
*/
@@ -179,6 +184,9 @@ OTAState OTALogic::handle_HeaderReceived()
179184
_ota_bin_data.hdr_len = ota_header.header.len;
180185
_ota_bin_data.hdr_crc32 = ota_header.header.crc32;
181186

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+
182190
/* Reset the counter which is responsible for keeping tabs on how many bytes have been received */
183191
_ota_bin_data.bytes_received = 0;
184192

@@ -218,6 +226,8 @@ OTAState OTALogic::handle_BinaryReceived()
218226
_ota_bin_data.bytes_received += _mqtt_ota_buf.num_bytes;
219227
_mqtt_ota_buf.num_bytes = 0;
220228

229+
DBG_VERBOSE("%s: %d bytes received", __func__, _ota_bin_data.bytes_received);
230+
221231
if(_ota_bin_data.bytes_received >= _ota_bin_data.hdr_len) {
222232
_ota_storage->close();
223233
_ota_bin_data.crc32 = crc_finalize(_ota_bin_data.crc32);
@@ -229,6 +239,7 @@ OTAState OTALogic::handle_BinaryReceived()
229239

230240
OTAState OTALogic::handle_Verify()
231241
{
242+
DBG_VERBOSE(__func__);
232243
if(_ota_bin_data.crc32 == _ota_bin_data.hdr_crc32) {
233244
return OTAState::Rename;
234245
} else {
@@ -240,6 +251,7 @@ OTAState OTALogic::handle_Verify()
240251

241252
OTAState OTALogic::handle_Rename()
242253
{
254+
DBG_VERBOSE(__func__);
243255
if(_ota_storage->rename("UPDATE.BIN.TMP", "UPDATE.BIN")) {
244256
_ota_storage->deinit();
245257
return OTAState::Reset;
@@ -252,6 +264,7 @@ OTAState OTALogic::handle_Rename()
252264

253265
OTAState OTALogic::handle_Reset()
254266
{
267+
DBG_VERBOSE(__func__);
255268
#if !defined(HOST) && !defined(ESP8266)
256269
/* After completion of the reset a second stage bootloader
257270
* such as the SFU is examining the OTA storage medium for

0 commit comments

Comments
 (0)