[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/rf2xx/rf230 RF230ActiveMessage.h, NONE, 1.1 RF230DriverLayer.h, NONE, 1.1 RF230ActiveMessageC.nc, 1.3, 1.4 RF230ActiveMessageP.nc, 1.4, 1.5 RF230DriverLayerC.nc, 1.1, 1.2 RF230DriverLayerP.nc, 1.4, 1.5 RF230.h, 1.2, NONE RF230Packet.h, 1.3, NONE RF230PacketC.nc, 1.3, NONE RF230PacketP.nc, 1.3, NONE

Miklos Maroti mmaroti at users.sourceforge.net
Thu Apr 2 15:10:09 PDT 2009


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8351/rf230

Modified Files:
	RF230ActiveMessageC.nc RF230ActiveMessageP.nc 
	RF230DriverLayerC.nc RF230DriverLayerP.nc 
Added Files:
	RF230ActiveMessage.h RF230DriverLayer.h 
Removed Files:
	RF230.h RF230Packet.h RF230PacketC.nc RF230PacketP.nc 
Log Message:
change metadata handling, 
remove the RF2xxPacket component, move functionality to RF2xxActiveMessage,
prepare blip support (RF2xxMessageC)


--- NEW FILE: RF230ActiveMessage.h ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

#ifndef __RF230ACTIVEMESSAGE_H__
#define __RF230ACTIVEMESSAGE_H__

#include <IEEE154PacketLayer.h>
#include <MetadataFlagsLayer.h>
#include <RF230DriverLayer.h>
#include <TimeStampingLayer.h>
#include <LowPowerListeningLayer.h>
#include <PacketLinkLayer.h>

typedef ieee154_header_t rf230packet_header_t;

typedef nx_struct rf230packet_footer_t
{
	// the time stamp is not recorded here, time stamped messaged cannot have max length
} rf230packet_footer_t;

typedef struct rf230packet_metadata_t
{
	flags_metadata_t flags;
	rf230_metadata_t rf230;
	timestamp_metadata_t timestamp;
#ifdef LOW_POWER_LISTENING
	lpl_metadata_t lpl;
#endif
#ifdef PACKET_LINK
	link_metadata_t link;
#endif
} rf230packet_metadata_t;

#endif//__RF230ACTIVEMESSAGE_H__

--- NEW FILE: RF230DriverLayer.h ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

#ifndef __RF230DRIVERLAYER_H__
#define __RF230DRIVERLAYER_H__

typedef struct rf230_metadata_t
{
	uint8_t lqi;
	union
	{
		uint8_t power;
		uint8_t rssi;
	};
} rf230_metadata_t;

enum rf230_registers_enum
{
	RF230_TRX_STATUS = 0x01,
	RF230_TRX_STATE = 0x02,
	RF230_TRX_CTRL_0 = 0x03,
	RF230_PHY_TX_PWR = 0x05,
	RF230_PHY_RSSI = 0x06,
	RF230_PHY_ED_LEVEL = 0x07,
	RF230_PHY_CC_CCA = 0x08,
	RF230_CCA_THRES = 0x09,
	RF230_IRQ_MASK = 0x0E,
	RF230_IRQ_STATUS = 0x0F,
	RF230_VREG_CTRL = 0x10,
	RF230_BATMON = 0x11,
	RF230_XOSC_CTRL = 0x12,
	RF230_PLL_CF = 0x1A,
	RF230_PLL_DCU = 0x1B,
	RF230_PART_NUM = 0x1C,
	RF230_VERSION_NUM = 0x1D,
	RF230_MAN_ID_0 = 0x1E,
	RF230_MAN_ID_1 = 0x1F,
	RF230_SHORT_ADDR_0 = 0x20,
	RF230_SHORT_ADDR_1 = 0x21,
	RF230_PAN_ID_0 = 0x22,
	RF230_PAN_ID_1 = 0x23,
	RF230_IEEE_ADDR_0 = 0x24,
	RF230_IEEE_ADDR_1 = 0x25,
	RF230_IEEE_ADDR_2 = 0x26,
	RF230_IEEE_ADDR_3 = 0x27,
	RF230_IEEE_ADDR_4 = 0x28,
	RF230_IEEE_ADDR_5 = 0x29,
	RF230_IEEE_ADDR_6 = 0x2A,
	RF230_IEEE_ADDR_7 = 0x2B,
	RF230_XAH_CTRL = 0x2C,
	RF230_CSMA_SEED_0 = 0x2D,
	RF230_CSMA_SEED_1 = 0x2E,
};

enum rf230_trx_register_enums
{
	RF230_CCA_DONE = 1 << 7,
	RF230_CCA_STATUS = 1 << 6,
	RF230_TRX_STATUS_MASK = 0x1F,
	RF230_P_ON = 0,
	RF230_BUSY_RX = 1,
	RF230_BUSY_TX = 2,
	RF230_RX_ON = 6,
	RF230_TRX_OFF = 8,
	RF230_PLL_ON = 9,
	RF230_SLEEP = 15,
	RF230_BUSY_RX_AACK = 16,
	RF230_BUSR_TX_ARET = 17,
	RF230_RX_AACK_ON = 22,
	RF230_TX_ARET_ON = 25,
	RF230_RX_ON_NOCLK = 28,
	RF230_AACK_ON_NOCLK = 29,
	RF230_BUSY_RX_AACK_NOCLK = 30,
	RF230_STATE_TRANSITION_IN_PROGRESS = 31,
	RF230_TRAC_STATUS_MASK = 0xE0,
	RF230_TRAC_SUCCESS = 0,
	RF230_TRAC_CHANNEL_ACCESS_FAILURE = 3 << 5,
	RF230_TRAC_NO_ACK = 5 << 5,
	RF230_TRX_CMD_MASK = 0x1F,
	RF230_NOP = 0,
	RF230_TX_START = 2,
	RF230_FORCE_TRX_OFF = 3,
};

enum rf230_phy_register_enums
{
	RF230_TX_AUTO_CRC_ON = 1 << 7,
	RF230_TX_PWR_MASK = 0x0F,
	RF230_RSSI_MASK = 0x1F,
	RF230_CCA_REQUEST = 1 << 7,
	RF230_CCA_MODE_0 = 0 << 5,
	RF230_CCA_MODE_1 = 1 << 5,
	RF230_CCA_MODE_2 = 2 << 5,
	RF230_CCA_MODE_3 = 3 << 5,
	RF230_CHANNEL_DEFAULT = 11,
	RF230_CHANNEL_MASK = 0x1F,
	RF230_CCA_CS_THRES_SHIFT = 4,
	RF230_CCA_ED_THRES_SHIFT = 0,
};

enum rf230_irq_register_enums
{
	RF230_IRQ_BAT_LOW = 1 << 7,
	RF230_IRQ_TRX_UR = 1 << 6,
	RF230_IRQ_TRX_END = 1 << 3,
	RF230_IRQ_RX_START = 1 << 2,
	RF230_IRQ_PLL_UNLOCK = 1 << 1,
	RF230_IRQ_PLL_LOCK = 1 << 0,
};

enum rf230_control_register_enums
{
	RF230_AVREG_EXT = 1 << 7,
	RF230_AVDD_OK = 1 << 6,
	RF230_DVREG_EXT = 1 << 3,
	RF230_DVDD_OK = 1 << 2,
	RF230_BATMON_OK = 1 << 5,
	RF230_BATMON_VHR = 1 << 4,
	RF230_BATMON_VTH_MASK = 0x0F,
	RF230_XTAL_MODE_OFF = 0 << 4,
	RF230_XTAL_MODE_EXTERNAL = 4 << 4,
	RF230_XTAL_MODE_INTERNAL = 15 << 4,
};

enum rf230_pll_register_enums
{
	RF230_PLL_CF_START = 1 << 7,
	RF230_PLL_DCU_START = 1 << 7,
};

enum rf230_spi_command_enums
{
	RF230_CMD_REGISTER_READ = 0x80,
	RF230_CMD_REGISTER_WRITE = 0xC0,
	RF230_CMD_REGISTER_MASK = 0x3F,
	RF230_CMD_FRAME_READ = 0x20,
	RF230_CMD_FRAME_WRITE = 0x60,
	RF230_CMD_SRAM_READ = 0x00,
	RF230_CMD_SRAM_WRITE = 0x40,
};

#endif//__RF230DRIVERLAYER_H__

Index: RF230ActiveMessageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** RF230ActiveMessageC.nc	30 Mar 2009 22:29:48 -0000	1.3
--- RF230ActiveMessageC.nc	2 Apr 2009 22:10:07 -0000	1.4
***************
*** 37,42 ****
  		interface AMPacket;
  		interface PacketAcknowledgements;
- 
- 		// we provide a dummy LowPowerListening interface if LOW_POWER_LISTENING is not defined
  		interface LowPowerListening;
  
--- 37,40 ----
***************
*** 51,54 ****
--- 49,53 ----
  		interface PacketField<uint8_t> as PacketRSSI;
  
+ 		interface LocalTime<TRadio> as LocalTimeRadio;
  		interface PacketTimeStamp<TRadio, uint32_t> as PacketTimeStampRadio;
  		interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
***************
*** 58,62 ****
  implementation
  {
! 	components RF230ActiveMessageP, RF230PacketC, IEEE154Packet2C, RadioAlarmC;
  
  #ifdef RADIO_DEBUG
--- 57,61 ----
  implementation
  {
! 	components RF230ActiveMessageP, IEEE154PacketLayerC, RadioAlarmC;
  
  #ifdef RADIO_DEBUG
***************
*** 64,83 ****
  #endif
  
! 	RF230ActiveMessageP.IEEE154Packet2 -> IEEE154Packet2C;
! 	RF230ActiveMessageP.Packet -> RF230PacketC;
  	RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
  
! 	Packet = RF230PacketC;
! 	AMPacket = RF230PacketC;
! 	PacketAcknowledgements = RF230PacketC;
! 	PacketLinkQuality = RF230PacketC.PacketLinkQuality;
! 	PacketTransmitPower = RF230PacketC.PacketTransmitPower;
! 	PacketRSSI = RF230PacketC.PacketRSSI;
! 	PacketTimeStampRadio = RF230PacketC;
! 	PacketTimeStampMilli = RF230PacketC;
! 	LowPowerListening = LowPowerListeningLayerC;
! 	RadioChannel = MessageBufferLayerC;
  
  	components ActiveMessageLayerC;
  #ifdef TFRAMES_ENABLED
  	components new DummyLayerC() as IEEE154NetworkLayerC;
--- 63,86 ----
  #endif
  
! 	RF230ActiveMessageP.IEEE154PacketLayer -> IEEE154PacketLayerC;
  	RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
+ 	RF230ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
  
! 	Packet = RF230ActiveMessageP;
! 
! // -------- ActiveMessage
  
  	components ActiveMessageLayerC;
+ 	ActiveMessageLayerC.Config -> RF230ActiveMessageP;
+ 	ActiveMessageLayerC.AMPacket -> IEEE154PacketLayerC;
+ 	ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC;
+ 	ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC;
+ 	AMSend = ActiveMessageLayerC;
+ 	Receive = ActiveMessageLayerC.Receive;
+ 	Snoop = ActiveMessageLayerC.Snoop;
+ 	AMPacket = IEEE154PacketLayerC;
+ 
+ // -------- IEEE154Network
+ 
  #ifdef TFRAMES_ENABLED
  	components new DummyLayerC() as IEEE154NetworkLayerC;
***************
*** 85,151 ****
  	components IEEE154NetworkLayerC;
  #endif
  
  #ifdef LOW_POWER_LISTENING
  	components LowPowerListeningLayerC;
! 	LowPowerListeningLayerC.PacketSleepInterval -> RF230PacketC;
! 	LowPowerListeningLayerC.IEEE154Packet2 -> IEEE154Packet2C;
! 	LowPowerListeningLayerC.PacketAcknowledgements -> RF230PacketC;
  #else	
! 	components new DummyLayerC() as LowPowerListeningLayerC;
  #endif
  
  #ifdef PACKET_LINK
  	components PacketLinkLayerC;
  	PacketLink = PacketLinkLayerC;
! 	PacketLinkLayerC.PacketData -> RF230PacketC;
! 	PacketLinkLayerC.PacketAcknowledgements -> RF230PacketC;
  #else
  	components new DummyLayerC() as PacketLinkLayerC;
  #endif
- 
- 	components MessageBufferLayerC;
- 	components UniqueLayerC;
- 	components TrafficMonitorLayerC;
- 
- #ifdef SLOTTED_MAC
- 	components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
- #else
- 	components RandomCollisionLayerC as CollisionAvoidanceLayerC;
- #endif
- 
- 	components SoftwareAckLayerC;
- 	components new DummyLayerC() as CsmaLayerC;
- 	components RF230DriverLayerC;
- 
- 	SplitControl = LowPowerListeningLayerC;
- 	AMSend = ActiveMessageLayerC;
- 	Receive = ActiveMessageLayerC.Receive;
- 	Snoop = ActiveMessageLayerC.Snoop;
- 
- 	ActiveMessageLayerC.Config -> RF230ActiveMessageP;
- 	ActiveMessageLayerC.AMPacket -> IEEE154Packet2C;
- 	ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC;
- 	ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC;
- 
- 	IEEE154NetworkLayerC.SubSend -> UniqueLayerC;
- 	IEEE154NetworkLayerC.SubReceive -> LowPowerListeningLayerC;
- 
- 	// the UniqueLayer is wired at two points
- 	UniqueLayerC.Config -> RF230ActiveMessageP;
- 	UniqueLayerC.SubSend -> LowPowerListeningLayerC;
- 
- 	LowPowerListeningLayerC.SubControl -> MessageBufferLayerC;
- 	LowPowerListeningLayerC.SubSend -> PacketLinkLayerC;
- 	LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
- 
  	PacketLinkLayerC.SubSend -> MessageBufferLayerC;
  
! 	MessageBufferLayerC.Packet -> RF230PacketC;
  	MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
  	MessageBufferLayerC.RadioReceive -> UniqueLayerC;
  	MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
  
  	UniqueLayerC.SubReceive -> TrafficMonitorLayerC;
  
  	TrafficMonitorLayerC.Config -> RF230ActiveMessageP;
  	TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
--- 88,144 ----
  	components IEEE154NetworkLayerC;
  #endif
+ 	IEEE154NetworkLayerC.SubSend -> UniqueLayerC;
+ 	IEEE154NetworkLayerC.SubReceive -> LowPowerListeningLayerC;
+ 
+ // -------- UniqueLayer Send part (wired twice)
+ 
+ 	components UniqueLayerC;
+ 	UniqueLayerC.Config -> RF230ActiveMessageP;
+ 	UniqueLayerC.SubSend -> LowPowerListeningLayerC;
+ 
+ // -------- Low Power Listening 
  
  #ifdef LOW_POWER_LISTENING
  	components LowPowerListeningLayerC;
! 	LowPowerListeningLayerC.PacketLplMetadata -> RF230ActiveMessageP;
! 	LowPowerListeningLayerC.IEEE154PacketLayer -> IEEE154PacketLayerC;
! 	LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
  #else	
! 	components LowPowerListeningDummyC as LowPowerListeningLayerC;
  #endif
+ 	LowPowerListeningLayerC.SubControl -> MessageBufferLayerC;
+ 	LowPowerListeningLayerC.SubSend -> PacketLinkLayerC;
+ 	LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
+ 	SplitControl = LowPowerListeningLayerC;
+ 	LowPowerListening = LowPowerListeningLayerC;
+ 
+ // -------- Packet Link
  
  #ifdef PACKET_LINK
  	components PacketLinkLayerC;
  	PacketLink = PacketLinkLayerC;
! 	PacketLinkLayerC.PacketLinkMetadata -> RF230ActiveMessageP;
! 	PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
  #else
  	components new DummyLayerC() as PacketLinkLayerC;
  #endif
  	PacketLinkLayerC.SubSend -> MessageBufferLayerC;
  
! // -------- MessageBuffer
! 
! 	components MessageBufferLayerC;
! 	MessageBufferLayerC.Packet -> RF230ActiveMessageP;
  	MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
  	MessageBufferLayerC.RadioReceive -> UniqueLayerC;
  	MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
+ 	RadioChannel = MessageBufferLayerC;
+ 
+ // -------- UniqueLayer receive part (wired twice)
  
  	UniqueLayerC.SubReceive -> TrafficMonitorLayerC;
  
+ // -------- Traffic Monitor
+ 
+ 	components TrafficMonitorLayerC;
  	TrafficMonitorLayerC.Config -> RF230ActiveMessageP;
  	TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
***************
*** 153,168 ****
--- 146,197 ----
  	TrafficMonitorLayerC.SubState -> RF230DriverLayerC;
  
+ // -------- CollisionAvoidance
+ 
+ #ifdef SLOTTED_MAC
+ 	components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
+ #else
+ 	components RandomCollisionLayerC as CollisionAvoidanceLayerC;
+ #endif
  	CollisionAvoidanceLayerC.Config -> RF230ActiveMessageP;
  	CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC;
  	CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC;
  
+ // -------- SoftwareAcknowledgement
+ 
+ 	components SoftwareAckLayerC;
  	SoftwareAckLayerC.Config -> RF230ActiveMessageP;
  	SoftwareAckLayerC.SubSend -> CsmaLayerC;
  	SoftwareAckLayerC.SubReceive -> RF230DriverLayerC;
+ 	PacketAcknowledgements = SoftwareAckLayerC;
  
+ // -------- Carrier Sense
+ 
+ 	components new DummyLayerC() as CsmaLayerC;
  	CsmaLayerC.Config -> RF230ActiveMessageP;
  	CsmaLayerC -> RF230DriverLayerC.RadioSend;
  	CsmaLayerC -> RF230DriverLayerC.RadioCCA;
  
+ // -------- RF230 Driver
+ 
+ 	components RF230DriverLayerC;
+ 	RF230DriverLayerC.PacketRF230Metadata -> RF230ActiveMessageP;
  	RF230DriverLayerC.RF230DriverConfig -> RF230ActiveMessageP;
+ 	RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
+ 	PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower;
+ 	PacketLinkQuality = RF230DriverLayerC.PacketLinkQuality;
+ 	PacketRSSI = RF230DriverLayerC.PacketRSSI;
+ 	LocalTimeRadio = RF230DriverLayerC;
+ 
+ // -------- MetadataFlags
+ 
+ 	components MetadataFlagsLayerC;
+ 	MetadataFlagsLayerC.PacketFlagsMetadata -> RF230ActiveMessageP;
+ 
+ // -------- TimeStamping
+ 
+ 	components TimeStampingLayerC;
+ 	TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC;
+ 	TimeStampingLayerC.PacketTimeStampMetadata -> RF230ActiveMessageP;
+ 	PacketTimeStampRadio = TimeStampingLayerC;
+ 	PacketTimeStampMilli = TimeStampingLayerC;
  }

Index: RF230ActiveMessageP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** RF230ActiveMessageP.nc	29 Mar 2009 21:12:06 -0000	1.4
--- RF230ActiveMessageP.nc	2 Apr 2009 22:10:07 -0000	1.5
***************
*** 22,26 ****
   */
  
! #include <RF230Packet.h>
  #include <RadioConfig.h>
  #include <Tasklet.h>
--- 22,26 ----
   */
  
! #include <RF230ActiveMessage.h>
  #include <RadioConfig.h>
  #include <Tasklet.h>
***************
*** 39,49 ****
  		interface ActiveMessageConfig;
  		interface DummyConfig;
  	}
  
  	uses
  	{
! 		interface IEEE154Packet2;
! 		interface Packet;
  		interface RadioAlarm;
  	}
  }
