@@ -124,7 +124,9 @@ void OTALogic::onOTADataReceived(uint8_t const * const data, size_t const length
124
124
125
125
OTAState OTALogic::handle_Init ()
126
126
{
127
+ #ifndef HOST
127
128
DBG_VERBOSE (__PRETTY_FUNCTION__);
129
+ #endif
128
130
if (_ota_storage->init ()) {
129
131
return OTAState::Idle;
130
132
} else {
@@ -143,7 +145,9 @@ OTAState OTALogic::handle_Idle()
143
145
144
146
OTAState OTALogic::handle_StartDownload ()
145
147
{
148
+ #ifndef HOST
146
149
DBG_VERBOSE (__PRETTY_FUNCTION__);
150
+ #endif
147
151
if (_ota_storage->open ()) {
148
152
return OTAState::WaitForHeader;
149
153
} else {
@@ -154,7 +158,9 @@ OTAState OTALogic::handle_StartDownload()
154
158
155
159
OTAState OTALogic::handle_WaitForHeader ()
156
160
{
161
+ #ifndef HOST
157
162
DBG_VERBOSE (__PRETTY_FUNCTION__);
163
+ #endif
158
164
if (_mqtt_ota_buf.num_bytes >= OTA_BINARY_HEADER_SIZE) {
159
165
return OTAState::HeaderReceived;
160
166
}
@@ -163,7 +169,6 @@ OTAState OTALogic::handle_WaitForHeader()
163
169
164
170
OTAState OTALogic::handle_HeaderReceived ()
165
171
{
166
- DBG_VERBOSE (__PRETTY_FUNCTION__);
167
172
/* The OTA header has been received, let's extract it
168
173
* from the MQTT OTA receive buffer.
169
174
*/
@@ -184,8 +189,10 @@ OTAState OTALogic::handle_HeaderReceived()
184
189
_ota_bin_data.hdr_len = ota_header.header .len ;
185
190
_ota_bin_data.hdr_crc32 = ota_header.header .crc32 ;
186
191
192
+ #ifndef HOST
187
193
DBG_VERBOSE (" %s: header length = %d" , __PRETTY_FUNCTION__, _ota_bin_data.hdr_len );
188
194
DBG_VERBOSE (" %s: header CRC32 = %d" , __PRETTY_FUNCTION__, _ota_bin_data.hdr_crc32 );
195
+ #endif
189
196
190
197
/* Reset the counter which is responsible for keeping tabs on how many bytes have been received */
191
198
_ota_bin_data.bytes_received = 0 ;
@@ -226,7 +233,9 @@ OTAState OTALogic::handle_BinaryReceived()
226
233
_ota_bin_data.bytes_received += _mqtt_ota_buf.num_bytes ;
227
234
_mqtt_ota_buf.num_bytes = 0 ;
228
235
236
+ #ifndef HOST
229
237
DBG_VERBOSE (" %s: %d bytes written" , __PRETTY_FUNCTION__, _ota_bin_data.bytes_received );
238
+ #endif
230
239
231
240
if (_ota_bin_data.bytes_received >= _ota_bin_data.hdr_len ) {
232
241
_ota_storage->close ();
@@ -239,7 +248,9 @@ OTAState OTALogic::handle_BinaryReceived()
239
248
240
249
OTAState OTALogic::handle_Verify ()
241
250
{
251
+ #ifndef HOST
242
252
DBG_VERBOSE (__PRETTY_FUNCTION__);
253
+ #endif
243
254
if (_ota_bin_data.crc32 == _ota_bin_data.hdr_crc32 ) {
244
255
return OTAState::Rename;
245
256
} else {
@@ -251,7 +262,9 @@ OTAState OTALogic::handle_Verify()
251
262
252
263
OTAState OTALogic::handle_Rename ()
253
264
{
265
+ #ifndef HOST
254
266
DBG_VERBOSE (__PRETTY_FUNCTION__);
267
+ #endif
255
268
if (_ota_storage->rename ()) {
256
269
_ota_storage->deinit ();
257
270
return OTAState::Reset;
@@ -272,8 +285,10 @@ OTAState OTALogic::handle_Reset()
272
285
* update before starting the application, otherwise the app
273
286
* is started directly.
274
287
*/
288
+ #ifndef HOST
275
289
DBG_VERBOSE (__PRETTY_FUNCTION__);
276
290
delay (250 );
291
+ #endif
277
292
NVIC_SystemReset ();
278
293
#endif /* HOST */
279
294
return OTAState::Reset;
0 commit comments