PUD: start OLSR and uplink tx timers on init
authorFerry Huberts <f.huberts@mindef.nl>
Mon, 5 Dec 2011 09:54:04 +0000 (10:54 +0100)
committerFerry Huberts <f.huberts@mindef.nl>
Mon, 5 Dec 2011 10:51:05 +0000 (11:51 +0100)
so that uplink will start reporting to relay server even
though no valid position was obtained yet

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

index 7734a01..d8b35d7 100644 (file)
@@ -631,6 +631,31 @@ static void detemineMoving(PositionUpdateEntry * avg,
        return;
 }
 
+/**
+ Restart the OLSR tx timer
+ */
+static void restartOlsrTimer(void) {
+       if (!restartOlsrTxTimer(
+                       (state.externalState == STATIONARY) ? getUpdateIntervalStationary() :
+                                       getUpdateIntervalMoving(), &pud_olsr_tx_timer_callback)) {
+               pudError(0, "Could not restart OLSR tx timer, no periodic"
+                               " position updates will be sent to the OLSR network");
+       }
+}
+
+/**
+ Restart the uplink tx timer
+ */
+static void restartUplinkTimer(void) {
+       if (!restartUplinkTxTimer(
+                       (state.externalState == STATIONARY) ? getUplinkUpdateIntervalStationary() :
+                                       getUplinkUpdateIntervalMoving(),
+                       &pud_uplink_timer_callback)) {
+               pudError(0, "Could not restart uplink timer, no periodic"
+                               " position updates will be uplinked");
+       }
+}
+
 /**
  Update the latest GPS information. This function is called when a packet is
  received from a rxNonOlsr interface, containing one or more NMEA strings with
@@ -818,22 +843,11 @@ bool receiverUpdateGpsInformation(unsigned char * rxBuffer, size_t rxCount) {
 
        if (updateTransmitGpsInformation) {
                TimedTxInterface interfaces = OLSR; /* always send over olsr */
-               if (!restartOlsrTxTimer(
-                               (state.externalState == STATIONARY) ? getUpdateIntervalStationary()
-                               : getUpdateIntervalMoving(), &pud_olsr_tx_timer_callback)) {
-                       pudError(0, "Could not restart OLSR tx timer, no periodic"
-                                       " position updates will be sent to the OLSR network");
-               }
+               restartOlsrTimer();
 
                if (isUplinkAddrSet()) {
                        interfaces |= UPLINK;
-                       if (!restartUplinkTxTimer(
-                                       (state.externalState == STATIONARY) ? getUplinkUpdateIntervalStationary()
-                                       : getUplinkUpdateIntervalMoving(), &pud_uplink_timer_callback)
-                                       ) {
-                               pudError(0, "Could not restart uplink timer, no periodic"
-                                               " position updates will be uplinked");
-                       }
+                       restartUplinkTimer();
                }
 
                /* do an immediate transmit */
@@ -895,6 +909,9 @@ bool startReceiver(void) {
                return false;
        }
 
+       restartOlsrTimer();
+       restartUplinkTimer();
+
        return true;
 }