--- 39,63 ----
  		interface ActiveMessageConfig;
  		interface DummyConfig;
+ 
+ 		interface Packet;
+ 
+ 		interface PacketData<flags_metadata_t> as PacketFlagsMetadata;
+ 		interface PacketData<rf230_metadata_t> as PacketRF230Metadata;
+ 		interface PacketData<timestamp_metadata_t> as PacketTimeStampMetadata;
+ 
+ #ifdef LOW_POWER_LISTENING
+ 		interface PacketData<lpl_metadata_t> as PacketLplMetadata;
+ #endif
+ #ifdef PACKET_LINK
+ 		interface PacketData<link_metadata_t> as PacketLinkMetadata;
+ #endif
  	}
  
  	uses
  	{
! 		interface IEEE154PacketLayer;
  		interface RadioAlarm;
+ 
+ 		interface PacketTimeStamp<TRadio, uint32_t>;
  	}
  }
***************
*** 55,74 ****
  	async command uint8_t RF230DriverConfig.getLength(message_t* msg)
  	{
! 		return call IEEE154Packet2.getLength(msg);
  	}
  
  	async command void RF230DriverConfig.setLength(message_t* msg, uint8_t len)
  	{
! 		call IEEE154Packet2.setLength(msg, len);
  	}
  
  	async command uint8_t* RF230DriverConfig.getPayload(message_t* msg)
  	{
! 		return ((uint8_t*)(call IEEE154Packet2.getHeader(msg))) + 1;
! 	}
! 
! 	inline rf230packet_metadata_t* getMeta(message_t* msg)
! 	{
! 		return (rf230packet_metadata_t*)(msg->metadata);
  	}
  
