The functionality youre interested in - reliably link layer transmissions - is included in the CC2420 radio stack in the PacketLink interface. You can add the PacketLink layer into the radio stack by adding CFLAGS+=-DPACKET_LINK into your Makefile. In your software, instead of requesting an acknowledgment, setup a reliable packet transmission through the PacketLink interface:
call PacketLink.setRetries(&myMsg, 5); call PacketLink.setRetryDelay(&myMsg, 0); This will automatically retry sending the packet 5 times, with no delays between retransmissions. When you get a sendDone() event back, you can check to see if the packet was delivered either by calling PacketAcknowledgments.wasAcked(&myMsg); OR by calling PacketLink.wasDelivered(&myMsg);. You are receiving multiple packets at the base station because acknowledgments are just as unreliable as sending any packet. If an acknowledgement is dropped and you have to retransmit, then the base station will receive duplicates. The PacketLink layer, combined with UniqueSend and UniqueReceive layers in the CC2420 stack, prevent duplicate packet receptions due to dropped acknowledgments. There is more documentation here: http://tinyos.cvs.sourceforge.net/*checkout*/tinyos/tinyos-2.x/doc/html/tep1 27.html Finally, there is already a delay built into the send for the acknowledgment wait period, and you will not get a sendDone() event back until an ack was received or the ack wait period timed out. -David _____ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Juan Antonio López Riquelme Sent: Monday, April 07, 2008 9:33 AM To: tinyos-help@millennium.berkeley.edu Subject: [Tinyos-help] Problems with ACKs in TinyOS 2.0.2 Hello, I am working with TinyOS 2.0.2 and payload of 29 bytes. Two remotes nodes send messages to node with BaseStation application. I changed BaseStation program to work with 29 bytes of payload and acknowledgements. I compiled with address 0. In BaseStationP: #include "AM.h" #include "Serial.h" #define TOSH_DATA_LENGTH 29 //Added line The Makefile: COMPONENT=BaseStationC #CFLAGS += -DCC2420_NO_ACKNOWLEDGEMENTS CFLAGS += -DCC2420_NO_ADDRESS_RECOGNITION include $(MAKERULES) The remote node requests an ack before to send the message: call ACK.requestAck(&PaqueteDatos); if (call EnviarDatos.send(0, &PaqueteDatos, sizeof(MensajeDatos)) == SUCCESS) And finally the code at sendDone event: event void EnviarDatos.sendDone(message_t* msg, error_t error) { if (&PaqueteDatos == msg) { enviarDatosBusy = FALSE; enviados = enviados + 1; if (!call ACK.wasAcked(msg) && intentos < REINTENTOS) { intentos = intentos + 1; FuncionEnviarDatos(); } else { //New iteration with the sensors intentos = 0; ... } ... } } If the ack failed the program tries to send the message 5 times. At the computer sometimes I get the same message twice. Can the program requiere a delay between sendDone is signaled and check the acknowledgement? Thanks, Juan Antonio.
_______________________________________________ Tinyos-help mailing list Tinyos-help@millennium.berkeley.edu https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help