OS: TinyOS 2.10/ TinyOS 2.x
Tools used : none
Assumptions: You are able to understand BlinkToRadio example from Tinyos tutorials.
Concept used: TX_POWER is set when sending a data to do multiple node transmission in a small room testbed. ( If you want to use it, you need to include the following in the AppC
components CC2420PacketC;
App.CC2420Packet->CC2420PacketC;)
When a packet is received, it check for the target. If target is not current node, it compares its own id with target. Nexthop id is chosen accordingly.
Running the program:
1)Modify the BlinkToRadio application in receiving packets and include the routing decision.
2) Write a test program. Fuse it to say nodeid 10. Try to send data to 14 and 3. For 14 it should hop right. For 3 it should hop left.
void sendMessage(uint8_t data, uint16_t nodeid)
{
if (!busy) {
BlinkToRadioMsg* btrpkt =
(BlinkToRadioMsg*)(call Packet.getPayload(&pkt, sizeof(BlinkToRadioMsg)));
if (btrpkt == NULL)
{
return;
}
btrpkt->nodeid = nodeid;
btrpkt->counter = data;
call CC2420Packet.setPower(&pkt,MY_TX_POWER);
//routing decision
if(nodeid
{
//send left
if (call AMSend.send(TOS_NODE_ID-1,
&pkt, sizeof(BlinkToRadioMsg)) == SUCCESS)
{
busy = TRUE;
}
}
else
{
//send right
if (call AMSend.send(TOS_NODE_ID+1,
&pkt, sizeof(BlinkToRadioMsg)) == SUCCESS)
{
busy = TRUE;
}
}
}
}
// The Header file is modified to get desired output
//Transmission power is set to two. This will help to run the program in actual mote with multiple hops in a small room.
#ifndef BLINKTORADIO_H
#define BLINKTORADIO_H
enum {
AM_BLINKTORADIO = 6,
TIMER_PERIOD_MILLI = 250,
MY_TX_POWER=1
};
typedef nx_struct BlinkToRadioMsg {
nx_uint16_t nodeid;
nx_uint16_t counter;
} BlinkToRadioMsg;
#endif
If you could implement this, try to do it for 2 dimension.