--- 69,83 ----
  	async command uint8_t RF230DriverConfig.getLength(message_t* msg)
  	{
! 		return call IEEE154PacketLayer.getLength(msg);
  	}
  
  	async command void RF230DriverConfig.setLength(message_t* msg, uint8_t len)
  	{
! 		call IEEE154PacketLayer.setLength(msg, len);
  	}
  
  	async command uint8_t* RF230DriverConfig.getPayload(message_t* msg)
  	{
! 		return ((uint8_t*)(call IEEE154PacketLayer.getHeader(msg))) + 1;
  	}
  
***************
*** 87,91 ****
  	async command bool RF230DriverConfig.requiresRssiCca(message_t* msg)
  	{
! 		return call IEEE154Packet2.isDataFrame(msg);
  	}
  
--- 96,100 ----
  	async command bool RF230DriverConfig.requiresRssiCca(message_t* msg)
  	{
! 		return call IEEE154PacketLayer.isDataFrame(msg);
  	}
  
***************
*** 94,126 ****
  	async command bool SoftwareAckConfig.requiresAckWait(message_t* msg)
  	{
! 		return call IEEE154Packet2.requiresAckWait(msg);
  	}
  
  	async command bool SoftwareAckConfig.isAckPacket(message_t* msg)
  	{
! 		return call IEEE154Packet2.isAckFrame(msg);
  	}
  
  	async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack)
  	{
! 		return call IEEE154Packet2.verifyAckReply(data, ack);
  	}
  
