On Sat, Dec 29, 2012 at 2:41 AM, Swetha <[email protected]> wrote: > Hello all, > > I am new to Tiny OS and I am waiting for the motes to learn further and > test the program, > > I have read the concept of mote to mote radio communication and my doubt > is in the usage of message_t; > > > implementation { > .. > message_t pkt; // this is used to hold data for transmission > *mess**age**_t store //// Fix me here please!! if i need to store rec > eiving information, can i store in the address message_t type variable* > } > > event void Timer0.fired() { > BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)(call > Packet.getPayload(&pkt, sizeof (BlinkToRadioMsg))); > // logics are added > if (call AMSend.send(AM_BROADCAST_ADDR, &pkt, sizeof(BlinkToRadioMsg)) > == SUCCESS) { > } > } > event message_t* Receive.receive(message_t* msg, void* payload, uint8_t > len) { > if (len == sizeof(BlinkToRadioMsg)) { > BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload; > call Leds.set(btrpkt->counter); > * ///// here I am going to store the required information which is > being received, i have created Cache_t header and I am > ///// storing **the information*. > > * Cache_t* cpkt = (Cache_t*)(call Packet.getPayload(&store, sizeof ( > Cache_t))); > cpkt->neighbor_id=btrpkt->node_id;* > } > return msg; > } > > is this right way to store the receiving information in new structure ??
That is reasonable. When a message is received, it lives in a message_t datum that is owned by the low level receive code. You are pointing at its information with btrpkt in the receive code. You then make a pointer to local data (local to the module, but static allocation so it always exists, which is good) and copy some data out of the received packet. You then return the recieved message (msg) back to the low level receive code. I think you've got it. > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > -- Eric B. Decker Senior (over 50 :-) Researcher
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
