Hi all,

I want to create a packet and each time that the packet is being created I want 
to send it to a specific sensor board knowing the TOS_NODE_ID of the nodes.

I have 3 telosb boards. I assign node ids of 1,2 and 3 to them when uploading 
the program. But for giving the address (switching between 2 addresses in 
"AMSend.send()" method, the compiler gives some errors. Here is part of my code:

bool _radioBusy = FALSE;
message_t _packet;
uint16_t _address = 2;

event void Boot.booted()
{
call Notify.enable();
call AMControl.start();
}

event void Notify.notify(button_state_t val)
{
if(_radioBusy == FALSE)
{
if(_address == 2)
{
_address = 3;
}
else
{
_address = 2;
}

//Creating the packet
MoteToMoteMsg_t* msg = call Packet.getPayload(& _packet , 
sizeof(MoteToMoteMsg_t));

msg->NodeId = TOS_NODE_ID;
msg->Data = (uint8_t) val; 

//Sending the packet
if(call AMSend.send(_address,& _packet , sizeof(MoteToMoteMsg_t)) == SUCCESS)
{
_radioBusy = TRUE;
}
}
}

And here is the error :

In file included from MoteToMoteAppC.nc:9:
In component `MoteToMoteC':
MoteToMoteC.nc: In function `Notify.notify':
MoteToMoteC.nc:56: syntax error before `*'
MoteToMoteC.nc:58: `msg' undeclared (first use in this function)
MoteToMoteC.nc:58: (Each undeclared identifier is reported only once
MoteToMoteC.nc:58: for each function it appears in.)

I found if I remove the if/else statement for checking for "_address" inside 
the Notify event, the progam compiles...but then I will only be able to send to 
node with ID of 2.

Can you please tell me how to solve this problem? I was following the guide 
here on youtube: http://youtu.be/CBhVPXpTz_Q

Thanks,
Sean.
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to