! 	async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
  	{
! 		return call IEEE154Packet2.requiresAckReply(msg);
  	}
  
! 	async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
  	{
! 		call IEEE154Packet2.createAckReply(data, ack);
  	}
  
! 	async command void SoftwareAckConfig.setAckReceived(message_t* msg, bool acked)
  	{
! 		if( acked )
! 			getMeta(msg)->flags |= RF230PACKET_WAS_ACKED;
! 		else
! 			getMeta(msg)->flags &= ~RF230PACKET_WAS_ACKED;
  	}
  
--- 103,132 ----
  	async command bool SoftwareAckConfig.requiresAckWait(message_t* msg)
  	{
! 		return call IEEE154PacketLayer.requiresAckWait(msg);
  	}
  
  	async command bool SoftwareAckConfig.isAckPacket(message_t* msg)
  	{
! 		return call IEEE154PacketLayer.isAckFrame(msg);
  	}
  
  	async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack)
  	{
! 		return call IEEE154PacketLayer.verifyAckReply(data, ack);
  	}
  
! 	async command void SoftwareAckConfig.setAckRequired(message_t* msg, bool ack)
  	{
! 		call IEEE154PacketLayer.setAckRequired(msg, ack);
  	}
  
! 	async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
  	{
! 		return call IEEE154PacketLayer.requiresAckReply(msg);
  	}
  
