4141 * CTOR/DTOR
4242 ******************************************************************************/
4343
44- OTALogic::OTALogic (OTAStorage & ota_storage )
45- : _ota_storage(ota_storage)
44+ OTALogic::OTALogic ()
45+ : _ota_storage{ nullptr }
4646, _ota_state{OTAState::Init}
4747, _ota_error{OTAError::None}
4848{
@@ -105,7 +105,7 @@ void OTALogic::onOTADataReceived(uint8_t const * const data, size_t const length
105105
106106OTAState OTALogic::handle_Init ()
107107{
108- if (_ota_storage. init ()) {
108+ if (_ota_storage-> init ()) {
109109 return OTAState::Idle;
110110 } else {
111111 _ota_error = OTAError::StorageInitFailed;
@@ -123,7 +123,7 @@ OTAState OTALogic::handle_Idle()
123123
124124OTAState OTALogic::handle_StartDownload ()
125125{
126- if (_ota_storage. open ()) {
126+ if (_ota_storage-> open ()) {
127127 return OTAState::WaitForHeader;
128128 } else {
129129 _ota_error = OTAError::StorageOpenFailed;
@@ -187,7 +187,7 @@ OTAState OTALogic::handle_WaitForBinary()
187187OTAState OTALogic::handle_BinaryReceived ()
188188{
189189 /* Write to OTA storage */
190- if (_ota_storage. write (_mqtt_ota_buf.buf , _mqtt_ota_buf.num_bytes ) != _mqtt_ota_buf.num_bytes )
190+ if (_ota_storage-> write (_mqtt_ota_buf.buf , _mqtt_ota_buf.num_bytes ) != _mqtt_ota_buf.num_bytes )
191191 {
192192 _ota_error = OTAError::StorageWriteFailed;
193193 return OTAState::Error;
@@ -201,7 +201,7 @@ OTAState OTALogic::handle_BinaryReceived()
201201 _mqtt_ota_buf.num_bytes = 0 ;
202202
203203 if (_ota_bin_data.bytes_received >= _ota_bin_data.hdr_len ) {
204- _ota_storage. close ();
204+ _ota_storage-> close ();
205205 _ota_bin_data.crc32 = crc_finalize (_ota_bin_data.crc32 );
206206 return OTAState::Verify;
207207 }
@@ -212,10 +212,10 @@ OTAState OTALogic::handle_BinaryReceived()
212212OTAState OTALogic::handle_Verify ()
213213{
214214 if (_ota_bin_data.crc32 == _ota_bin_data.hdr_crc32 ) {
215- _ota_storage. deinit ();
215+ _ota_storage-> deinit ();
216216 return OTAState::Reset;
217217 } else {
218- _ota_storage. remove ();
218+ _ota_storage-> remove ();
219219 _ota_error = OTAError::ChecksumMismatch;
220220 return OTAState::Error;
221221 }
0 commit comments