Hi all,
I am trying to make a simple localization setup. I have 6 TelosB motes and they
are programmed as follow:
*TelosB #1* - I have installed BaseStation app on it and gave it TOS_NODE_ID
of 1 when I uploaded the program
*TelosB #2* - Is my remote node, I mean I move it close to the stationary
nodes to receive packet from them (the most important part is the recive event
that you can see below:)
*TelosB #3 ~ #6* - Are my stationary nodes. I have set the transmission power
to minimum for these 4 nodes and I have put them in distances like 2 meters of
eachother.
So, I programmed the stationary nodes to send a simple packet to destionation
address of 2, that is the remote mote. And I can see when I move the remote
mote close to stationary nodes, its led0 blinks, indicationg that it is
receiving something from a nearby stationary node.
The remote node then supposed to read the comming packet, and send the
TOS_NODE_ID of the stationary node to BaseStation, and BaseStation simply
prints the packet content on terminal.
Everything works fine, exepct a big problem! After turning on the remote node,
The remote node only sends the TOS_NODE_ID of the first stationary node that it
was near it when it got powered on. When I move to the next stationary node, it
receives packet from new node but it still sends the TOS_NODE_ID of the first
node that ot was near it.
*Example: *
I turn on the remote node near stationary node #3, then I can see on terminal
that the node number was 3...Everything fine so far...Then I move to node #4,
somewhere in the middle of the way to next node, well I dont receive packet
because the transmission power is low. When I reach the node #4, the leds on
remote node (#2) starts blinking and I start to see output on terminal again
but it still shows the node id was 3, so it does not get updated.
If I turn off and turn on again near node #4, then I can see on terminal the
correct node ID, but when I go to another node, it still shows the last node id.
I am sure that I gave correct node ids when uploading the program. So I beleive
this could be a code problem.
Can you please check my code?
*Here is the message in header file that is same for remote and stationary
nodes:*
typedef nx_struct LocalNodeMsg
{
nx_uint16_t NodeId;
} LocalNodeMsg_t;
*Here is the code that sends packets from stationary nodes to remote node:*
//Global vars
bool _radioBusy = FALSE; //indicates if radio chip is busy sending/receiving
message_t _packet; // static storage for making packets
event void Boot.booted()
{
call RadioControl.start();
}
event void SendTimer.fired()
{
if(_radioBusy == FALSE)
{
LocalNodeMsg_t* pkt = call Packet.getPayload(& _packet,
sizeof(LocalNodeMsg_t));
pkt -> NodeId = TOS_NODE_ID; //Assign the node ID to packet
if(call AMSend.send(2, & _packet, sizeof(LocalNodeMsg_t)) == SUCCESS)
{
call Leds.led2On();
_radioBusy = TRUE;
}
}
}
*Here is the code in the remote node that sends node id to BaseStation:*
event message_t * RadioReceive.receive(message_t *msg, void *payload, uint8_t
len)
{
if(len == sizeof(LocalNodeMsg_t))
{
LocalNodeMsg_t *locPkt = (LocalNodeMsg_t*) payload;
LocalNodeMsg_t *pkt =
call RadioPacket.getPayload(&posPkt, sizeof(LocalNodeMsg_t));
pkt->NodeId = locPkt->NodeId;
if(call RadioSend.send(1, &posPkt, sizeof(LocalNodeMsg_t)) == SUCCESS)
{
radioBusy = TRUE;
}
call Leds.led1On();
return msg;
}
REGARDS,
Sean.
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help