Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CC2420/LPL: shorten the inter-packet interval #341

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/tests/TestLpl/Makefile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions apps/tests/TestLpl/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions apps/tests/TestLpl/TestLplAppC.nc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
53 changes: 33 additions & 20 deletions apps/tests/TestLpl/TestLplC.nc
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -40,6 +40,10 @@
* @date Oct 27 2006
*/


//#define WITH_ACKS


module TestLplC {
uses {
interface Leds;
Expand All @@ -49,6 +53,7 @@ module TestLplC {
interface Timer<TMilli> as MilliTimer;
interface SplitControl;
interface LowPowerListening;
interface PacketAcknowledgements;
}
}
implementation
Expand All @@ -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;
Expand All @@ -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) { }
Expand Down
2 changes: 1 addition & 1 deletion tos/chips/cc2420/CC2420.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down