From 80947dbfb5b56d7b65bc51a4518b320643821ab3 Mon Sep 17 00:00:00 2001 From: mmaroti Date: Mon, 29 Mar 2010 22:26:10 +0000 Subject: [PATCH] tune the LPL constants (use 5 ms listen check) Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ --- .../rf2xx/layers/LowPowerListeningConfig.nc | 7 ++++++ .../rf2xx/layers/LowPowerListeningLayerC.nc | 3 +++ .../rf2xx/layers/LowPowerListeningLayerP.nc | 21 ++++++++++++---- tos/chips/rf2xx/rf212/RF212RadioP.nc | 24 +++++++++++++++++++ tos/chips/rf2xx/rf230/RF230RadioP.nc | 24 +++++++++++++++++++ 5 files changed, 74 insertions(+), 5 deletions(-) diff --git a/tos/chips/rf2xx/layers/LowPowerListeningConfig.nc b/tos/chips/rf2xx/layers/LowPowerListeningConfig.nc index 57c99d82..06678b6a 100644 --- a/tos/chips/rf2xx/layers/LowPowerListeningConfig.nc +++ b/tos/chips/rf2xx/layers/LowPowerListeningConfig.nc @@ -35,4 +35,11 @@ interface LowPowerListeningConfig * this message via the PacketAcknowledgements interface. */ command bool ackRequested(message_t* msg); + + /** + * Returns the number of milliseconds the mote should turn on + * its radio to check for incoming messages. This check is + * performed at every localWakeInterval. + */ + command uint16_t getListenLength(); } diff --git a/tos/chips/rf2xx/layers/LowPowerListeningLayerC.nc b/tos/chips/rf2xx/layers/LowPowerListeningLayerC.nc index 75d07154..d3b8ebe7 100644 --- a/tos/chips/rf2xx/layers/LowPowerListeningLayerC.nc +++ b/tos/chips/rf2xx/layers/LowPowerListeningLayerC.nc @@ -64,4 +64,7 @@ implementation LowPowerListeningLayerP.Timer -> TimerMilliC; LowPowerListeningLayerP.SystemLowPowerListening -> SystemLowPowerListeningC; + + components NoLedsC as LedsC; + LowPowerListeningLayerP.Leds -> LedsC; } diff --git a/tos/chips/rf2xx/layers/LowPowerListeningLayerP.nc b/tos/chips/rf2xx/layers/LowPowerListeningLayerP.nc index 7efab6dc..b965af8a 100644 --- a/tos/chips/rf2xx/layers/LowPowerListeningLayerP.nc +++ b/tos/chips/rf2xx/layers/LowPowerListeningLayerP.nc @@ -48,6 +48,8 @@ module LowPowerListeningLayerP interface LowPowerListeningConfig as Config; interface Timer; interface SystemLowPowerListening; + + interface Leds; } } @@ -55,9 +57,6 @@ implementation { enum { - // minimum wakeup time to catch a transmission in milliseconds - LISTEN_WAKEUP = 6U, // use xxxL if LISTEN_WAKEUP * 10000 > 65535 - MIN_SLEEP = 2, // the minimum sleep interval in milliseconds }; @@ -108,7 +107,10 @@ implementation ASSERT( error == SUCCESS || error == EBUSY ); if( error == SUCCESS ) + { + call Leds.led2On(); ++state; + } else post transition(); } @@ -118,7 +120,10 @@ implementation ASSERT( error == SUCCESS || error == EBUSY ); if( error == SUCCESS ) + { ++state; + call Leds.led2Off(); + } else post transition(); } @@ -138,7 +143,7 @@ implementation { state = LISTEN; if( sleepInterval > 0 ) - call Timer.startOneShot(LISTEN_WAKEUP); + call Timer.startOneShot(call Config.getListenLength()); } else if( state == SLEEP_TIMER ) { @@ -158,7 +163,8 @@ implementation transmitInterval = call LowPowerListening.getRemoteWakeupInterval(txMsg); if( transmitInterval > 0 ) - call Timer.startOneShot(transmitInterval); + call Timer.startOneShot(transmitInterval + + 2 * call Config.getListenLength()); state = SEND_SUBSEND; post transition(); @@ -264,6 +270,8 @@ implementation event message_t* SubReceive.receive(message_t* msg) { + call Leds.led0Toggle(); + if( state == SLEEP_SUBSTOP ) state = LISTEN; @@ -341,6 +349,9 @@ implementation state = SEND_SUBSEND; post transition(); + + if( error == SUCCESS ) + call Leds.led1Toggle(); } /*----------------- LowPowerListening -----------------*/ diff --git a/tos/chips/rf2xx/rf212/RF212RadioP.nc b/tos/chips/rf2xx/rf212/RF212RadioP.nc index 16f93405..81fc60b2 100644 --- a/tos/chips/rf2xx/rf212/RF212RadioP.nc +++ b/tos/chips/rf2xx/rf212/RF212RadioP.nc @@ -246,6 +246,8 @@ implementation * congestion backoff = 0x7 * CC2420_BACKOFF_PERIOD = 70 jiffies = 2240 microsec */ +#ifndef LOW_POWER_LISTENING + async command uint16_t RandomCollisionConfig.getMinimumBackoff() { return (uint16_t)(320 * RADIO_ALARM_MICROSEC); @@ -261,6 +263,8 @@ implementation return (uint16_t)(2240 * RADIO_ALARM_MICROSEC); } +#endif + async command uint16_t RandomCollisionConfig.getTransmitBarrier(message_t* msg) { uint16_t time; @@ -330,6 +334,26 @@ implementation return call Ieee154PacketLayer.getAckRequired(msg); } + command uint16_t LowPowerListeningConfig.getListenLength() + { + return 5; + } + + async command uint16_t RandomCollisionConfig.getMinimumBackoff() + { + return (uint16_t)(320 * RADIO_ALARM_MICROSEC); + } + + async command uint16_t RandomCollisionConfig.getInitialBackoff(message_t* msg) + { + return (uint16_t)(1600 * RADIO_ALARM_MICROSEC); + } + + async command uint16_t RandomCollisionConfig.getCongestionBackoff(message_t* msg) + { + return (uint16_t)(3200 * RADIO_ALARM_MICROSEC); + } + #endif } diff --git a/tos/chips/rf2xx/rf230/RF230RadioP.nc b/tos/chips/rf2xx/rf230/RF230RadioP.nc index f4b0eab7..2a259f08 100644 --- a/tos/chips/rf2xx/rf230/RF230RadioP.nc +++ b/tos/chips/rf2xx/rf230/RF230RadioP.nc @@ -246,6 +246,8 @@ implementation * congestion backoff = 0x7 * CC2420_BACKOFF_PERIOD = 70 jiffies = 2240 microsec */ +#ifndef LOW_POWER_LISTENING + async command uint16_t RandomCollisionConfig.getMinimumBackoff() { return (uint16_t)(320 * RADIO_ALARM_MICROSEC); @@ -261,6 +263,8 @@ implementation return (uint16_t)(2240 * RADIO_ALARM_MICROSEC); } +#endif + async command uint16_t RandomCollisionConfig.getTransmitBarrier(message_t* msg) { uint16_t time; @@ -330,6 +334,26 @@ implementation return call Ieee154PacketLayer.getAckRequired(msg); } + command uint16_t LowPowerListeningConfig.getListenLength() + { + return 5; + } + + async command uint16_t RandomCollisionConfig.getMinimumBackoff() + { + return (uint16_t)(320 * RADIO_ALARM_MICROSEC); + } + + async command uint16_t RandomCollisionConfig.getInitialBackoff(message_t* msg) + { + return (uint16_t)(1600 * RADIO_ALARM_MICROSEC); + } + + async command uint16_t RandomCollisionConfig.getCongestionBackoff(message_t* msg) + { + return (uint16_t)(3200 * RADIO_ALARM_MICROSEC); + } + #endif } -- 2.39.2