Hi,
You are right about using a boolean and an additional timer (let's call
them isReceived and CheckerTimer respectively). CheckerTimer should have
half the duration when you want to check the receive() event. The first
time CheckerTimer is fired will serve to switch the value of isReceived to
false, from the second time (thus the duration since the last package
reception should surpassed the package sending interval), if CheckerTimer
is fired with isReceived==false, this means no package is received during
the predefined duration. The pseudo-code should be as follows:
//in init:
duration=500;//This is the package sending inteval
event receive(){
//data processing.....
isReceived=true;
CheckerTimer.restart(TIMER_REPEAT, duration/2 +1);
}
event CheckerTimer.fired(){
if (!isReceived) {
//It's bad, the package is not arrived as predicted
//Raise alert here
}
isReceived=false;
}
That's how I see it.
Best,
Ha.
On Tue, Mar 26, 2013 at 2:06 PM, Sean Dekker <[email protected]> wrote:
> Hi all,
>
> It seems that I can't figure out the logic for the following scenario:
>
> I have 2 TelosB nodes. and they sending packet to each other every 500 ms.
> Now if any of the nodes goes out of radio range, I want to light up an led
> on TelosB to indicate that there was no packet received after like 500 ms.
>
> I understand that I might use timers and set a boolean in received()
> event. But I have difficulties figuring out the logic. Is there a component
> or interface that takes care of this case by default in TinyOS? If not can
> you give me some help/hints?
>
> Sean.
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help