! 	async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
  	{
! 		call IEEE154PacketLayer.createAckReply(data, ack);
  	}
  
***************
*** 139,153 ****
  	async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg)
  	{
! 		return call IEEE154Packet2.getDSN(msg);
  	}
  
  	async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn)
  	{
! 		call IEEE154Packet2.setDSN(msg, dsn);
  	}
  
  	async command am_addr_t UniqueConfig.getSender(message_t* msg)
  	{
! 		return call IEEE154Packet2.getSrcAddr(msg);
  	}
  
--- 145,159 ----
  	async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg)
  	{
! 		return call IEEE154PacketLayer.getDSN(msg);
  	}
  
  	async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn)
  	{
! 		call IEEE154PacketLayer.setDSN(msg, dsn);
  	}
  
  	async command am_addr_t UniqueConfig.getSender(message_t* msg)
  	{
! 		return call IEEE154PacketLayer.getSrcAddr(msg);
  	}
  
***************
*** 162,166 ****
  	{
  		// the user forgot to call clear, we should return EINVAL
! 		if( ! call IEEE154Packet2.isDataFrame(msg) )
  			call Packet.clear(msg);
  
--- 168,172 ----
  	{
  		// the user forgot to call clear, we should return EINVAL
! 		if( ! call IEEE154PacketLayer.isDataFrame(msg) )
  			call Packet.clear(msg);
  
***************
*** 172,176 ****
  	async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg)
  	{
! 		return call IEEE154Packet2.isDataFrame(msg);
  	}
  
--- 178,182 ----
  	async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg)
  	{
! 		return call IEEE154PacketLayer.isDataFrame(msg);
  	}
  
