Hi, i have the code below to get the RSSI from mica2 motes. I will use it to
try and track one moving mote. I have 5 motes in total. The moving mote (a)
will have the code below, in order to communicate with all stationary motes.
The stationary motes will have to get the RSSI relative to the moving mote and
send their information to the base station with node id=0. How can i change the
code below to send the RSSI value to a specific node? What is the exact
replacement i need to do to the code for e.g. to send to node 0? Please
help!!!Many many thanks in advance!!!!!!Vas includes PongMsg;includes
Timer;module PongM{ provides interface StdControl; uses interface Timer;
uses interface SendMsg; uses interface ReceiveMsg; uses interface ReceiveMsg
as PingMsg; uses interface Leds;}implementation{ TOS_Msg m_msg; TOS_MsgPtr
p_msg; PongMsg_t* pongmsg; int m_int; bool m_sending; command result_t
StdControl.init() { m_int = 0; m_sending = FALSE; pongmsg =
(PongMsg_t*)m_msg.data; p_msg = &m_msg; call Leds.init(); return
SUCCESS; } command result_t StdControl.start() { if (TOS_LOCAL_ADDRESS ==
1) { call Timer.start(TIMER_REPEAT, 500); } return SUCCESS; }
command result_t StdControl.stop() { return SUCCESS; } event result_t
Timer.fired() { call Leds.redToggle(); pongmsg->src =
TOS_LOCAL_ADDRESS; if (call SendMsg.send(TOS_BCAST_ADDR,
sizeof(PongMsg_t), p_msg)) { } return SUCCESS; } event result_t
SendMsg.sendDone( TOS_MsgPtr msg, result_t success ) { return SUCCESS; }
event TOS_MsgPtr ReceiveMsg.receive( TOS_MsgPtr msg ) { PongMsg_t*
_pongmsg; call Leds.greenToggle(); _pongmsg = (PongMsg_t*)msg->data;
if( _pongmsg->src != TOS_LOCAL_ADDRESS ) { pongmsg->src =
_pongmsg->src; pongmsg->src_rssi = msg->strength; pongmsg->dest =
TOS_LOCAL_ADDRESS; call SendMsg.send(_pongmsg->src, sizeof(PongMsg_t),
p_msg); } else { // send to UART call Leds.yellowToggle();
pongmsg->src = _pongmsg->src; pongmsg->src_rssi =
_pongmsg->src_rssi; pongmsg->dest = _pongmsg->dest; pongmsg->dest_rssi
= msg->strength; call SendMsg.send(TOS_UART_ADDR, sizeof(PongMsg_t),
p_msg); } return msg; } event TOS_MsgPtr PingMsg.receive( TOS_MsgPtr
msg ) { PingMsg_t* pingmsg = (PingMsg_t*)(msg->data); if (pingmsg->src
== TOS_UART_ADDR) { call Leds.redToggle(); pongmsg->src =
TOS_LOCAL_ADDRESS; if (call SendMsg.send(TOS_BCAST_ADDR,
sizeof(PongMsg_t), p_msg)) { call Leds.greenToggle(); } }
return msg; }}
_________________________________________________________________
Share what Santa brought you
https://www.mycooluncool.com_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help