Hello together,
I`m new to TinyOS and I have a question about how to modify a received
packet.
I send a packet to a mote by serial. The mote receives the packet (led`s
are blinking). But how can I modify the received packet? I want to
modify some fields (set the TOS_NODE_ID of the mote who received the
packet) of the payload and then send it to other modes by a radio
broadcast, but I think I`ve problems with the pointer ...
Here is my approach. Some comments are in the code.
-----------------------------------------------------------------------------------------------------------------------------------------------
implementation {
message_t packet;
message_t* ptrPacket=&packet;
...
// a node received a msg by serial connection
event message_t* ReceiveSerial.receive(message_t* msg, void*
payload, uint8_t len) {
if(len != sizeof(BroadcastSerialMsg)) {
call Leds.led0Toggle();
}
else {
// get pointer to the payload of the received packet?!
BroadcastSerialMsg* rcm = (BroadcastSerialMsg*)payload;
// read value of payload field "broadcast_val"
uint8_t broadcast = rcm -> broadcast_val;
//try to set node id of the node who received the msg
rcm->src_nodeid = TOS_NODE_ID;
broad_id = rcm -> broadcast_id;
// is the address operator to "packet" right? Do I have to
"put" the payload into the packet msg?
// If yes, how can I do this?
if(broadcast==0x01) {
if(call SendRadio.send(AM_BROADCAST_ADDR, &packet,
sizeof(BroadcastSerialMsg)) == SUCCESS){
busy = TRUE;
call Leds.led1Toggle();
}
}
}
return msg;
}
-----------------------------------------------------------------------------------------------------------------------------------------------
Am I right with my assumption that by changing the values in/by the
payload pointer and then sending the packet msg by radio...this are two
different kinds? But how can I store the received msg in a local
variable, modify its data fields (TOS_NODE_ID) and then send it by radio?
Thanks for any help!
Best regards
Benjamin
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help