Skip to content

Commit e3256fe

Browse files
committed
Return number of bytes in OTA receive buffer when calling 'onOTADataReceived'
1 parent 6ad9944 commit e3256fe

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/utility/ota/OTALogic.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,20 @@ OTAError OTALogic::update()
103103
return _ota_error;
104104
}
105105

106-
void OTALogic::onOTADataReceived(uint8_t const * const data, size_t const length)
106+
uint32_t OTALogic::onOTADataReceived(uint8_t const * const data, size_t const length)
107107
{
108108
size_t const bytes_available = (MQTT_OTA_BUF_SIZE - _mqtt_ota_buf.num_bytes);
109109
if(length <= bytes_available)
110110
{
111111
memcpy(_mqtt_ota_buf.buf + _mqtt_ota_buf.num_bytes, data, length);
112112
_mqtt_ota_buf.num_bytes += length;
113+
return _mqtt_ota_buf.num_bytes;
113114
}
114115
else
115116
{
116117
_ota_state = OTAState::Error;
117118
_ota_error = OTAError::ReceivedDataOverrun;
119+
return 0;
118120
}
119121
}
120122

src/utility/ota/OTALogic.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class OTALogic
7676

7777

7878
OTAError update();
79-
void onOTADataReceived(uint8_t const * const data, size_t const length);
79+
uint32_t onOTADataReceived(uint8_t const * const data, size_t const length);
8080

8181
#ifdef HOST
8282
inline OTAState state() const { return _ota_state; }

0 commit comments

Comments
 (0)