Skip to content

Commit 85526e2

Browse files
committed
Adding debug verbose output for OTALogic
1 parent 1723c56 commit 85526e2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/utility/ota/OTALogic.cpp

+14
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(__PRETTY_FUNCTION__);
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(__PRETTY_FUNCTION__);
144147
if(_ota_storage->open()) {
145148
return OTAState::WaitForHeader;
146149
} else {
@@ -151,6 +154,7 @@ OTAState OTALogic::handle_StartDownload()
151154

152155
OTAState OTALogic::handle_WaitForHeader()
153156
{
157+
DBG_VERBOSE(__PRETTY_FUNCTION__);
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(__PRETTY_FUNCTION__);
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: header length = %d", __PRETTY_FUNCTION__, _ota_bin_data.hdr_len);
188+
DBG_VERBOSE("%s: header CRC32 = %d", __PRETTY_FUNCTION__, _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 written", __PRETTY_FUNCTION__, _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(__PRETTY_FUNCTION__);
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(__PRETTY_FUNCTION__);
243255
if(_ota_storage->rename()) {
244256
_ota_storage->deinit();
245257
return OTAState::Reset;
@@ -260,6 +272,8 @@ OTAState OTALogic::handle_Reset()
260272
* update before starting the application, otherwise the app
261273
* is started directly.
262274
*/
275+
DBG_VERBOSE(__PRETTY_FUNCTION__);
276+
delay(250);
263277
NVIC_SystemReset();
264278
#endif /* HOST */
265279
return OTAState::Reset;

0 commit comments

Comments
 (0)