Hello,
Could you have a look to my program? thanks!!
Receive a message, save data timer (t2), send a message, save data timer
(t3)
includes CountMsg;
module CountReceptorM
{
provides interface StdControl;
uses interface ReceiveMsg;
uses interface Leds;
uses interface Timer;
uses interface SendMsg;
uses interface AMSend; // can I use it to send t2 and t3?
TOS_Msg m_msg;
int m_int;
bool m_sending;
}
Implementation
{
Uint32_t t2; // are them ok here?
Uint32_t t3;
enum // is CountMSg.h in the right position?
{
AM_COUNTMSG = 4,
};
typedef struct CountMsg
{
uint16_t n;
uint16_t src;
} CountMsg_t
command result_t StdControl.init() //inicializamos Leds
{
m_int = 0;
m_sending = FALSE;
call Leds.init();
return SUCCESS;
}
command result_t StdControl.start()
{
// nothing?
}
command result_t StdControl.stop()
{
return SUCCESS;
}
event TOS_MsgPtr ReceiveMsg.receive( TOS_MsgPtr msg )
{
CountMsg_t* body = (CountMsg_t*)msg->data;
call Leds.set( body->n );
return msg;
t2=msg; // save t2
}
event result_t Timer.fired()
{
if( m_sending == FALSE )
{
CountMsg_t* body = (CountMsg_t*)m_msg.data;
body->n = m_int;
body->src = TOS_LOCAL_ADDRESS;
if( call SendMsg.send( TOS_BCAST_ADDR, sizeof(CountMsg_t), &m_msg ) ==
SUCCESS )
{
call Leds.set( m_int );
m_sending = TRUE;
}
}
m_int++;
return SUCCESS;
}
event result_t SendMsg.sendDone( TOS_MsgPtr msg, result_t success )
{
m_sending = FALSE;
return SUCCESS;
t3 = SUCCESS // save t3
}
}
///////////////////////////////////
RTT = 2 t2 + t3
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help