***************
*** 197,207 ****
  		 */
  
! 		uint8_t len = call IEEE154Packet2.getLength(msg);
! 		return call IEEE154Packet2.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
  	}
  
  	async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg)
  	{
! 		return call IEEE154Packet2.getSrcAddr(msg);
  	}
  
--- 203,213 ----
  		 */
  
! 		uint8_t len = call IEEE154PacketLayer.getLength(msg);
! 		return call IEEE154PacketLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
  	}
  
  	async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg)
  	{
! 		return call IEEE154PacketLayer.getSrcAddr(msg);
  	}
  
***************
*** 245,249 ****
  
  		// estimated response time (download the message, etc) is 5-8 bytes
! 		if( call IEEE154Packet2.requiresAckReply(msg) )
  			time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RADIO_ALARM_MICROSEC);
  		else
--- 251,255 ----
  
  		// estimated response time (download the message, etc) is 5-8 bytes
! 		if( call IEEE154PacketLayer.requiresAckReply(msg) )
  			time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RADIO_ALARM_MICROSEC);
  		else
***************
*** 270,274 ****
  	{
  		// TODO: check if the timestamp is correct
! 		return getMeta(msg)->timestamp;
  	}
  
--- 276,280 ----
  	{
  		// TODO: check if the timestamp is correct
! 		return call PacketTimeStamp.timestamp(msg);
  	}
  
***************
*** 276,280 ****
  	{
  		// the preamble (4 bytes), SFD (1 byte), plus two extra for safety
! 		return getMeta(msg)->timestamp - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC);
  	}
  
--- 282,286 ----
  	{
  		// the preamble (4 bytes), SFD (1 byte), plus two extra for safety
! 		return (call PacketTimeStamp.timestamp(msg)) - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC);
  	}
  
***************
*** 291,293 ****
--- 297,381 ----
  	{
  	}
+ 
+ /*----------------- Metadata -----------------*/
+ 
+ 	inline rf230packet_metadata_t* getMeta(message_t* msg)
+ 	{
+ 		return (rf230packet_metadata_t*)(msg->metadata);
+ 	}
+ 
+ 	async command flags_metadata_t* PacketFlagsMetadata.get(message_t* msg)
+ 	{
+ 		return &(getMeta(msg)->flags);
+ 	}
+ 
+ 	async command rf230_metadata_t* PacketRF230Metadata.get(message_t* msg)
+ 	{
+ 		return &(getMeta(msg)->rf230);
+ 	}
+ 
+ 	async command timestamp_metadata_t* PacketTimeStampMetadata.get(message_t* msg)
+ 	{
+ 		return &(getMeta(msg)->timestamp);
+ 	}
+ 
+ #ifdef LOW_POWER_LISTENING
+ 	async command lpl_metadata_t* PacketLplMetadata.get(message_t* msg)
+ 	{
+ 		return &(getMeta(msg)->lpl);
+ 	}
+ #endif
+ 
+ #ifdef PACKET_LINK
+ 	async command link_metadata_t* PacketLinkMetadata.get(message_t* msg)
+ 	{
+ 		return &(getMeta(msg)->link);
+ 	}
+ #endif
+ 
+ /*----------------- Packet -----------------*/
+ 
+ 	enum
+ 	{
+ 		PACKET_LENGTH_INCREASE =
+ 			sizeof(rf230packet_header_t) - 1	// the 8-bit length field is not counted
+ 			+ sizeof(ieee154_footer_t),		// the CRC is not stored in memory
+ 	};
+ 
+ 	command void Packet.clear(message_t* msg)
+ 	{
+ 		signal PacketFlagsMetadata.clear(msg);
+ 		signal PacketRF230Metadata.clear(msg);
+ 		signal PacketTimeStampMetadata.clear(msg);
+ #ifdef LOW_POWER_LISTENING
+ 		signal PacketLplMetadata.clear(msg);
+ #endif
+ #ifdef PACKET_LINK
+ 		signal PacketLinkMetadata.clear(msg);
+ #endif
+ 		call IEEE154PacketLayer.createDataFrame(msg);
+ 	}
+ 
+ 	inline command void Packet.setPayloadLength(message_t* msg, uint8_t len)
+ 	{
+ 		call IEEE154PacketLayer.setLength(msg, len + PACKET_LENGTH_INCREASE);
+ 	}
+ 
+ 	inline command uint8_t Packet.payloadLength(message_t* msg)
+ 	{
+ 		return call IEEE154PacketLayer.getLength(msg) - PACKET_LENGTH_INCREASE;
+ 	}
+ 
+ 	inline command uint8_t Packet.maxPayloadLength()
+ 	{
+ 		return TOSH_DATA_LENGTH;
+ 	}
+ 
+ 	command void* Packet.getPayload(message_t* msg, uint8_t len)
+ 	{
+ 		if( len > TOSH_DATA_LENGTH )
+ 			return NULL;
+ 
+ 		return msg->data;
+ 	}
  }

