[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/rf230 DefaultMacC.nc, 1.5, 1.6 DummyLayerC.nc, 1.1, 1.2 LowPowerListeningLayerC.nc, 1.1, 1.2 LowPowerListeningLayerP.nc, 1.1, 1.2

Miklos Maroti mmaroti at users.sourceforge.net
Tue Apr 22 03:55:23 PDT 2008


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv23216

Modified Files:
	DefaultMacC.nc DummyLayerC.nc LowPowerListeningLayerC.nc 
	LowPowerListeningLayerP.nc 
Log Message:
low power listening: better state machine

Index: DefaultMacC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/DefaultMacC.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DefaultMacC.nc	21 Apr 2008 20:58:08 -0000	1.5
--- DefaultMacC.nc	22 Apr 2008 10:55:20 -0000	1.6
***************
*** 95,98 ****
--- 95,101 ----
  	LowPowerListeningLayerC.SubSend -> MessageBufferLayerC;
  	LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
+ 	LowPowerListeningLayerC.PacketSleepInterval -> DefaultPacketC;
+ 	LowPowerListeningLayerC.IEEE154Packet -> IEEE154PacketC;
+ 	LowPowerListeningLayerC.PacketAcknowledgements -> DefaultPacketC;
  
  	MessageBufferLayerC.Packet -> DefaultPacketC;
***************
*** 117,122 ****
  
  	CsmaLayerC.Config -> DefaultMacP;
! 	CsmaLayerC.SubSend -> RF230LayerC;
! 	CsmaLayerC.SubCCA -> RF230LayerC;
  
  	RF230LayerC.RF230Config -> DefaultMacP;
--- 120,125 ----
  
  	CsmaLayerC.Config -> DefaultMacP;
! 	CsmaLayerC -> RF230LayerC.RadioSend;
! 	CsmaLayerC -> RF230LayerC.RadioCCA;
  
  	RF230LayerC.RF230Config -> DefaultMacP;

Index: DummyLayerC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/DummyLayerC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DummyLayerC.nc	5 Nov 2007 20:36:46 -0000	1.1
--- DummyLayerC.nc	22 Apr 2008 10:55:20 -0000	1.2
***************
*** 26,29 ****
--- 26,34 ----
  	provides
  	{
+ 		interface SplitControl;
+ 		interface Send;
+ 		interface Receive;
+ 		interface LowPowerListening;
+ 
  		interface RadioState;
  		interface RadioSend;
***************
*** 32,35 ****
--- 37,43 ----
  
  		interface DummyConfig as UnconnectedConfig;
+ 		interface PacketField<uint16_t> as UnconnectedPacketSleepInterval;
+ 		interface IEEE154Packet as UnconnectedIEEE154Packet;
+ 		interface PacketAcknowledgements as UnconnectedPacketAcknowledgments;
  	}
  
***************
*** 37,45 ****
  	{
  		interface RadioState as SubState;
! 		interface RadioSend as SubSend;
! 		interface RadioReceive as SubReceive;
! 		interface RadioCCA as SubCCA;
  
  		interface DummyConfig as Config;
  	}
  }
--- 45,61 ----
  	{
  		interface RadioState as SubState;
! 		interface RadioSend as SubRadioSend;
! 		interface RadioReceive as SubRadioReceive;
! 		interface RadioCCA as SubRadioCCA;
! 		interface SplitControl as SubControl;
! 		interface Send as SubSend;
! 		interface Receive as SubReceive;
  
  		interface DummyConfig as Config;
+ 		interface PacketField<uint16_t> as PacketSleepInterval;
+ 		interface IEEE154Packet;
+ 		interface PacketAcknowledgements;
+ 
+ 		interface LowPowerListening as UnconnectedLowPowerListening;
  	}
  }
***************
*** 48,54 ****
  {
  	RadioState = SubState;
! 	RadioSend = SubSend;
! 	RadioReceive = SubReceive;
! 	RadioCCA = SubCCA;
  	Config = UnconnectedConfig;
  }
--- 64,79 ----
  {
  	RadioState = SubState;
! 	RadioSend = SubRadioSend;
! 	RadioReceive = SubRadioReceive;
! 	RadioCCA = SubRadioCCA;
! 
! 	SplitControl = SubControl;
! 	Send = SubSend;
! 	Receive = SubReceive;
! 
  	Config = UnconnectedConfig;
+ 	PacketSleepInterval = UnconnectedPacketSleepInterval;
+ 	IEEE154Packet = UnconnectedIEEE154Packet;
+ 	PacketAcknowledgements = UnconnectedPacketAcknowledgments;
+ 	LowPowerListening = UnconnectedLowPowerListening;
  }

