Skip to content

Commit

Permalink
Merge pull request eclipse-wakaama#363 from asarabi/observe
Browse files Browse the repository at this point in the history
Change lessThan and greaterThan condition.
  • Loading branch information
dnav committed Jun 12, 2018
2 parents 4066317 + 385f685 commit 3e038d3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/observe.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,19 +557,19 @@ void observe_step(lwm2m_context_t * contextP,
switch (dataP->type)
{
case LWM2M_TYPE_INTEGER:
if ((integerValue <= watcherP->parameters->lessThan
if ((integerValue < watcherP->parameters->lessThan
&& watcherP->lastValue.asInteger > watcherP->parameters->lessThan)
|| (integerValue >= watcherP->parameters->lessThan
|| (integerValue > watcherP->parameters->lessThan
&& watcherP->lastValue.asInteger < watcherP->parameters->lessThan))
{
LOG("Notify on lower threshold crossing");
notify = true;
}
break;
case LWM2M_TYPE_FLOAT:
if ((floatValue <= watcherP->parameters->lessThan
if ((floatValue < watcherP->parameters->lessThan
&& watcherP->lastValue.asFloat > watcherP->parameters->lessThan)
|| (floatValue >= watcherP->parameters->lessThan
|| (floatValue > watcherP->parameters->lessThan
&& watcherP->lastValue.asFloat < watcherP->parameters->lessThan))
{
LOG("Notify on lower threshold crossing");
Expand All @@ -587,19 +587,19 @@ void observe_step(lwm2m_context_t * contextP,
switch (dataP->type)
{
case LWM2M_TYPE_INTEGER:
if ((integerValue <= watcherP->parameters->greaterThan
if ((integerValue < watcherP->parameters->greaterThan
&& watcherP->lastValue.asInteger > watcherP->parameters->greaterThan)
|| (integerValue >= watcherP->parameters->greaterThan
|| (integerValue > watcherP->parameters->greaterThan
&& watcherP->lastValue.asInteger < watcherP->parameters->greaterThan))
{
LOG("Notify on lower upper crossing");
notify = true;
}
break;
case LWM2M_TYPE_FLOAT:
if ((floatValue <= watcherP->parameters->greaterThan
if ((floatValue < watcherP->parameters->greaterThan
&& watcherP->lastValue.asFloat > watcherP->parameters->greaterThan)
|| (floatValue >= watcherP->parameters->greaterThan
|| (floatValue > watcherP->parameters->greaterThan
&& watcherP->lastValue.asFloat < watcherP->parameters->greaterThan))
{
LOG("Notify on lower upper crossing");
Expand Down

0 comments on commit 3e038d3

Please sign in to comment.