41
41
* CTOR/DTOR
42
42
******************************************************************************/
43
43
44
- OTALogic::OTALogic (OTAStorage & ota_storage )
45
- : _ota_storage(ota_storage)
44
+ OTALogic::OTALogic ()
45
+ : _ota_storage{ nullptr }
46
46
, _ota_state{OTAState::Init}
47
47
, _ota_error{OTAError::None}
48
48
{
@@ -105,7 +105,7 @@ void OTALogic::onOTADataReceived(uint8_t const * const data, size_t const length
105
105
106
106
OTAState OTALogic::handle_Init ()
107
107
{
108
- if (_ota_storage. init ()) {
108
+ if (_ota_storage-> init ()) {
109
109
return OTAState::Idle;
110
110
} else {
111
111
_ota_error = OTAError::StorageInitFailed;
@@ -123,7 +123,7 @@ OTAState OTALogic::handle_Idle()
123
123
124
124
OTAState OTALogic::handle_StartDownload ()
125
125
{
126
- if (_ota_storage. open ()) {
126
+ if (_ota_storage-> open ()) {
127
127
return OTAState::WaitForHeader;
128
128
} else {
129
129
_ota_error = OTAError::StorageOpenFailed;
@@ -187,7 +187,7 @@ OTAState OTALogic::handle_WaitForBinary()
187
187
OTAState OTALogic::handle_BinaryReceived ()
188
188
{
189
189
/* 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 )
191
191
{
192
192
_ota_error = OTAError::StorageWriteFailed;
193
193
return OTAState::Error;
@@ -201,7 +201,7 @@ OTAState OTALogic::handle_BinaryReceived()
201
201
_mqtt_ota_buf.num_bytes = 0 ;
202
202
203
203
if (_ota_bin_data.bytes_received >= _ota_bin_data.hdr_len ) {
204
- _ota_storage. close ();
204
+ _ota_storage-> close ();
205
205
_ota_bin_data.crc32 = crc_finalize (_ota_bin_data.crc32 );
206
206
return OTAState::Verify;
207
207
}
@@ -212,10 +212,10 @@ OTAState OTALogic::handle_BinaryReceived()
212
212
OTAState OTALogic::handle_Verify ()
213
213
{
214
214
if (_ota_bin_data.crc32 == _ota_bin_data.hdr_crc32 ) {
215
- _ota_storage. deinit ();
215
+ _ota_storage-> deinit ();
216
216
return OTAState::Reset;
217
217
} else {
218
- _ota_storage. remove ();
218
+ _ota_storage-> remove ();
219
219
_ota_error = OTAError::ChecksumMismatch;
220
220
return OTAState::Error;
221
221
}
0 commit comments