Skip to content

Commit 7ad3cad

Browse files
committed
Configure _min_time_between_updates_millis to DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS already in CTOR to facilitate rate limiting in to 2 Hz in default settings
1 parent 99bcd45 commit 7ad3cad

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
Property::Property()
3232
: _name{""}
3333
, _min_delta_property{0.0f}
34-
, _min_time_between_updates_millis{0}
34+
, _min_time_between_updates_millis{DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS}
3535
, _permission{Permission::Read}
3636
, _get_time_func{nullptr}
3737
, _update_callback_func{nullptr}

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)