Index: LowPowerListeningLayerC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/LowPowerListeningLayerC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** LowPowerListeningLayerC.nc	21 Apr 2008 20:58:08 -0000	1.1
--- LowPowerListeningLayerC.nc	22 Apr 2008 10:55:20 -0000	1.2
***************
*** 39,42 ****
--- 39,44 ----
  
  		interface PacketField<uint16_t> as PacketSleepInterval;
+ 		interface IEEE154Packet;
+ 		interface PacketAcknowledgements;
  	}
  }
***************
*** 46,57 ****
  	components LowPowerListeningLayerP, new TimerMilliC();
  
- 	LowPowerListening = LowPowerListeningLayerP;
- 	PacketSleepInterval = LowPowerListeningLayerP;
  	SplitControl = LowPowerListeningLayerP;
- 	SubControl = LowPowerListeningLayerP;
  	Send = LowPowerListeningLayerP;
- 	SubSend = LowPowerListeningLayerP;
  	Receive = LowPowerListeningLayerP;
  	SubReceive = LowPowerListeningLayerP;
  	
  	LowPowerListeningLayerP.Timer -> TimerMilliC;
--- 48,62 ----
  	components LowPowerListeningLayerP, new TimerMilliC();
  
  	SplitControl = LowPowerListeningLayerP;
  	Send = LowPowerListeningLayerP;
  	Receive = LowPowerListeningLayerP;
+ 	LowPowerListening = LowPowerListeningLayerP;
+ 
+ 	SubControl = LowPowerListeningLayerP;
+ 	SubSend = LowPowerListeningLayerP;
  	SubReceive = LowPowerListeningLayerP;
+ 	PacketSleepInterval = LowPowerListeningLayerP;
+ 	IEEE154Packet = LowPowerListeningLayerP;
+ 	PacketAcknowledgements = LowPowerListeningLayerP;
  	
  	LowPowerListeningLayerP.Timer -> TimerMilliC;

Index: LowPowerListeningLayerP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/LowPowerListeningLayerP.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** LowPowerListeningLayerP.nc	21 Apr 2008 20:58:08 -0000	1.1
--- LowPowerListeningLayerP.nc	22 Apr 2008 10:55:20 -0000	1.2
***************
*** 42,45 ****
--- 42,47 ----
  
  		interface PacketField<uint16_t> as PacketSleepInterval;
+ 		interface IEEE154Packet;
+ 		interface PacketAcknowledgements;
  		interface Timer<TMilli>;
  	}
***************
*** 64,68 ****
  	};
  
! 	uint16_t rxSleepInterval;
  
  /*----------------- state machine -----------------*/
--- 66,74 ----
  	};
  
! 	uint16_t sleepInterval;
! 
! 	message_t* txMsg;
! 	uint8_t txLen;
! 	error_t txError;
  
  /*----------------- state machine -----------------*/
***************
*** 70,157 ****
  	enum
  	{
! 		STATE_OFF = 0,		// timer off, radio off
! 		STATE_SLEEP = 1,	// timer on, radio off
! 		STATE_LISTEN = 2,	// timer on/off, radio on
! 		STATE_SEND = 3,		// timer on/off, radio on
  
! 		STATE_OFF_TO_LISTEN = 10,
! 		STATE_SLEEP_TO_LISTEN = 11,
! 		STATE_SLEEP_TO_SEND = 12,
! 		STATE_SLEEP_TO_OFF = 13,
! 		STATE_LISTEN_TO_SLEEP_1 = 14,	// we go back to listen if a message arrives in this state
! 		STATE_LISTEN_TO_SLEEP_2 = 15,
! 		STATE_LISTEN_TO_OFF = 16,
! 		STATE_SEND_DONE = 17,
  	};
  
  	uint8_t state;
  
