My main intension is to capture processing time of tinysec. That i was doing by
starting timer when timer expires it sends packet to tinysec. But my problem
is, when i receive the packet how can i read the packet time stamp and check
sending time and received time.. and this is my code...
------SenseDataM.nc -----
module SenseDataM {
provides {
interface StdControl;
interface IntOutput;
}
uses {
interface SendMsg;
interface ReceiveMsg;
interface TinySecMode;
interface Leds;
interface Timer;
}
}
implementation{
uint8_t msg1; // Simple Message stored in TOS_Msg data
uint16_t timer_value; // Counts no. of times timer expires
struct TOS_Msg data; // Packet to be send and receive
TOS_MsgPtr buffer; // Pointer to struct TOS_Msg ( for received
message )
uint8_t sendvalue; // No. of times packet is send
task void sendmsg(){
(data.data)[0] = msg1;
memset(data.data+1,0,29);
(data.data)[29] = 0xff;
call SendMsg.send(TOS_BCAST_ADDR,8,&data); // We need to Specify
address of mote
dbg(DBG_USR1,"Data send\n");
}
task void receivedMsg(){
if( sendvalue == 1 ){
dbg(DBG_USR2,"Packet received and message is %i\n",buffer);
dbg(DBG_USR2,"Packet elapsed time %i\n",timer_value);
}
}
command result_t StdControl.init(){
timer_value = msg1 = sendvalue = 0;
call Leds.init();
call TinySecMode.setTransmitMode(TINYSEC_ENCRYPT_AND_AUTH);
return SUCCESS;
}
command result_t StdControl.start(){
call Timer.start(TIMER_ONE_SHOT,512);
return SUCCESS;
}
command result_t StdControl.stop(){
return SUCCESS;
}
command result_t IntOutput.output(uint16_t value){
msg1 = (uint8_t)value;
dbg(DBG_USR1,"Timer Interrupted so Sending Packet %i\n",msg1);
post sendmsg();
signal IntOutput.outputComplete(SUCCESS);
return SUCCESS;
}
event result_t SendMsg.sendDone(TOS_MsgPtr msg,result_t success){
call Leds.redToggle();
return success;
}
event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr m){
buffer = m;
dbg(DBG_CRYPTO,"Message received at Application layer\n");
post receivedMsg();
return buffer;
}
event result_t Timer.fired(){
timer_value++; // Timer count
if( sendvalue == 0 ){
call IntOutput.output(1);
sendvalue += 1;
}
dbg(DBG_USR1,"Timer expired:%i\n",timer_value);
return SUCCESS;
}
}
_________________________________________________________________
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