Skip to content

Commit dfffdc9

Browse files
committed
Extracting initialisation of MQTT OTA buffer and control data for binary OTA data into separate functions
1 parent 6a8b597 commit dfffdc9

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/utility/ota/OTALogic.cpp

+16-7
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,8 @@ OTALogic::OTALogic(OTAStorage & ota_storage)
3939
, _ota_state{OTAState::Init}
4040
, _ota_error{OTAError::None}
4141
{
42-
memset(_mqtt_ota_buf.buf, 0U, sizeof(_mqtt_ota_buf.buf));
43-
_mqtt_ota_buf.num_bytes = 0;
44-
45-
_ota_bin_data.hdr_len = 0;
46-
_ota_bin_data.hdr_crc32 = 0;
47-
_ota_bin_data.bytes_received = 0;
48-
_ota_bin_data.crc32 = crc_init();
42+
init_mqtt_ota_buffer();
43+
init_ota_binary_data();
4944
}
5045

5146
/******************************************************************************
@@ -233,3 +228,17 @@ OTAState OTALogic::handle_Reset()
233228
#endif /* HOST */
234229
return OTAState::Reset;
235230
}
231+
232+
void OTALogic::init_mqtt_ota_buffer()
233+
{
234+
memset(_mqtt_ota_buf.buf, 0U, sizeof(_mqtt_ota_buf.buf));
235+
_mqtt_ota_buf.num_bytes = 0;
236+
}
237+
238+
void OTALogic::init_ota_binary_data()
239+
{
240+
_ota_bin_data.hdr_len = 0;
241+
_ota_bin_data.hdr_crc32 = 0;
242+
_ota_bin_data.bytes_received = 0;
243+
_ota_bin_data.crc32 = crc_init();
244+
}

src/utility/ota/OTALogic.h

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ class OTALogic
106106
OTAState handle_Verify();
107107
OTAState handle_Reset();
108108

109+
void init_mqtt_ota_buffer();
110+
void init_ota_binary_data();
111+
109112
};
110113

111114
#endif /* ARDUINO_OTA_LOGIC_H_ */

0 commit comments

Comments
 (0)