I understand that you want to unicast message form a node. I have
implemented this in two ways in my projects based on the requirement:
1) if the sender knows the node to which it wants to send the message
and receiver doesn't know from which node it wants to receive:
sender uses the target nodes ID to send the message:
call AMSend.send("the address", msg, len)
receiver on receiving check if message is intended for itself:
call AMPacket.isForMe(msg)
if it is, message is accepted
2) if sender doesn't know which node it wanted to send the message to
but receiver knows from which node it wants to receive:
sender broadcasts the message:
call AMSend.send(AM_BROADCAST_ADDR, &pkt, len)
receiver on receiving the messages check if the sender of this message
was the one from which it is expecting a message:
if(call AMPacket.source(msg)=="the address")
if it is message is accepted
On Sun, Oct 12, 2008 at 6:23 PM, Artemis Voulkidis <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I am trying to make a node send a data packet to another node, but i cannot
> figure out how i can achieve this..
>
> For example, I have created a struct:
>
> typedef nx_struct msg_send_temp {
> uint8_t msg_type;
> uint8_t temp
> } msg_send_temp_t;
>
> I try to send it with the help of Packet, and AMSend interfaces like this:
>
> void msg_send_temp(am_addr_t XXXXX) {
> msg_send_temp_t* pkt = (msg_send_temp_t*)call Packet.getPayload(&packet,
> sizeof(msg_send_temp_t));
> if(pkt == NULL){
> return;
> }
> pkt->msg_type = (uint8_t)SEND_TEMP_MSG;
> pkt->temp = node_temp;
> call AMSend.send(XXXXX, &packet, sizeof(msg_send_temp_t));
> dbg("NodeC","Temp information sent, node id = %hu.\n", node_id);
> return;
> }
>
> The XXXXX written above, is supposed to be an am_addr_t of the other node,
> whose am_addr_t needs to be taken from a Receive function like this:
>
> event message_t * Receive.receive(message_t * msg, void * payload, uint8_t
> len){
> if(len == sizeof(msg_request_temp_t)){
> msg_request_temp_t* pkt = (msg_request_temp_t*)payload;
> if (pkt->msg_type == REQUEST_IS_HEAD_MSG){
> msg_send_temp(XXXXX); //Here i should try to get the msg's am_addr_t..
> }
> return msg;
> }
>
>
> However, i cannot figure out how to take the address of the source node, to
> correctly pass it to the msg_send_temp(am_addr_t) function..
>
> Can i use simultaneously both the AMPacket and the Packet interface?
>
> Thank you in advance for your time,
>
> Artemis Voulkidis
>
> National Technical University of Athens
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help