Hi all,
Please go through my code and check whethear the procedure is correct for
calculating time between send() and sendDone().
--------------------------------------- TestTinySecM.nc
----------------------------------------------------
includes Surge;
module TestTinySecM {
provides interface StdControl;
uses {
interface SendMsg as Send;
interface ReceiveMsg as ReceiveIntMsg;
interface Leds;
interface TinySecMode;
//interface TimerJiffyAsync;
interface TimerJiffy as Jiffy;
interface Timer;
interface MyInterface;
}
}
implementation {
struct TOS_Msg data;
uint8_t value;
uint32_t counter=0;
uint32_t seq_no = 0;
uint32_t prev_pkt_etime=0;
bool busy = FALSE;
SurgeMsg *pReading;
uint32_t bit = 0;
uint8_t i = 0;
uint8_t j = 0;
task void sendit(){
uint16_t Len;
if( ( pReading = ( (SurgeMsg *)call MyInterface.getBuffer(&data,&Len) ) )
!=NULL ) {
pReading->type = SURGE_TYPE_SENSORREADING;
pReading->send = prev_pkt_etime;
//pReading->receive = 0;
pReading->seq_no = seq_no++;
}
call Jiffy.setPeriodic(1);
if ( ( call Send.send (TOS_BCAST_ADDR,sizeof(SurgeMsg),&data) ) == SUCCESS)
call Leds.redToggle();
else
post sendit();
}
command result_t StdControl.init() {
call Leds.init();
value = 0;
call TinySecMode.setTransmitMode(TINYSEC_AUTH_ONLY);
return SUCCESS;
}
event result_t Send.sendDone(TOS_MsgPtr m, result_t s) {
busy = FALSE;
atomic {
call Jiffy.stop();
prev_pkt_etime = counter;
counter = 0 ;
}
return s;
}
command result_t StdControl.start() {
call Timer.start(TIMER_REPEAT,4096);
return SUCCESS;
}
command result_t StdControl.stop() {
call Timer.stop();
return SUCCESS;
}
event TOS_MsgPtr ReceiveIntMsg.receive(TOS_MsgPtr m) {
return m;
}
event result_t Jiffy.fired() {
counter++;
return SUCCESS;
}
event result_t Timer.fired() {
if( ! busy ) {
busy = TRUE;
post sendit();
}
}
}
_________________________________________________________________
Missed any of the IPL matches ? Catch a recap of all the action on MSN Videos
http://msnvideos.in/iplt20/msnvideoplayer.aspx_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help