Skip to content

Commit be1ccbd

Browse files
committed
Add bool flag and functions to handle properties appended to a CBOR message that may be discarded
1 parent ab527a1 commit be1ccbd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/property/Property.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Property::Property()
3939
, _update_policy{UpdatePolicy::OnChange}
4040
, _has_been_updated_once{false}
4141
, _has_been_modified_in_callback{false}
42+
, _has_been_appended_but_not_sended{false}
4243
, _last_updated_millis{0}
4344
, _update_interval_millis{0}
4445
, _last_local_change_timestamp{0}
@@ -106,6 +107,10 @@ bool Property::shouldBeUpdated() {
106107
return true;
107108
}
108109

110+
if (_has_been_appended_but_not_sended) {
111+
return true;
112+
}
113+
109114
if (_has_been_modified_in_callback) {
110115
return true;
111116
}
@@ -126,6 +131,13 @@ void Property::requestUpdate()
126131
_update_requested = true;
127132
}
128133

134+
void Property::appendCompleted()
135+
{
136+
if (_has_been_appended_but_not_sended) {
137+
_has_been_appended_but_not_sended = false;
138+
}
139+
}
140+
129141
void Property::execCallbackOnChange() {
130142
if (_update_callback_func != nullptr) {
131143
_update_callback_func();

src/property/Property.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class Property
174174
void setTimestamp(unsigned long const timestamp);
175175
bool shouldBeUpdated();
176176
void requestUpdate();
177+
void appendCompleted();
177178
void execCallbackOnChange();
178179
void execCallbackOnSync();
179180
void setLastCloudChangeTimestamp(unsigned long cloudChangeTime);
@@ -229,7 +230,8 @@ class Property
229230

230231
UpdatePolicy _update_policy;
231232
bool _has_been_updated_once,
232-
_has_been_modified_in_callback;
233+
_has_been_modified_in_callback,
234+
_has_been_appended_but_not_sended;
233235
/* Variables used for UpdatePolicy::TimeInterval */
234236
unsigned long _last_updated_millis,
235237
_update_interval_millis;

0 commit comments

Comments
 (0)