@@ -11,6 +11,7 @@ ArduinoCloudProperty<T>::ArduinoCloudProperty(T & property, String const & name,
11
11
_update_callback_func(NULL ),
12
12
_update_policy(UpdatePolicy::OnChange),
13
13
_has_been_updated_once(false ),
14
+ _has_been_modified_in_callback(false ),
14
15
_min_delta_property(getInitialMinDeltaPropertyValue()),
15
16
_min_time_between_updates_millis(0 ),
16
17
_last_updated_millis(0 ),
@@ -52,9 +53,14 @@ ArduinoCloudProperty<T> & ArduinoCloudProperty<T>::publishEvery(unsigned long co
52
53
}
53
54
54
55
template <typename T>
55
- bool ArduinoCloudProperty<T>::shouldBeUpdated() const {
56
+ bool ArduinoCloudProperty<T>::shouldBeUpdated() {
56
57
if (!_has_been_updated_once) return true ;
57
58
59
+ if (_has_been_modified_in_callback) {
60
+ _has_been_modified_in_callback = false ;
61
+ return true ;
62
+ }
63
+
58
64
if (_update_policy == UpdatePolicy::OnChange) {
59
65
return (isValueDifferent (_property, _shadow_property) && ((millis () - _last_updated_millis) >= (_min_time_between_updates_millis)));
60
66
}
@@ -72,6 +78,10 @@ void ArduinoCloudProperty<T>::execCallbackOnChange() {
72
78
if (_update_callback_func != NULL ) {
73
79
_update_callback_func ();
74
80
}
81
+
82
+ if (!isValueDifferent (_property, _shadow_property)) {
83
+ _has_been_modified_in_callback = true ;
84
+ }
75
85
}
76
86
}
77
87
0 commit comments