Sending a packet over the radio is acheived by using AMSend.send(AM_BROADCAST_ADDR, msg, len). In receive.receive I can check from which node did I get the message. But how do I send the message back to the same node from which I received message. I have the node ID, how can I get the network address of the one from which I received data and send back to it. Not just only acknowledging the packet. I need to send data once I receive it. Any help will be appreciated.
Asked
Active
Viewed 387 times
1 Answers
1
The signature of AMSend.send
is:
command error_t send(am_addr_t addr, message_t* msg, uint8_t len);
where addr
is documented as address to which to send the packet. AM_BROADCAST_ADDR
is a constant denoting broadcast address: packets sent to that address are received by all nodes in radio range. Once you received a packet and obtained sender's id (by AMPacket.source
), provide is as addr
to AMSend.send
. It has the same type am_addr_t
which is basically an integer (8- or 16-bit).
Note that an id is typically assigned during compilation or programming a node (see this presentation, slide 61) and usually all nodes have by default the same id unless you assign one explicitly.

maral
- 1,431
- 1
- 10
- 15
-
Correct me if I am wrong in this snippet. Is this what you meant by? `uses{ interface AMSend; interface SplitControl as AMControl; interface Packet; interface AMPacket; }` `Receive.receive(msg_t* msg, void *payload, uint8_t len) {` `msg_t* data = (msg_t*)payload; am_addr_t addr = call AMPacket.source(msg); send_message(addr); //rest of the code } void send_message(addr){ //send msg to source now using AMSend.send() }` – Suraj Acharya Oct 03 '16 at 22:16