X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tos%2Flib%2Fftsp%2FTimeSyncP.nc;h=177c1dff6920e4a70ce53ef239ba29373626f5be;hb=bd818a82164e7a40010adc2e2b9c3c1a2180dd71;hp=db59408b5054f625187cd4ea1515b55f48dc0abc;hpb=52b2570b0e032cc67044d2ab46d90f6bed93620f;p=tinyos-2.x.git diff --git a/tos/lib/ftsp/TimeSyncP.nc b/tos/lib/ftsp/TimeSyncP.nc index db59408b..177c1dff 100644 --- a/tos/lib/ftsp/TimeSyncP.nc +++ b/tos/lib/ftsp/TimeSyncP.nc @@ -43,6 +43,7 @@ generic module TimeSyncP(typedef precision_tag) interface TimeSyncAMSend as Send; interface Receive; interface Timer; + interface Random; interface Leds; interface TimeSyncPacket; interface LocalTime as LocalTime; @@ -316,6 +317,7 @@ implementation if( diff < -16 || diff > 16 ) return msg; #endif + if( (state & STATE_PROCESSING) == 0 && call TimeSyncPacket.isValid(msg)) { message_t* old = processedMsg; @@ -358,7 +360,6 @@ implementation } outgoingMsg->globalTime = globalTime; - #ifdef LOW_POWER_LISTENING call LowPowerListening.setRemoteWakeupInterval(&outgoingMsgBuffer, LPL_INTERVAL); #endif @@ -414,11 +415,8 @@ implementation } command error_t TimeSyncMode.setMode(uint8_t mode_){ - if (mode == mode_) - return SUCCESS; - if (mode_ == TS_TIMER_MODE){ - call Timer.startPeriodic((uint32_t)1000 * BEACON_RATE); + call Timer.startPeriodic((uint32_t)(896U+(call Random.rand16()&0xFF)) * BEACON_RATE); } else call Timer.stop(); @@ -466,10 +464,9 @@ implementation command error_t StdControl.start() { - mode = TS_TIMER_MODE; heartBeats = 0; outgoingMsg->nodeID = TOS_NODE_ID; - call Timer.startPeriodic((uint32_t)1000 * BEACON_RATE); + call TimeSyncMode.setMode(TS_TIMER_MODE); return SUCCESS; }