diff --git a/apps/tests/TestLpl/Makefile b/apps/tests/TestLpl/Makefile old mode 100644 new mode 100755 index 68581ad079..d1112f3fb5 --- a/apps/tests/TestLpl/Makefile +++ b/apps/tests/TestLpl/Makefile @@ -1,5 +1,7 @@ COMPONENT=TestLplAppC CFLAGS += -DLOW_POWER_LISTENING +#CFLAGS += -DCC2420_HW_ACKNOWLEDGEMENTS +#CFLAGS += -DCC2420_HW_ADDRESS_RECOGNITION TINYOS_ROOT_DIR?=../../.. include $(TINYOS_ROOT_DIR)/Makefile.include diff --git a/apps/tests/TestLpl/README.txt b/apps/tests/TestLpl/README.txt index a3c6686c5b..de8fd48ecd 100644 --- a/apps/tests/TestLpl/README.txt +++ b/apps/tests/TestLpl/README.txt @@ -14,6 +14,10 @@ LED 1 every time it receives a message. If this application is working correctly (see caveat about timing below), you should see both nodes toggling LED 1. +By default broadcast packets are sent. In order to test unicast transmission +with acknowledgements, uncomment the WITH_ACKS define in TestLplC.nc and +assign node IDs 1 and 2. + Its low-power-listening settings are as follows (repeating every 256s): 0-32s: receive: fully on diff --git a/apps/tests/TestLpl/TestLplAppC.nc b/apps/tests/TestLpl/TestLplAppC.nc index 4ab2ea612a..53f7ecfa47 100644 --- a/apps/tests/TestLpl/TestLplAppC.nc +++ b/apps/tests/TestLpl/TestLplAppC.nc @@ -60,6 +60,7 @@ implementation { App.Receive -> ActiveMessageC.Receive[240]; App.AMSend -> ActiveMessageC.AMSend[240]; App.SplitControl -> ActiveMessageC; + App.PacketAcknowledgements -> ActiveMessageC; App.Leds -> LedsC; App.MilliTimer -> TimerMilliC; App.LowPowerListening -> LplRadio; diff --git a/apps/tests/TestLpl/TestLplC.nc b/apps/tests/TestLpl/TestLplC.nc old mode 100644 new mode 100755 index f1db49f7f1..3c72b69980 --- a/apps/tests/TestLpl/TestLplC.nc +++ b/apps/tests/TestLpl/TestLplC.nc @@ -1,6 +1,6 @@ // $Id: TestLplC.nc,v 1.2 2009-10-21 19:11:51 razvanm Exp $ -/* tab:4 +/* * "Copyright (c) 2000-2005 The Regents of the University of California. * All rights reserved. * @@ -40,6 +40,10 @@ * @date Oct 27 2006 */ + +//#define WITH_ACKS + + module TestLplC { uses { interface Leds; @@ -49,6 +53,7 @@ module TestLplC { interface Timer as MilliTimer; interface SplitControl; interface LowPowerListening; + interface PacketAcknowledgements; } } implementation @@ -74,43 +79,51 @@ implementation sendInterval = 100; /* Send to sleepy listener */ break; case 2: - sendInterval = -1; /* Send to listener like us */ - call LowPowerListening.setLocalWakeupInterval(250); + sendInterval = 250; /* Send to listener like us */ + call LowPowerListening.setLocalWakeupInterval(sendInterval); break; case 3: sendInterval = 0; /* Send to awake listener */ break; case 4: - sendInterval = -1; /* Send to listener like us */ - call LowPowerListening.setLocalWakeupInterval(10); + sendInterval = 10; /* Send to listener like us */ + call LowPowerListening.setLocalWakeupInterval(sendInterval); break; case 5: sendSkip = 7; /* Send every 7s */ - call LowPowerListening.setLocalWakeupInterval(2000); + sendInterval = 2000; /* Send to listener like us */ + call LowPowerListening.setLocalWakeupInterval(sendInterval); break; } } - + event void MilliTimer.fired() { + am_addr_t dst; counter++; if (!(counter & 31)) nextLplState(); if (!locked && ((counter & sendSkip) == sendSkip)) + { + if (sendInterval >= 0) + call LowPowerListening.setRemoteWakeupInterval(&packet, sendInterval); + +#ifdef WITH_ACKS + call PacketAcknowledgements.requestAck(&packet); + dst = TOS_NODE_ID == 1 ? 2 : 1; +#endif + + if (call AMSend.send(dst, &packet, 0) == SUCCESS) { - if (sendInterval >= 0) - call LowPowerListening.setRemoteWakeupInterval(&packet, sendInterval); - if (call AMSend.send(AM_BROADCAST_ADDR, &packet, 0) == SUCCESS) - { - call Leds.led0On(); - locked = TRUE; - } + call Leds.led0On(); + locked = TRUE; } + } } event message_t* Receive.receive(message_t* bufPtr, - void* payload, uint8_t len) + void* payload, uint8_t len) { call Leds.led1Toggle(); return bufPtr; @@ -119,15 +132,15 @@ implementation event void AMSend.sendDone(message_t* bufPtr, error_t error) { if (&packet == bufPtr) - { - locked = FALSE; - call Leds.led0Off(); - } + { + locked = FALSE; + call Leds.led0Off(); + } } event void SplitControl.startDone(error_t err) { - call MilliTimer.startPeriodic(1000); + call MilliTimer.startPeriodic(1024); } event void SplitControl.stopDone(error_t err) { } diff --git a/tos/chips/cc2420/CC2420.h b/tos/chips/cc2420/CC2420.h index 54609089bd..58bc5bb2cd 100644 --- a/tos/chips/cc2420/CC2420.h +++ b/tos/chips/cc2420/CC2420.h @@ -193,7 +193,7 @@ enum cc2420_enums { CC2420_TIME_SYMBOL = 2, // 2 symbols / jiffy CC2420_BACKOFF_PERIOD = ( 20 / CC2420_TIME_SYMBOL ), // symbols CC2420_MIN_BACKOFF = ( 20 / CC2420_TIME_SYMBOL ), // platform specific? - CC2420_ACK_WAIT_DELAY = 256, // jiffies + CC2420_ACK_WAIT_DELAY = 50, // jiffies }; enum cc2420_status_enums {