Skip to content

Commit dd14625

Browse files
committed
Fix delta stuff
1 parent 3f8cfbc commit dd14625

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

ArduinoCloudThing.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ ArduinoCloudPropertyGeneric& ArduinoCloudThing::addPropertyReal(int& property, S
130130
ArduinoCloudProperty<int> *thing = new ArduinoCloudProperty<int>(property, name);
131131
list.add(thing);
132132
thing->shadow_property = -1;
133+
thing->minDelta = 0;
133134
return *(reinterpret_cast<ArduinoCloudPropertyGeneric*>(thing));
134135
}
135136

@@ -149,6 +150,7 @@ ArduinoCloudPropertyGeneric& ArduinoCloudThing::addPropertyReal(float& property,
149150
}
150151
ArduinoCloudProperty<float> *thing = new ArduinoCloudProperty<float>(property, name);
151152
list.add(thing);
153+
thing->minDelta = 0.0f;
152154
thing->shadow_property = property - 1.0f;
153155
return *(reinterpret_cast<ArduinoCloudPropertyGeneric*>(thing));
154156
}

ArduinoCloudThing.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class ArduinoCloudProperty : public ArduinoCloudPropertyGeneric
192192
if (updatePolicy == ON_CHANGE) {
193193
return newData();
194194
}
195-
return (millis() - lastUpdated > updatePolicy * 1000) ;
195+
return ((millis() - lastUpdated) > (updatePolicy * 1000)) ;
196196
}
197197

198198
inline bool operator==(const ArduinoCloudProperty& rhs){
@@ -216,12 +216,12 @@ class ArduinoCloudProperty : public ArduinoCloudPropertyGeneric
216216

217217
template <>
218218
inline bool ArduinoCloudProperty<int>::newData() {
219-
return (property != shadow_property && abs(property - shadow_property) > minDelta );
219+
return (property != shadow_property && abs(property - shadow_property) >= minDelta );
220220
}
221221

222222
template <>
223223
inline bool ArduinoCloudProperty<float>::newData() {
224-
return (property != shadow_property && abs(property - shadow_property) > minDelta );
224+
return (property != shadow_property && abs(property - shadow_property) >= minDelta );
225225
}
226226

227227
template <>

0 commit comments

Comments
 (0)