PUD: pull out clearing the MovementType
authorFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 5 Mar 2012 10:08:04 +0000 (11:08 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 5 Mar 2012 10:40:37 +0000 (11:40 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/receiver.c

index 396e4c3..a81690c 100644 (file)
@@ -147,6 +147,26 @@ static union olsr_ip_addr txGateway;
  * Functions
  */
 
+/**
+ Clear the MovementType
+ * @param result a pointer to the MovementType
+ */
+static void clearMovementType(MovementType * result) {
+       /* clear outputs */
+       result->moving = UNKNOWN;
+       result->differentGateway = UNSET;
+       result->overThresholds = UNKNOWN;
+       result->speedOverThreshold = UNKNOWN;
+       result->hDistanceOverThreshold = UNKNOWN;
+       result->vDistanceOverThreshold = UNKNOWN;
+       result->outside = UNKNOWN;
+       result->outsideHdop = UNKNOWN;
+       result->outsideVdop = UNKNOWN;
+       result->inside = UNKNOWN;
+       result->insideHdop = UNKNOWN;
+       result->insideVdop = UNKNOWN;
+}
+
 /**
  Determine whether s position is valid.
 
@@ -389,20 +409,6 @@ static void detemineMoving(PositionUpdateEntry * avg, union olsr_ip_addr * gatew
        bool vDistanceValid;
        bool vdopDistanceValid;
 
-       /* clear outputs */
-       result->moving = UNKNOWN;
-       result->differentGateway = UNSET;
-       result->overThresholds = UNKNOWN;
-       result->speedOverThreshold = UNKNOWN;
-       result->hDistanceOverThreshold = UNKNOWN;
-       result->vDistanceOverThreshold = UNKNOWN;
-       result->outside = UNKNOWN;
-       result->outsideHdop = UNKNOWN;
-       result->outsideVdop = UNKNOWN;
-       result->inside = UNKNOWN;
-       result->insideHdop = UNKNOWN;
-       result->insideVdop = UNKNOWN;
-
        /*
         * When the gateway is different from the gateway during last transmit, then
         * we force MOVING
@@ -759,6 +765,7 @@ bool receiverUpdateGpsInformation(unsigned char * rxBuffer, size_t rxCount) {
         */
 
        bestGateway = getBestUplinkGateway();
+       clearMovementType(&movementResult);
        detemineMoving(posAvgEntry, bestGateway, &txPosition, &txGateway, &movementResult);
        movingNow = movementResult.moving;