Index: RF230DriverLayerC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230DriverLayerC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RF230DriverLayerC.nc	10 Mar 2009 20:37:58 -0000	1.1
--- RF230DriverLayerC.nc	2 Apr 2009 22:10:07 -0000	1.2
***************
*** 22,25 ****
--- 22,28 ----
   */
  
+ #include <RadioConfig.h>
+ #include <RF230DriverLayer.h>
+ 
  configuration RF230DriverLayerC
  {
***************
*** 30,41 ****
  		interface RadioReceive;
  		interface RadioCCA;
  	}
  
! 	uses interface RF230DriverConfig;
  }
  
  implementation
  {
! 	components RF230DriverLayerP, HplRF230C, BusyWaitMicroC, TaskletC, MainC, RadioAlarmC, RF230PacketC, LocalTimeMicroC as LocalTimeRadioC;
  
  	RadioState = RF230DriverLayerP;
--- 33,56 ----
  		interface RadioReceive;
  		interface RadioCCA;
+ 
+ 		interface PacketField<uint8_t> as PacketTransmitPower;
+ 		interface PacketField<uint8_t> as PacketRSSI;
+ 		interface PacketField<uint8_t> as PacketTimeSyncOffset;
+ 		interface PacketField<uint8_t> as PacketLinkQuality;
+ 
+ 		interface LocalTime<TRadio> as LocalTimeRadio;
  	}
  
! 	uses
! 	{
! 		interface RF230DriverConfig;
! 		interface PacketTimeStamp<TRadio, uint32_t>;
! 		interface PacketData<rf230_metadata_t> as PacketRF230Metadata;
! 	}
  }
  
  implementation
  {
! 	components RF230DriverLayerP, HplRF230C, BusyWaitMicroC, TaskletC, MainC, RadioAlarmC;
  
  	RadioState = RF230DriverLayerP;
***************
*** 44,55 ****
  	RadioCCA = RF230DriverLayerP;
  
  	RF230DriverConfig = RF230DriverLayerP;
  
! 	RF230DriverLayerP.PacketLinkQuality -> RF230PacketC.PacketLinkQuality;
! 	RF230DriverLayerP.PacketTransmitPower -> RF230PacketC.PacketTransmitPower;
! 	RF230DriverLayerP.PacketRSSI -> RF230PacketC.PacketRSSI;
! 	RF230DriverLayerP.PacketTimeSyncOffset -> RF230PacketC.PacketTimeSyncOffset;
! 	RF230DriverLayerP.PacketTimeStamp -> RF230PacketC;
! 	RF230DriverLayerP.LocalTime -> LocalTimeRadioC;
  
  	RF230DriverLayerP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
--- 59,83 ----
  	RadioCCA = RF230DriverLayerP;
  
+ 	LocalTimeRadio = HplRF230C;
+ 
  	RF230DriverConfig = RF230DriverLayerP;
+ 	PacketRF230Metadata = RF230DriverLayerP;
  
! 	PacketTransmitPower = RF230DriverLayerP.PacketTransmitPower;
! 	components new MetadataFlagC() as TransmitPowerFlagC;
! 	RF230DriverLayerP.TransmitPowerFlag -> TransmitPowerFlagC;
! 
! 	PacketRSSI = RF230DriverLayerP.PacketRSSI;
! 	components new MetadataFlagC() as RSSIFlagC;
! 	RF230DriverLayerP.RSSIFlag -> RSSIFlagC;
! 
! 	PacketTimeSyncOffset = RF230DriverLayerP.PacketTimeSyncOffset;
! 	components new MetadataFlagC() as TimeSyncFlagC;
! 	RF230DriverLayerP.TimeSyncFlag -> TimeSyncFlagC;
! 
! 	PacketLinkQuality = RF230DriverLayerP.PacketLinkQuality;
! 	PacketTimeStamp = RF230DriverLayerP.PacketTimeStamp;
! 
! 	RF230DriverLayerP.LocalTime -> HplRF230C;
  
  	RF230DriverLayerP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];

Index: RF230DriverLayerP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230DriverLayerP.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** RF230DriverLayerP.nc	27 Mar 2009 21:55:10 -0000	1.4
--- RF230DriverLayerP.nc	2 Apr 2009 22:10:07 -0000	1.5
***************
*** 22,26 ****
   */
  
! #include <RF230.h>
  #include <Tasklet.h>
  #include <RadioAssert.h>
--- 22,26 ----
   */
  
! #include <RF230DriverLayer.h>
  #include <Tasklet.h>
  #include <RadioAssert.h>
***************
*** 39,42 ****
--- 39,47 ----
  		interface RadioReceive;
  		interface RadioCCA;
+ 
+ 		interface PacketField<uint8_t> as PacketTransmitPower;
+ 		interface PacketField<uint8_t> as PacketRSSI;
+ 		interface PacketField<uint8_t> as PacketTimeSyncOffset;
+ 		interface PacketField<uint8_t> as PacketLinkQuality;
  	}
  
***************
*** 54,67 ****
  
  		interface BusyWait<TMicro, uint16_t>;
  
