Hi Sumit, I believe the code is correct. The first call of the timer triggers it after a random duration. This is to keep the durations different for different nodes. But once it is triggered you repeatedly call the single shot timer with a deterministic duration. This deterministic duration will maintain the original randomness throughout (assuming clock drifts etc are absent).
Hope this helps, Kannan. Quoting Sumit Gupta <[EMAIL PROTECTED]>: > Hi, > > I am trying to understand the code of SurgeTelos application. Now this > application is using Component MultiHopLQI (located in > ..tinyos-1.x/tos/lib/MultiHopLQI/) > for routing. In this component developer use Timer component for > triggering > the collection of data and sending it to base station. > > Now I am bit confused. In this they are using argument TIMER_ONE_SHOT for > Timer, which I believe is wrong because it should be TIMER_REPEAT to > repeat > the process of sending data to base station over and over again. If not > then > how it has been implemented. Please explain if you understand what I am > missing out here. > > They used it at two places. First when application initialized, which > make > sense to me as they are awaking each node at random time, but I am not > sure > why they are using again at second time with TIMER_ONE_SHOT parameter. > Please give a look and help me understanding. Is it a typo? > > // First time when timer will initialized > command result_t StdControl.start() { > gLastHeard = 0; > call Timer.start(TIMER_ONE_SHOT, > call Random.rand() % (1024 * gUpdateInterval)); > return SUCCESS; > } > > //Second time when timer will fire > event result_t Timer.fired() { > post TimerTask(); > call Timer.start(TIMER_ONE_SHOT, 1024 * gUpdateInterval + 1); > return SUCCESS; > } > > Is it because Timer is being started again from Timer.fired function? I > just > want to make sure that I am understanding it in a right way. Please > advice. > > Regards, > Sumit Gupta > _______________________________________________ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help