Skip to content

Commit cd6901d

Browse files
authored
Merge pull request #140 from arduino-libraries/default-value-for-update-policy
Default value for update policy and rate limit
2 parents cae230c + 7ad3cad commit cd6901d

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

src/ArduinoIoTCloud.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void ArduinoIoTCloudClass::addPropertyReal(Property& property, String name, int
6464
}
6565

6666
if (seconds == ON_CHANGE) {
67-
addPropertyToContainer(_property_container, property, name, permission, tag).publishOnChange(minDelta, DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS).onUpdate(fn).onSync(synFn);
67+
addPropertyToContainer(_property_container, property, name, permission, tag).publishOnChange(minDelta, Property::DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS).onUpdate(fn).onSync(synFn);
6868
} else {
6969
addPropertyToContainer(_property_container, property, name, permission, tag).publishEvery(seconds).onUpdate(fn).onSync(synFn);
7070
}

src/ArduinoIoTCloud.h

-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ class ArduinoIoTCloudClass
101101

102102
#define addProperty( v, ...) addPropertyReal(v, #v, __VA_ARGS__)
103103

104-
static unsigned long const DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS = 500; /* Data rate throttled to 2 Hz */
105-
106104
/* The following methods are used for non-LoRa boards which can use the
107105
* name of the property to identify a given property within a CBOR message.
108106
*/

src/property/Property.cpp

+20-19
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,26 @@
2929
CTOR/DTOR
3030
******************************************************************************/
3131
Property::Property()
32-
: _name(""),
33-
_min_delta_property(0.0f),
34-
_min_time_between_updates_millis(0),
35-
_permission(Permission::Read),
36-
_get_time_func{nullptr},
37-
_update_callback_func(nullptr),
38-
_sync_callback_func(nullptr),
39-
_has_been_updated_once(false),
40-
_has_been_modified_in_callback(false),
41-
_last_updated_millis(0),
42-
_update_interval_millis(0),
43-
_last_local_change_timestamp(0),
44-
_last_cloud_change_timestamp(0),
45-
_identifier(0),
46-
_attributeIdentifier(0),
47-
_lightPayload(false),
48-
_update_requested(false),
49-
_encode_timestamp(false),
50-
_timestamp(0)
32+
: _name{""}
33+
, _min_delta_property{0.0f}
34+
, _min_time_between_updates_millis{DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS}
35+
, _permission{Permission::Read}
36+
, _get_time_func{nullptr}
37+
, _update_callback_func{nullptr}
38+
, _sync_callback_func{nullptr}
39+
, _update_policy{UpdatePolicy::OnChange}
40+
, _has_been_updated_once{false}
41+
, _has_been_modified_in_callback{false}
42+
, _last_updated_millis{0}
43+
, _update_interval_millis{0}
44+
, _last_local_change_timestamp{0}
45+
, _last_cloud_change_timestamp{0}
46+
, _identifier{0}
47+
, _attributeIdentifier{0}
48+
, _lightPayload{false}
49+
, _update_requested{false}
50+
, _encode_timestamp{false}
51+
, _timestamp{0}
5152
{
5253

5354
}

src/property/Property.h

+3
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ class Property {
188188
virtual bool isPrimitive() {
189189
return false;
190190
};
191+
192+
static unsigned long const DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS = 500; /* Data rate throttled to 2 Hz */
193+
191194
protected:
192195
/* Variables used for UpdatePolicy::OnChange */
193196
String _name;

0 commit comments

Comments
 (0)