! 		interface PacketField<uint8_t> as PacketLinkQuality;
! 		interface PacketField<uint8_t> as PacketTransmitPower;
! 		interface PacketField<uint8_t> as PacketRSSI;
! 		interface PacketField<uint8_t> as PacketTimeSyncOffset;
  
  		interface PacketTimeStamp<TRadio, uint32_t>;
- 		interface LocalTime<TRadio>;
  
- 		interface RF230DriverConfig;
  		interface Tasklet;
  		interface RadioAlarm;
--- 59,73 ----
  
  		interface BusyWait<TMicro, uint16_t>;
+ 		interface LocalTime<TRadio>;
  
! 		interface RF230DriverConfig;
! 
! 		interface PacketData<rf230_metadata_t> as PacketRF230Metadata;
! 		interface PacketFlag as TransmitPowerFlag;
! 		interface PacketFlag as RSSIFlag;
! 		interface PacketFlag as TimeSyncFlag;
  
  		interface PacketTimeStamp<TRadio, uint32_t>;
  
  		interface Tasklet;
  		interface RadioAlarm;
***************
*** 830,832 ****
--- 836,946 ----
  			call SpiResource.release();
  	}
+ 
+ /*----------------- PACKET -----------------*/
+ 
+ 	async event void PacketRF230Metadata.clear(message_t* msg)
+ 	{
+ 	}
+ 
+ // --- TransmitPower
+ 
+ 	async command bool PacketTransmitPower.isSet(message_t* msg)
+ 	{
+ 		return call TransmitPowerFlag.get(msg);
+ 	}
+ 
+ 	async command uint8_t PacketTransmitPower.get(message_t* msg)
+ 	{
+ 		return (call PacketRF230Metadata.get(msg))->power;
+ 	}
+ 
+ 	async command void PacketTransmitPower.clear(message_t* msg)
+ 	{
+ 		call TransmitPowerFlag.clear(msg);
+ 	}
+ 
+ 	async command void PacketTransmitPower.set(message_t* msg, uint8_t value)
+ 	{
+ 		call TransmitPowerFlag.set(msg);
+ 		(call PacketRF230Metadata.get(msg))->power = value;
+ 	}
+ 
+ // --- RSSI
+ 
+ 	async command bool PacketRSSI.isSet(message_t* msg)
+ 	{
+ 		return call RSSIFlag.get(msg);
+ 	}
+ 
+ 	async command uint8_t PacketRSSI.get(message_t* msg)
+ 	{
+ 		return (call PacketRF230Metadata.get(msg))->rssi;
+ 	}
+ 
+ 	async command void PacketRSSI.clear(message_t* msg)
+ 	{
+ 		call RSSIFlag.clear(msg);
+ 	}
+ 
+ 	async command void PacketRSSI.set(message_t* msg, uint8_t value)
+ 	{
+ 		// just to be safe if the user fails to clear the packet
+ 		call TransmitPowerFlag.clear(msg);
+ 
+ 		call RSSIFlag.set(msg);
+ 		(call PacketRF230Metadata.get(msg))->rssi = value;
+ 	}
+ 
+ // --- TimeSyncOffset
+ 
+ 	enum
+ 	{
+ 		PACKET_LENGTH_INCREASE =
+ 			sizeof(rf230packet_header_t) - 1	// the 8-bit length field is not counted
+ 			+ sizeof(ieee154_footer_t),		// the CRC is not stored in memory
+ 	};
+ 
+ 	async command bool PacketTimeSyncOffset.isSet(message_t* msg)
+ 	{
+ 		return call TimeSyncFlag.get(msg);
+ 	}
+ 
+ 	async command uint8_t PacketTimeSyncOffset.get(message_t* msg)
+ 	{
+ 		return call RF230DriverConfig.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t);
+ 	}
+ 
+ 	async command void PacketTimeSyncOffset.clear(message_t* msg)
+ 	{
+ 		call TimeSyncFlag.clear(msg);
+ 	}
+ 
+ 	async command void PacketTimeSyncOffset.set(message_t* msg, uint8_t value)
+ 	{
+ 		// we do not store the value, the time sync field is always the last 4 bytes
+ 		ASSERT( call RF230DriverConfig.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t) == value );
+ 
+ 		call TimeSyncFlag.set(msg);
+ 	}
+ 
+ // --- LinkQuality
+ 
+ 	async command bool PacketLinkQuality.isSet(message_t* msg)
+ 	{
+ 		return TRUE;
+ 	}
+ 
+ 	async command uint8_t PacketLinkQuality.get(message_t* msg)
+ 	{
+ 		return (call PacketRF230Metadata.get(msg))->lqi;
+ 	}
+ 
+ 	async command void PacketLinkQuality.clear(message_t* msg)
+ 	{
+ 	}
+ 
+ 	async command void PacketLinkQuality.set(message_t* msg, uint8_t value)
+ 	{
+ 		(call PacketRF230Metadata.get(msg))->lqi = value;
+ 	}
  }

--- RF230.h DELETED ---

--- RF230Packet.h DELETED ---

--- RF230PacketC.nc DELETED ---

--- RF230PacketP.nc DELETED ---



More information about the Tinyos-2-commits mailing list