Skip to content

Default value for update policy and rate limit #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ArduinoIoTCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void ArduinoIoTCloudClass::addPropertyReal(Property& property, String name, int
}

if (seconds == ON_CHANGE) {
addPropertyToContainer(_property_container, property, name, permission, tag).publishOnChange(minDelta, DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS).onUpdate(fn).onSync(synFn);
addPropertyToContainer(_property_container, property, name, permission, tag).publishOnChange(minDelta, Property::DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS).onUpdate(fn).onSync(synFn);
} else {
addPropertyToContainer(_property_container, property, name, permission, tag).publishEvery(seconds).onUpdate(fn).onSync(synFn);
}
Expand Down
2 changes: 0 additions & 2 deletions src/ArduinoIoTCloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ class ArduinoIoTCloudClass

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

static unsigned long const DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS = 500; /* Data rate throttled to 2 Hz */

/* The following methods are used for non-LoRa boards which can use the
* name of the property to identify a given property within a CBOR message.
*/
Expand Down
39 changes: 20 additions & 19 deletions src/property/Property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,26 @@
CTOR/DTOR
******************************************************************************/
Property::Property()
: _name(""),
_min_delta_property(0.0f),
_min_time_between_updates_millis(0),
_permission(Permission::Read),
_get_time_func{nullptr},
_update_callback_func(nullptr),
_sync_callback_func(nullptr),
_has_been_updated_once(false),
_has_been_modified_in_callback(false),
_last_updated_millis(0),
_update_interval_millis(0),
_last_local_change_timestamp(0),
_last_cloud_change_timestamp(0),
_identifier(0),
_attributeIdentifier(0),
_lightPayload(false),
_update_requested(false),
_encode_timestamp(false),
_timestamp(0)
: _name{""}
, _min_delta_property{0.0f}
, _min_time_between_updates_millis{DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS}
, _permission{Permission::Read}
, _get_time_func{nullptr}
, _update_callback_func{nullptr}
, _sync_callback_func{nullptr}
, _update_policy{UpdatePolicy::OnChange}
, _has_been_updated_once{false}
, _has_been_modified_in_callback{false}
, _last_updated_millis{0}
, _update_interval_millis{0}
, _last_local_change_timestamp{0}
, _last_cloud_change_timestamp{0}
, _identifier{0}
, _attributeIdentifier{0}
, _lightPayload{false}
, _update_requested{false}
, _encode_timestamp{false}
, _timestamp{0}
{

}
Expand Down
3 changes: 3 additions & 0 deletions src/property/Property.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ class Property {
virtual bool isPrimitive() {
return false;
};

static unsigned long const DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS = 500; /* Data rate throttled to 2 Hz */

protected:
/* Variables used for UpdatePolicy::OnChange */
String _name;
Expand Down