PUD: do not change state on unknown movement
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 13 Mar 2012 09:34:09 +0000 (10:34 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 14 Mar 2012 13:28:43 +0000 (14:28 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/receiver.c

index 55e77d3..aab87de 100644 (file)
@@ -725,8 +725,8 @@ static bool determineStateWithHysteresis(SubStateIndex subStateIndex, TristateBo
        } else if (movingNow == TRISTATE_BOOLEAN_UNSET) {
                newState = MOVEMENT_STATE_STATIONARY;
        } else {
-               /* force back to stationary for unknown movement */
-               newState = MOVEMENT_STATE_STATIONARY;
+               /* keep current sub-state */
+               newState = subState->internalState;
        }
        internalStateChange = (subState->internalState != newState);
        subState->internalState = newState;
@@ -772,8 +772,7 @@ static bool determineStateWithHysteresis(SubStateIndex subStateIndex, TristateBo
                                break;
 
                        default:
-                               /* when unknown do just as if we transition into stationary */
-                               newState = MOVEMENT_STATE_STATIONARY;
+                               /* when unknown then don't change state */
                                break;
                }
        }