I'm totally lost using TinyOS and I think I need some help over here.
I have a node that send a message to all nodes that listen to him, so, from time to time this node send a message to all of his "children"
event void Timer.fired() {
call Read.read();
}
event void Read.readDone(error_t result, uint16_t data) {
if (!busy) {
Msg* localpkt = (Msg*) (call Packet.getPayload(&packet, sizeof(Msg)));
if (localpkt == NULL) { return; }
localpkt->data = data;
if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(Msg)) == SUCCESS) {
busy = TRUE;
}
}
Then, I have the receive method (all methods are in the same .nc)
event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len){
if (len == sizeof(Msg)) {
Msg* localpkt = (Msg*)payload;
data = localpkt->data;
}
return msg;
}
When I send a message, the father node will receive message from his children, but how do I know witch children answered in time?
If I have for example, one father sending message for 3 nodes, how do I know how many of this nodes answered me and how do I know his ID?
I forgot to tell, father node and children node execute the same code, but the father act like a "coordinator", so we have to send message to his children time to time. I`m ussing TOSSIM to simmulate this code.
Thanks in advance!
If I understand your question correctly, you are looking for a way to get packet acknowledgements on a per destination basis using broadcast. My experience with TinyOS is somewhat limited, but as far as I now there is no direct way to do that.
What you could try is use unicast messages instead. So for example, you could add extra logic to your application that will make children "register" with the coordinator first thing after booting up by sending some small packet through the channel that only coordinator listens on. Coordinator then keeps a list of registered children and sends messages to them one by one. This way you can use tos.interfaces.PacketAcknowledgements to get acks for each destination and know for sure which children have received their messages.