- 	message_t* txMsg;
- 	uint8_t txLen;
- 
  	task void transition()
  	{
  		error_t error;
  
! 		if( state == STATE_OFF_TO_LISTEN || state == STATE_SLEEP_TO_LISTEN || state == STATE_SLEEP_TO_SEND )
  		{
  			error = call SubControl.start();
  			ASSERT( error == SUCCESS || error == EBUSY );
  
! 			if( error != SUCCESS )
  				post transition();
  		}
! 		else if( state == STATE_LISTEN_TO_OFF || state == STATE_LISTEN_TO_SLEEP_1 )
  		{
  			error = call SubControl.stop();
  			ASSERT( error == SUCCESS || error == EBUSY );
  
! 			if( error != SUCCESS )
  				post transition();
- 			else if( state == STATE_LISTEN_TO_SLEEP_1 )
- 				state = STATE_LISTEN_TO_SLEEP_2;
  		}
! 		else if( state == STATE_SLEEP_TO_OFF )
  		{
! 			state = STATE_OFF;
  			signal SplitControl.stopDone(SUCCESS);
  		}
! 		else if( state == STATE_SEND )
  		{
! 			error = call SubSend.send(txMsg, txLen);
! 			if( error == SUCCESS )
! 				state = STATE_SEND_DONE;
  			else
  			{
! 				state = STATE_LISTEN;
! 				if( rxSleepInterval > 0 )
! 					call Timer.startOneShot(AFTER_TRANSMIT);
! 
! 				signal Send.sendDone(txMsg, error);
  			}
  		}
! 		else if( state == STATE_LISTEN )
  		{
! 			if( rxSleepInterval > 0 )
! 				call Timer.startOneShot(LISTEN_WAKEUP);
  		}
! 		else if( state == STATE_SLEEP )
  		{
! 			if( rxSleepInterval > 0 )
! 				call Timer.startOneShot(rxSleepInterval);
  			else
  			{
! 				state = STATE_SLEEP_TO_LISTEN;
  				post transition();
  			}
  		}
  	}
  
  	command error_t SplitControl.start()
  	{
! 		if( state != STATE_OFF )
  			return EALREADY;
  
! 		state = STATE_OFF_TO_LISTEN;
  		post transition();
  
--- 76,202 ----
  	enum
  	{
! 		OFF = 0,					
! 		OFF_SUBSTOP = 1,			// must have consecutive indices
! 		OFF_SUBSTOP_DONE = 2,		// must have consecutive indices
! 		OFF_STOP_END = 3,			// must have consecutive indices
! 		OFF_START_END = 4,
  
! 		LISTEN_SUBSTART = 5,		// must have consecutive indices
! 		LISTEN_SUBSTART_DONE = 6,	// must have consecutive indices
! 		LISTEN_TIMER = 7,			// must have consecutive indices
! 		LISTEN = 8,					// must have consecutive indices
! 
! 		SLEEP_SUBSTOP = 9,			// must have consecutive indices
! 		SLEEP_SUBSTOP_DONE = 10,	// must have consecutive indices
! 		SLEEP_TIMER = 11,			// must have consecutive indices
! 		SLEEP = 12,					// must have consecutive indices
! 
! 		SEND_SUBSTART = 13,			// must have consecutive indices
! 		SEND_SUBSTART_DONE = 14,	// must have consecutive indices
! 		SEND_TIMER = 15,			// must have consecutive indices
! 		SEND_SUBSEND= 16,
! 		SEND_SUBSEND_DONE = 17,
! 		SEND_SUBSEND_DONE_LAST = 18,
! 		SEND_DONE = 19,
  	};
  
  	uint8_t state;
  
  	task void transition()
  	{
  		error_t error;
+ 		uint16_t transmitInterval;
  
! 		if( state == LISTEN_SUBSTART || state == SEND_SUBSTART )
  		{
  			error = call SubControl.start();
  			ASSERT( error == SUCCESS || error == EBUSY );
  
! 			if( error == SUCCESS )
! 				++state;
! 			else
  				post transition();
  		}
! 		else if( state == SLEEP_SUBSTOP || state == OFF_SUBSTOP )
  		{
  			error = call SubControl.stop();
  			ASSERT( error == SUCCESS || error == EBUSY );
  
! 			if( error == SUCCESS )
! 				++state;
! 			else
  				post transition();
  		}
! 		else if( state == OFF_START_END )
  		{
! 			state = LISTEN_SUBSTART;
! 			post transition();
! 
! 			signal SplitControl.startDone(SUCCESS);
! 		}
! 		else if( state == OFF_STOP_END )
! 		{
! 			state = OFF;
  			signal SplitControl.stopDone(SUCCESS);
  		}
! 		else if( state == LISTEN_TIMER )
  		{
! 			state = LISTEN;
! 			if( sleepInterval > 0 )
! 				call Timer.startOneShot(LISTEN_WAKEUP);
! 		}
! 		else if( state == SLEEP_TIMER )
! 		{
! 			if( sleepInterval > 0 )
! 			{
! 				state = SLEEP;
! 				call Timer.startOneShot(sleepInterval);
! 			}
  			else
  			{
! 				state = LISTEN_SUBSTART;
! 				post transition();
  			}
  		}
! 		else if( state == SEND_TIMER )
  		{
! 			transmitInterval = call LowPowerListening.getRxSleepInterval(txMsg);
! 
! 			if( transmitInterval > 0 )
! 				call Timer.startOneShot(transmitInterval);
! 
! 			state = SEND_SUBSEND;
! 			post transition();
  		}
! 		else if( state == SEND_SUBSEND)
  		{
! 			txError = call SubSend.send(txMsg, txLen);
! 
! 			if( txError == SUCCESS )
! 				state = SEND_SUBSEND_DONE;
  			else
  			{
! 				state = SEND_DONE;
  				post transition();
  			}
  		}
+ 		else if( state == SEND_DONE )
+ 		{
+ 			state = LISTEN;
+ 			if( sleepInterval > 0 )
+ 				call Timer.startOneShot(AFTER_TRANSMIT);
+ 
+ 			signal Send.sendDone(txMsg, txError);
+ 		}
  	}
  
  	command error_t SplitControl.start()
  	{
! 		if( state == OFF_START_END )
! 			return EBUSY;
! 		else if( state != OFF )
  			return EALREADY;
  
! 		state = OFF_START_END;
  		post transition();
  
***************
*** 162,176 ****
  	{
  		ASSERT( error == SUCCESS || error == EBUSY );
! 		ASSERT( state == STATE_OFF_TO_LISTEN || state == STATE_SLEEP_TO_LISTEN || state == STATE_SLEEP_TO_SEND );
  
  		if( error == SUCCESS )
! 		{
! 			if( state == STATE_OFF_TO_LISTEN )
! 				signal SplitControl.startDone(SUCCESS);
! 			else if( state == STATE_SLEEP_TO_SEND )
! 				state = STATE_SEND;
! 			else
! 				state = STATE_LISTEN;
! 		}
  
  		post transition();
--- 207,216 ----
  	{
  		ASSERT( error == SUCCESS || error == EBUSY );
! 		ASSERT( state == LISTEN_SUBSTART_DONE || state == SEND_SUBSTART_DONE );
  
  		if( error == SUCCESS )
! 			++state;
! 		else
! 			--state;
  
  		post transition();
***************
*** 179,194 ****
  	command error_t SplitControl.stop()
  	{
! 		if( state == STATE_OFF )
! 			return EALREADY;
! 		else if( state != STATE_LISTEN || state != STATE_SLEEP )
! 			return EBUSY;
  
! 		call Timer.stop();
! 		if( state == STATE_SLEEP )
! 			state = STATE_SLEEP_TO_OFF;
  		else
! 			state = STATE_LISTEN_TO_OFF;
! 
! 		post transition();
  
  		return SUCCESS;
--- 219,238 ----
  	command error_t SplitControl.stop()
  	{
! 		if( state == SLEEP || state == LISTEN )
! 		{
! 			call Timer.stop();
! 			post transition();
! 		}
  
! 		if( state == LISTEN_TIMER || state == LISTEN || state == SLEEP_SUBSTOP )
! 			state = OFF_SUBSTOP;
! 		else if( state == SLEEP_SUBSTOP_DONE )
! 			state = OFF_SUBSTOP_DONE;
! 		else if( state == LISTEN_SUBSTART || state == SLEEP_TIMER || state == SLEEP )
! 			state = OFF_STOP_END;
! 		else if( state == OFF )
! 			return EALREADY;
  		else
! 			return EBUSY;
  
  		return SUCCESS;
***************
*** 198,210 ****
  	{
  		ASSERT( error == SUCCESS || error == EBUSY );
! 		ASSERT( state == STATE_LISTEN_TO_SLEEP_2 || state == STATE_LISTEN_TO_OFF );
  
  		if( error == SUCCESS )
! 		{
! 			if( state == STATE_LISTEN_TO_OFF )
! 				state = STATE_SLEEP_TO_OFF;
! 			else
! 				state = STATE_SLEEP;
! 		}
  
  		post transition();
--- 242,251 ----
  	{
  		ASSERT( error == SUCCESS || error == EBUSY );
! 		ASSERT( state == SLEEP_SUBSTOP_DONE || state == OFF_SUBSTOP_DONE );
  
  		if( error == SUCCESS )
! 			++state;
! 		else
! 			--state;
  
  		post transition();
***************
*** 213,244 ****
  	event void Timer.fired()
  	{
! 		ASSERT( state == STATE_LISTEN || state == STATE_SLEEP );
  
! 		if( state == STATE_LISTEN )
! 			state = STATE_LISTEN_TO_SLEEP_1;
! 		else
! 			state = STATE_SLEEP_TO_LISTEN;
  
  		post transition();
  	}
  
! 	void rxSleepIntervalChanged()
  	{
! 		if( rxSleepInterval == 0 )
  		{
  			call Timer.stop();
! 			if( state == STATE_SLEEP )
! 				state = STATE_SLEEP_TO_LISTEN;
  		}
- 
- 		post transition();
  	}
  
  	event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len)
  	{
! 		if( state == STATE_LISTEN_TO_SLEEP_1 )
! 			state = STATE_LISTEN;
  
! 		if( state == STATE_LISTEN && rxSleepInterval > 0 )
  			call Timer.startOneShot(AFTER_RECEIVE);
  
--- 254,287 ----
  	event void Timer.fired()
  	{
! 		ASSERT( state == LISTEN || state == SLEEP || state == SEND_SUBSEND|| state == SEND_SUBSEND_DONE );
  
! 		if( state == LISTEN )
! 			state = SLEEP_SUBSTOP;
! 		else if( state == SLEEP )
! 			state = LISTEN_SUBSTART;
! 		else if( state == SEND_SUBSEND_DONE )
! 			state = SEND_SUBSEND_DONE_LAST;
! 		else if( state == SEND_SUBSEND)
! 			state = SEND_DONE;
  
  		post transition();
  	}
  
! 	void sleepIntervalChanged()
  	{
! 		if( (state == LISTEN && sleepInterval == 0) || state == SLEEP )
  		{
  			call Timer.stop();
! 			--state;
! 			post transition();
  		}
  	}
  
  	event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len)
  	{
! 		if( state == SLEEP_SUBSTOP )
! 			state = LISTEN;
  
! 		if( state == LISTEN && sleepInterval > 0 )
  			call Timer.startOneShot(AFTER_RECEIVE);
  
***************
*** 248,266 ****
  	command error_t Send.send(message_t* msg, uint8_t len)
  	{
! 		if( state == STATE_LISTEN || state == STATE_SLEEP )
! 			call Timer.stop();
! 
! 		if( state == STATE_LISTEN || state == STATE_LISTEN_TO_SLEEP_1 )
! 		{
! 			state = STATE_SEND;
! 			post transition();
! 		}
! 		else if( state == STATE_SLEEP )
  		{
! 			state = STATE_SLEEP_TO_SEND;
  			post transition();
  		}
! 		else if( state == STATE_SLEEP_TO_LISTEN )
! 			state = STATE_SLEEP_TO_SEND;
  		else
  			return EBUSY;
--- 291,306 ----
  	command error_t Send.send(message_t* msg, uint8_t len)
  	{
! 		if( state == LISTEN || state == SLEEP )
  		{
! 			call Timer.stop();
  			post transition();
  		}
! 
! 		if( state == LISTEN_SUBSTART || state == SLEEP_TIMER || state == LISTEN )
! 			state = SEND_SUBSTART;
! 		else if( state == LISTEN_SUBSTART_DONE )
! 			state = SEND_SUBSTART_DONE;
! 		else if( state == LISTEN_TIMER || state == SLEEP_SUBSTOP|| state == LISTEN )
! 			state = SEND_TIMER;
  		else
  			return EBUSY;
***************
*** 268,287 ****
  		txMsg = msg;
  		txLen = len;
  	}
  
  	command error_t Send.cancel(message_t* msg)
  	{
! 		return call SubSend.cancel(msg);
  	}
  
  	event void SubSend.sendDone(message_t* msg, error_t error)
  	{
! 		ASSERT( state == STATE_SEND_DONE );
  
! 		state = STATE_LISTEN;
! 		if( rxSleepInterval > 0 )
! 			call Timer.startOneShot(AFTER_TRANSMIT);
  
! 		signal Send.sendDone(msg, error);
  	}
  
--- 308,349 ----
  		txMsg = msg;
  		txLen = len;
+ 		txError = FAIL;
  	}
  
  	command error_t Send.cancel(message_t* msg)
  	{
! 		if( state == SEND_SUBSEND )
! 		{
! 			call Timer.stop();
! 			state = LISTEN_TIMER;
! 			post transition();
! 
! 			// TODO: ask if sendDone should be called after a succesfull cancel
! 			return SUCCESS;
! 		}
! 		else
! 			return FAIL;
  	}
  
  	event void SubSend.sendDone(message_t* msg, error_t error)
  	{
! 		ASSERT( state == SEND_SUBSEND_DONE || state == SEND_SUBSEND_DONE_LAST );
! 		ASSERT( msg == txMsg );
  
! 		txError = error;
  
! 		// TODO: extend the PacketAcknowledgements interface with getAckRequired
! 		if( error != SUCCESS
! 			|| call LowPowerListening.getRxSleepInterval(msg) == 0
! 			|| state == SEND_SUBSEND_DONE_LAST
! 			|| (call IEEE154Packet.getAckRequired(msg) && call PacketAcknowledgements.wasAcked(msg)) )
! 		{
! 			call Timer.stop();
! 			state = SEND_DONE;
! 		}
! 		else
! 			state = SEND_SUBSEND;
! 
! 		post transition();
  	}
  
***************
*** 308,335 ****
  	}
  
! 	command uint16_t LowPowerListening.sleepIntervalToDutyCycle(uint16_t sleepInterval)
  	{
! 		if( sleepInterval < MIN_SLEEP )
  			return 10000;
! 		else if( sleepInterval >= MAX_SLEEP )
  			return MIN_DUTY;
  
! 		return (10000 * LISTEN_WAKEUP) / (LISTEN_WAKEUP + sleepInterval);
  	}
  
! 	command void LowPowerListening.setLocalSleepInterval(uint16_t sleepInterval)
      {
! 		if( sleepInterval < MIN_SLEEP )
! 			sleepInterval = 0;
! 		else if( sleepInterval > MAX_SLEEP )
! 			sleepInterval = MAX_SLEEP;
  
! 		rxSleepInterval = sleepInterval;
! 		rxSleepIntervalChanged();
  	}
  
  	command uint16_t LowPowerListening.getLocalSleepInterval()
      {	
! 		return rxSleepInterval;
  	}
  
--- 370,397 ----
  	}
  
! 	command uint16_t LowPowerListening.sleepIntervalToDutyCycle(uint16_t interval)
  	{
! 		if( interval < MIN_SLEEP )
  			return 10000;
! 		else if( interval >= MAX_SLEEP )
  			return MIN_DUTY;
  
! 		return (10000 * LISTEN_WAKEUP) / (LISTEN_WAKEUP + interval);
  	}
  
! 	command void LowPowerListening.setLocalSleepInterval(uint16_t interval)
      {
! 		if( interval < MIN_SLEEP )
! 			interval = 0;
! 		else if( interval > MAX_SLEEP )
! 			interval = MAX_SLEEP;
  
! 		sleepInterval = interval;
! 		sleepIntervalChanged();
  	}
  
  	command uint16_t LowPowerListening.getLocalSleepInterval()
      {	
! 		return sleepInterval;
  	}
  
***************
*** 342,356 ****
  	command uint16_t LowPowerListening.getLocalDutyCycle()
  	{
! 		return call LowPowerListening.sleepIntervalToDutyCycle(rxSleepInterval);
  	}
  
! 	command void LowPowerListening.setRxSleepInterval(message_t *msg, uint16_t sleepInterval)
  	{
! 		if( sleepInterval < MIN_SLEEP )
! 			sleepInterval = 0;
! 		else if( sleepInterval > MAX_SLEEP )
! 			sleepInterval = MAX_SLEEP;
  
! 		call PacketSleepInterval.set(msg, sleepInterval);
  	}
  
--- 404,418 ----
  	command uint16_t LowPowerListening.getLocalDutyCycle()
  	{
! 		return call LowPowerListening.sleepIntervalToDutyCycle(sleepInterval);
  	}
  
! 	command void LowPowerListening.setRxSleepInterval(message_t *msg, uint16_t interval)
  	{
! 		if( interval < MIN_SLEEP )
! 			interval = 0;
! 		else if( interval > MAX_SLEEP )
! 			interval = MAX_SLEEP;
  
! 		call PacketSleepInterval.set(msg, interval);
  	}
  



More information about the Tinyos-2-commits mailing list