PUD: always transmit last position
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 31 Jan 2012 13:38:21 +0000 (14:38 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 31 Jan 2012 13:38:42 +0000 (14:38 +0100)
So that late joiners see the last position of the node.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/receiver.c

index f0dfac3..176ceab 100644 (file)
@@ -179,25 +179,19 @@ static void txToAllOlsrInterfaces(TimedTxInterface interfaces) {
        union olsr_message * pu = &pu_uplink->msg.olsrMessage;
        unsigned int pu_size = 0;
 
        union olsr_message * pu = &pu_uplink->msg.olsrMessage;
        unsigned int pu_size = 0;
 
-       /*
-        * convert nmeaINFO to wireformat olsr message (always, since we always try
-        * to send the position)
-        */
        (void) pthread_mutex_lock(&transmitGpsInformation.mutex);
 
        (void) pthread_mutex_lock(&transmitGpsInformation.mutex);
 
-       /* only get the position when it is valid (no tx on invalid position) */
-       if (positionValid(&transmitGpsInformation.txPosition)) {
-               /* fixup timestamp when the position was not updated */
-               if (!transmitGpsInformation.updated) {
-                       nmea_time_now(&transmitGpsInformation.txPosition.nmeaInfo.utc);
-               }
-
-               txBufferBytesUsed += sizeof(UplinkHeader); /* keep before txBufferSpaceFree usage */
-               pu_size = gpsToOlsr(&transmitGpsInformation.txPosition.nmeaInfo, pu, txBufferBytesFree,
-                               ((state.externalState == MOVING) ? getUpdateIntervalMoving() : getUpdateIntervalStationary()));
-               txBufferBytesUsed += pu_size;
+       /* only fixup timestamp when the position is valid _and_ when the position was not updated */
+       if (positionValid(&transmitGpsInformation.txPosition) && !transmitGpsInformation.updated) {
+               nmea_time_now(&transmitGpsInformation.txPosition.nmeaInfo.utc);
        }
 
        }
 
+       /* convert nmeaINFO to wireformat olsr message */
+       txBufferBytesUsed += sizeof(UplinkHeader); /* keep before txBufferSpaceFree usage */
+       pu_size = gpsToOlsr(&transmitGpsInformation.txPosition.nmeaInfo, pu, txBufferBytesFree,
+                       ((state.externalState == MOVING) ? getUpdateIntervalMoving() : getUpdateIntervalStationary()));
+       txBufferBytesUsed += pu_size;
+
        transmitGpsInformation.updated = false;
        (void) pthread_mutex_unlock(&transmitGpsInformation.mutex);
 
        transmitGpsInformation.updated = false;
        (void) pthread_mutex_unlock(&transmitGpsInformation.mutex);