Hi all,
How can a sensor node receive packets from another sensor node using Xmesh
(Crossbow) and TinyOS1? I read the material and I just saw the upstream
transmission mode using sink nodes, but I want a communication between
sensor nodes (source and destination). I changed the source
BASE_STATION_ADDRESS for the specific NODE_ADDRESS (ex: 1), but the code
doesnt work.
Thanks in advance.
-----
module ExampleM {
provides {
interface StdControl;
}
uses {
interface Leds;
interface MhopSend as Send;
interface Receive;
........
implementation {
....
TOS_Msg msg_buf;
TOS_MsgPtr msg_ptr;
HealthMsg *h_msg;
norace bool sending_packet,sensinginsession;
norace uint8_t state;
XDataMsg pack;
bool sleeping; // application command state
......
/****************************************************************************
* Task to xmit radio message
*
****************************************************************************/
task void send_radio_msg(){
uint16_t len;
XDataMsg *data;
uint8_t i;
if(sending_packet) return;
call Leds.yellowOn();
atomic sending_packet=TRUE;
data = (XDataMsg*)call Send.getBuffer(msg_ptr, &len);
for (i=0; i<= sizeof(XDataMsg)-1; i++)
((uint8_t*) data)[i] = ((uint8_t*)&pack)[i];
data->xMeshHeader.board_id = SENSOR_BOARD_ID;
data->xMeshHeader.packet_id = 1;
data->xMeshHeader.parent = call RouteControl.getParent();
data->xMeshHeader.packet_id = data->xMeshHeader.packet_id | 0x80;
#if FEATURE_UART_SEND
if (TOS_LOCAL_ADDRESS != 0) {
call Leds.yellowOn();
call PowerMgrDisable();
TOSH_uwait(1000);
if (call SendUART.send(TOS_UART_ADDR, sizeof(XDataMsg),msg_ptr) !=
SUCCESS)
{
atomic sending_packet = FALSE;
call Leds.greenToggle();
call PowerMgrEnable();
}
}
else
#endif
{
// Send the RF packet!
if (call Send.send(NODE_ADDRESS,MODE_UPSTREAM,msg_ptr,
sizeof(XDataMsg)) != SUCCESS) {
atomic sending_packet = FALSE;
call Leds.yellowOn();
call Leds.greenOff();
}
}
return;
}
/****************************************************************************
#if FEATURE_UART_SEND
/**
* Handle completion of sent UART packet.
*
* @author Martin Turon
* @version 2004/7/21 mturon Initial revision
*/
event result_t SendUART.sendDone(TOS_MsgPtr msg, result_t success)
{
//if (msg->addr == TOS_UART_ADDR) {
atomic msg_ptr = msg;
msg_ptr->addr = TOS_BCAST_ADDR;
if (call
Send.send(NODE_ADDRESS,MODE_UPSTREAM,msg_ptr,sizeof(XDataMsg)) != SUCCESS) {
atomic sending_packet = FALSE;
call Leds.yellowOff();
}
if (TOS_LOCAL_ADDRESS != 0) // never turn on power mgr for base
call PowerMgrEnable();
//}
return SUCCESS;
}
#endif
/****************************************************************************/
* Receive packets from sensor nodes.
*
****************************************************************************/
event TOS_MsgPtr Receive.receive(TOS_MsgPtr msg, void* payload, uint16_t
payloadLen) {
call Leds.redOn();
return msg;
}
.....
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help