]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
support ActiveMessageC and Ieee154MessageC simultaneously
authormmaroti <mmaroti>
Fri, 18 Sep 2009 22:04:48 +0000 (22:04 +0000)
committermmaroti <mmaroti>
Fri, 18 Sep 2009 22:04:48 +0000 (22:04 +0000)
21 files changed:
tos/chips/rf2xx/layers/ActiveMessageLayerC.nc
tos/chips/rf2xx/layers/AutoResourceAcquireLayerC.nc [new file with mode: 0644]
tos/chips/rf2xx/layers/IEEE154MessageLayer.h [deleted file]
tos/chips/rf2xx/layers/IEEE154MessageLayer.nc [deleted file]
tos/chips/rf2xx/layers/IEEE154MessageLayerC.nc [deleted file]
tos/chips/rf2xx/layers/IEEE154MessageLayerP.nc [deleted file]
tos/chips/rf2xx/layers/Ieee154MessageLayerC.nc [new file with mode: 0644]
tos/chips/rf2xx/layers/LowpanNetworkLayer.h [deleted file]
tos/chips/rf2xx/layers/LowpanNetworkLayerC.nc [deleted file]
tos/chips/rf2xx/layers/TinyosNetworkLayer.h [new file with mode: 0644]
tos/chips/rf2xx/layers/TinyosNetworkLayerC.nc [new file with mode: 0644]
tos/chips/rf2xx/rf230/RF230ActiveMessage.h [deleted file]
tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc
tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc [deleted file]
tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc
tos/chips/rf2xx/rf230/RF230Radio.h [new file with mode: 0644]
tos/chips/rf2xx/rf230/RF230RadioC.nc [new file with mode: 0644]
tos/chips/rf2xx/rf230/RF230RadioP.nc [new file with mode: 0644]
tos/platforms/iris/ActiveMessageC.nc
tos/platforms/iris/Ieee154MessageC.nc
tos/platforms/iris/platform_message.h

index 5404beca6ee5e26045276ce9373e0e4147c16b4a..8ca6dce1f82defeb622de5d551ce1b292104c098 100755 (executable)
@@ -25,7 +25,6 @@ configuration ActiveMessageLayerC
 {
        provides
        {
-               interface RadioPacket;
                interface AMPacket;
                interface Packet;
                interface AMSend[am_id_t id];
@@ -48,7 +47,6 @@ implementation
        components ActiveMessageLayerP, ActiveMessageAddressC;
        ActiveMessageLayerP.ActiveMessageAddress -> ActiveMessageAddressC;
 
-       RadioPacket = ActiveMessageLayerP;
        AMPacket = ActiveMessageLayerP;
        Packet = ActiveMessageLayerP;
        AMSend = ActiveMessageLayerP;
diff --git a/tos/chips/rf2xx/layers/AutoResourceAcquireLayerC.nc b/tos/chips/rf2xx/layers/AutoResourceAcquireLayerC.nc
new file mode 100644 (file)
index 0000000..7d3c846
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2009, 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
+ */
+
+generic module AutoResourceAcquireLayerC()
+{
+       provides
+       {
+               interface BareSend;
+       }
+
+       uses
+       {
+               interface BareSend as SubSend;
+               interface Resource;
+       }
+}
+
+implementation
+{
+       message_t *pending;
+
+       command error_t BareSend.send(message_t* msg)
+       {
+               if( call Resource.immediateRequest() == SUCCESS )
+               {
+                       error_t result = call SubSend.send(msg);
+                       if( result != SUCCESS )
+                               call Resource.release();
+
+                       return result;
+               }
+
+               pending = msg;
+               return call Resource.request();
+       }
+
+       event void Resource.granted()
+       {
+               error_t result = call SubSend.send(pending);
+               if( result != SUCCESS )
+               {
+                       call Resource.release();
+                       signal BareSend.sendDone(pending, result);
+               }
+       }
+
+       event void SubSend.sendDone(message_t* msg, error_t result)
+       {
+               call Resource.release();
+               signal BareSend.sendDone(msg, result);
+       }
+
+       command error_t BareSend.cancel(message_t* msg)
+       {
+               return call SubSend.cancel(msg);
+       }
+}
diff --git a/tos/chips/rf2xx/layers/IEEE154MessageLayer.h b/tos/chips/rf2xx/layers/IEEE154MessageLayer.h
deleted file mode 100644 (file)
index 31ab0ea..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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 __IEEE154MESSAGELAYER_H__
-#define __IEEE154MESSAGELAYER_H__
-
-typedef nx_struct ieee154_header_t
-{
-       nxle_uint16_t fcf;
-       nxle_uint8_t dsn;
-       nxle_uint16_t destpan;
-       nxle_uint16_t dest;
-       nxle_uint16_t src;
-} ieee154_header_t;
-
-enum ieee154_fcf_enums {
-       IEEE154_FCF_FRAME_TYPE = 0,
-       IEEE154_FCF_SECURITY_ENABLED = 3,
-       IEEE154_FCF_FRAME_PENDING = 4,
-       IEEE154_FCF_ACK_REQ = 5,
-       IEEE154_FCF_INTRAPAN = 6,
-       IEEE154_FCF_DEST_ADDR_MODE = 10,
-       IEEE154_FCF_SRC_ADDR_MODE = 14,
-};
-
-enum ieee154_fcf_type_enums {
-       IEEE154_TYPE_BEACON = 0,
-       IEEE154_TYPE_DATA = 1,
-       IEEE154_TYPE_ACK = 2,
-       IEEE154_TYPE_MAC_CMD = 3,
-       IEEE154_TYPE_MASK = 7,
-};
-
-enum iee154_fcf_addr_mode_enums {
-       IEEE154_ADDR_NONE = 0,
-       IEEE154_ADDR_SHORT = 2,
-       IEEE154_ADDR_EXT = 3,
-       IEEE154_ADDR_MASK = 3,
-};
-
-#endif//__IEEE154MESSAGELAYER_H__
diff --git a/tos/chips/rf2xx/layers/IEEE154MessageLayer.nc b/tos/chips/rf2xx/layers/IEEE154MessageLayer.nc
deleted file mode 100644 (file)
index be98e1b..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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
- */
-
-#include <IEEE154MessageLayer.h>
-#include <message.h>
-
-/**
- * This interface encapsulates IEEE 802.15.4 intrapan data frames with 
- * 16-bit destination pan, source and destination addresses. It also 
- * supports 6LowPan interoperability mode, and acknowledgement frames.
- * Note, that this interface does not support the CRC-16 value, which
- * should be verified before the data can be trusted.
- */
-interface IEEE154MessageLayer
-{
-       /**
-        * Returns the frame control field. This method should not be used, 
-        * isDataFrame and isAckFrame should be used instead.
-        */
-       async command uint16_t getFCF(message_t* msg);
-
-       /**
-        * Sets the frame control field. This method should not be used, 
-        * createDataFrame and createAckFrame should be used instead.
-        */
-       async command void setFCF(message_t* msg, uint16_t fcf);
-
-       /**
-        * Returns TRUE if the message is a data frame supported by 
-        * this interface (based on the value of the FCF).
-        */
-       async command bool isDataFrame(message_t* msg);
-
-       /**
-        * Sets the FCF to create a data frame supported by this interface.
-        * You may call setAckRequired and setFramePending commands after this.
-        */
-       async command void createDataFrame(message_t* msg);
-
-       /**
-        * Returns TRUE if the message is an acknowledgement frame supported
-        * by this interface (based on the value of the FCF).
-        */
-       async command bool isAckFrame(message_t* msg);
-
-       /**
-        * Sets the FCF to create an acknowledgement frame supported by
-        * this interface. You may call setFramePending after this.
-        */
-       async command void createAckFrame(message_t* msg);
-
-       /**
-        * Creates an acknowledgement packet for the given data packet.
-        * This also sets the DSN value. The data message must be a 
-        * data frame, the ack message will be overwritten.
-        */
-       async command void createAckReply(message_t* data, message_t* ack);
-
-       /**
-        * Returns TRUE if the acknowledgement packet corresponds to the
-        * data packet. The data message must be a data packet.
-        */
-       async command bool verifyAckReply(message_t* data, message_t* ack);
-
-       /**
-        * Returns TRUE if the ACK required field is set in the FCF.
-        */
-       async command bool getAckRequired(message_t* msg);
-
-       /**
-        * Sets the ACK required field in the FCF, should never be set
-        * for acknowledgement frames.
-        */
-       async command void setAckRequired(message_t* msg, bool ack);
-
-       /**
-        * Returns TRUE if the frame pending field is set in the FCF.
-        */
-       async command bool getFramePending(message_t* msg);
-
-       /**
-        * Sets the frame pending field in the FCF.
-        */
-       async command void setFramePending(message_t* msg, bool pending);
-
-       /**
-        * Returns the data sequence number
-        */
-       async command uint8_t getDSN(message_t* msg);
-
-       /**
-        * Sets the data sequence number
-        */
-       async command void setDSN(message_t* msg, uint8_t dsn);
-
-       /**
-        * returns the destination PAN id, values <= 255 are tinyos groups,
-        * valid only for data frames
-        */
-       async command uint16_t getDestPan(message_t* msg);
-
-       /**
-        * Sets the destination PAN id, valid only for data frames
-        */
-       async command void setDestPan(message_t* msg, uint16_t pan);
-
-       /**
-        * Returns the destination address, valid only for data frames
-        */
-       async command uint16_t getDestAddr(message_t* msg);
-
-       /**
-        * Sets the destination address, valid only for data frames
-        */
-       async command void setDestAddr(message_t* msg, uint16_t addr);
-
-       /**
-        * Returns the source address, valid only for data frames
-        */
-       async command uint16_t getSrcAddr(message_t* msg);
-
-       /**
-        * Sets the source address, valid only for data frames
-        */
-       async command void setSrcAddr(message_t* msg, uint16_t addr);
-
-       /**
-        * Returns TRUE if the packet is a data packet, the ACK_REQ field
-        * is set and the destination address is not the broadcast address.
-        */
-       async command bool requiresAckWait(message_t* msg);
-
-       /**
-        * Returns TRUE if the packet is a data packet, the ACK_REQ field
-        * is set and the destionation address is this node.
-        */
-       async command bool requiresAckReply(message_t* msg);
-}
diff --git a/tos/chips/rf2xx/layers/IEEE154MessageLayerC.nc b/tos/chips/rf2xx/layers/IEEE154MessageLayerC.nc
deleted file mode 100644 (file)
index 8c93f42..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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
- */
-
-configuration IEEE154MessageLayerC
-{
-       provides
-       {
-               interface IEEE154MessageLayer;
-               interface RadioPacket;
-
-               // for passthrough wiring
-               interface BareSend as Send;
-
-               // for gateway wiring
-               interface Ieee154Packet;
-               interface Packet;
-               interface Ieee154Send;
-               interface Receive as Ieee154Receive;
-               interface SendNotifier;
-       }
-
-       uses
-       {
-               interface RadioPacket as SubPacket;
-               interface BareSend as SubSend;
-
-               // for gateway wiring
-               interface BareReceive as SubReceive;
-       }
-}
-
-implementation
-{
-       components IEEE154MessageLayerP, ActiveMessageAddressC;
-       IEEE154MessageLayerP.ActiveMessageAddress -> ActiveMessageAddressC;
-
-       IEEE154MessageLayer = IEEE154MessageLayerP;
-       RadioPacket = IEEE154MessageLayerP;
-       SubPacket = IEEE154MessageLayerP;
-
-       // for passthrough
-       Send = IEEE154MessageLayerP;
-       SubSend = IEEE154MessageLayerP;
-
-       Ieee154Packet = IEEE154MessageLayerP;
-       Packet = IEEE154MessageLayerP;
-       Ieee154Send = IEEE154MessageLayerP;
-       Ieee154Receive = IEEE154MessageLayerP;
-       SubReceive = IEEE154MessageLayerP;
-       SendNotifier = IEEE154MessageLayerP;
-}
diff --git a/tos/chips/rf2xx/layers/IEEE154MessageLayerP.nc b/tos/chips/rf2xx/layers/IEEE154MessageLayerP.nc
deleted file mode 100644 (file)
index 9b59ff9..0000000
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * 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
- */
-
-#include <IEEE154MessageLayer.h>
-
-module IEEE154MessageLayerP
-{
-       provides 
-       {
-               interface IEEE154MessageLayer;
-               interface RadioPacket;
-               interface Ieee154Packet;
-               interface Packet;
-               interface Ieee154Send;
-               interface BareSend as Send;
-               interface Receive as Ieee154Receive;
-               interface SendNotifier;
-       }
-
-       uses
-       {
-               interface ActiveMessageAddress;
-               interface RadioPacket as SubPacket;
-               interface BareSend as SubSend;
-               interface BareReceive as SubReceive;
-       }
-}
-
-implementation
-{
-/*----------------- IEEE154Message -----------------*/
-
-       enum
-       {
-               IEEE154_DATA_FRAME_MASK = (IEEE154_TYPE_MASK << IEEE154_FCF_FRAME_TYPE) 
-                       | (1 << IEEE154_FCF_INTRAPAN) 
-                       | (IEEE154_ADDR_MASK << IEEE154_FCF_DEST_ADDR_MODE) 
-                       | (IEEE154_ADDR_MASK << IEEE154_FCF_SRC_ADDR_MODE),
-
-               IEEE154_DATA_FRAME_VALUE = (IEEE154_TYPE_DATA << IEEE154_FCF_FRAME_TYPE) 
-                       | (1 << IEEE154_FCF_INTRAPAN) 
-                       | (IEEE154_ADDR_SHORT << IEEE154_FCF_DEST_ADDR_MODE) 
-                       | (IEEE154_ADDR_SHORT << IEEE154_FCF_SRC_ADDR_MODE),
-
-               IEEE154_ACK_FRAME_LENGTH = 3,   // includes the FCF, DSN
-               IEEE154_ACK_FRAME_MASK = (IEEE154_TYPE_MASK << IEEE154_FCF_FRAME_TYPE), 
-               IEEE154_ACK_FRAME_VALUE = (IEEE154_TYPE_ACK << IEEE154_FCF_FRAME_TYPE),
-       };
-
-       ieee154_header_t* getHeader(message_t* msg)
-       {
-               return ((void*)msg) + call SubPacket.headerLength(msg);
-       }
-
-       void* getPayload(message_t* msg)
-       {
-               return ((void*)msg) + call RadioPacket.headerLength(msg);
-       }
-
-       async command uint16_t IEEE154MessageLayer.getFCF(message_t* msg)
-       {
-               return getHeader(msg)->fcf;
-       }
-
-       async command void IEEE154MessageLayer.setFCF(message_t* msg, uint16_t fcf)
-       {
-               getHeader(msg)->fcf = fcf;
-       }
-
-       async command bool IEEE154MessageLayer.isDataFrame(message_t* msg)
-       {
-               return (getHeader(msg)->fcf & IEEE154_DATA_FRAME_MASK) == IEEE154_DATA_FRAME_VALUE;
-       }
-
-       async command void IEEE154MessageLayer.createDataFrame(message_t* msg)
-       {
-               getHeader(msg)->fcf = IEEE154_DATA_FRAME_VALUE;
-       }
-
-       async command bool IEEE154MessageLayer.isAckFrame(message_t* msg)
-       {
-               return (getHeader(msg)->fcf & IEEE154_ACK_FRAME_MASK) == IEEE154_ACK_FRAME_VALUE;
-       }
-
-       async command void IEEE154MessageLayer.createAckFrame(message_t* msg)
-       {
-               call SubPacket.setPayloadLength(msg, IEEE154_ACK_FRAME_LENGTH);
-               getHeader(msg)->fcf = IEEE154_ACK_FRAME_VALUE;
-       }
-
-       async command void IEEE154MessageLayer.createAckReply(message_t* data, message_t* ack)
-       {
-               ieee154_header_t* header = getHeader(ack);
-               call SubPacket.setPayloadLength(ack, IEEE154_ACK_FRAME_LENGTH);
-
-               header->fcf = IEEE154_ACK_FRAME_VALUE;
-               header->dsn = getHeader(data)->dsn;
-       }
-
-       async command bool IEEE154MessageLayer.verifyAckReply(message_t* data, message_t* ack)
-       {
-               ieee154_header_t* header = getHeader(ack);
-
-               return header->dsn == getHeader(data)->dsn
-                       && (header->fcf & IEEE154_ACK_FRAME_MASK) == IEEE154_ACK_FRAME_VALUE;
-       }
-
-       async command bool IEEE154MessageLayer.getAckRequired(message_t* msg)
-       {
-               return getHeader(msg)->fcf & (1 << IEEE154_FCF_ACK_REQ);
-       }
-
-       async command void IEEE154MessageLayer.setAckRequired(message_t* msg, bool ack)
-       {
-               if( ack )
-                       getHeader(msg)->fcf |= (1 << IEEE154_FCF_ACK_REQ);
-               else
-                       getHeader(msg)->fcf &= ~(uint16_t)(1 << IEEE154_FCF_ACK_REQ);
-       }
-
-       async command bool IEEE154MessageLayer.getFramePending(message_t* msg)
-       {
-               return getHeader(msg)->fcf & (1 << IEEE154_FCF_FRAME_PENDING);
-       }
-
-       async command void IEEE154MessageLayer.setFramePending(message_t* msg, bool pending)
-       {
-               if( pending )
-                       getHeader(msg)->fcf |= (1 << IEEE154_FCF_FRAME_PENDING);
-               else
-                       getHeader(msg)->fcf &= ~(uint16_t)(1 << IEEE154_FCF_FRAME_PENDING);
-       }
-
-       async command uint8_t IEEE154MessageLayer.getDSN(message_t* msg)
-       {
-               return getHeader(msg)->dsn;
-       }
-
-       async command void IEEE154MessageLayer.setDSN(message_t* msg, uint8_t dsn)
-       {
-               getHeader(msg)->dsn = dsn;
-       }
-
-       async command uint16_t IEEE154MessageLayer.getDestPan(message_t* msg)
-       {
-               return getHeader(msg)->destpan;
-       }
-
-       async command void IEEE154MessageLayer.setDestPan(message_t* msg, uint16_t pan)
-       {
-               getHeader(msg)->destpan = pan;
-       }
-
-       async command uint16_t IEEE154MessageLayer.getDestAddr(message_t* msg)
-       {
-               return getHeader(msg)->dest;
-       }
-
-       async command void IEEE154MessageLayer.setDestAddr(message_t* msg, uint16_t addr)
-       {
-               getHeader(msg)->dest = addr;
-       }
-
-       async command uint16_t IEEE154MessageLayer.getSrcAddr(message_t* msg)
-       {
-               return getHeader(msg)->src;
-       }
-
-       async command void IEEE154MessageLayer.setSrcAddr(message_t* msg, uint16_t addr)
-       {       
-               getHeader(msg)->src = addr;
-       }
-
-       async command bool IEEE154MessageLayer.requiresAckWait(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getAckRequired(msg)
-                       && call IEEE154MessageLayer.isDataFrame(msg)
-                       && call IEEE154MessageLayer.getDestAddr(msg) != 0xFFFF;
-       }
-
-       async command bool IEEE154MessageLayer.requiresAckReply(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getAckRequired(msg)
-                       && call IEEE154MessageLayer.isDataFrame(msg)
-                       && call IEEE154MessageLayer.getDestAddr(msg) == call ActiveMessageAddress.amAddress();
-       }
-
-       async event void ActiveMessageAddress.changed()
-       {
-       }
-
-/*----------------- Ieee154Packet -----------------*/
-
-       command ieee154_saddr_t Ieee154Packet.address()
-       {
-               return call ActiveMessageAddress.amAddress();
-       }
-
-       command ieee154_saddr_t Ieee154Packet.destination(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getDestAddr(msg);
-       }
-       command ieee154_saddr_t Ieee154Packet.source(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getSrcAddr(msg);
-       }
-
-       command void Ieee154Packet.setDestination(message_t* msg, ieee154_saddr_t addr)
-       {
-               call IEEE154MessageLayer.setDestAddr(msg, addr);
-       }
-
-       command void Ieee154Packet.setSource(message_t* msg, ieee154_saddr_t addr)
-       {
-               call IEEE154MessageLayer.setSrcAddr(msg, addr);
-       }
-
-       command bool Ieee154Packet.isForMe(message_t* msg)
-       {
-               ieee154_saddr_t addr = call Ieee154Packet.destination(msg);
-               return addr == call Ieee154Packet.address() || addr == IEEE154_BROADCAST_ADDR;
-       }
-
-       command ieee154_panid_t Ieee154Packet.pan(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getDestPan(msg);
-       }
-
-       command void Ieee154Packet.setPan(message_t* msg, ieee154_panid_t grp)
-       {
-               call IEEE154MessageLayer.setDestPan(msg, grp);
-       }
-
-       command ieee154_panid_t Ieee154Packet.localPan()
-       {
-               return call ActiveMessageAddress.amGroup();
-       }
-
-/*----------------- RadioPacket -----------------*/
-
-       async command uint8_t RadioPacket.headerLength(message_t* msg)
-       {
-               return call SubPacket.headerLength(msg) + sizeof(ieee154_header_t);
-       }
-
-       async command uint8_t RadioPacket.payloadLength(message_t* msg)
-       {
-               return call SubPacket.payloadLength(msg) - sizeof(ieee154_header_t);
-       }
-
-       async command void RadioPacket.setPayloadLength(message_t* msg, uint8_t length)
-       {
-               call SubPacket.setPayloadLength(msg, length + sizeof(ieee154_header_t));
-       }
-
-       async command uint8_t RadioPacket.maxPayloadLength()
-       {
-               return call SubPacket.maxPayloadLength() - sizeof(ieee154_header_t);
-       }
-
-       async command uint8_t RadioPacket.metadataLength(message_t* msg)
-       {
-               return call SubPacket.metadataLength(msg);
-       }
-
-       async command void RadioPacket.clear(message_t* msg)
-       {
-               call IEEE154MessageLayer.createDataFrame(msg);
-               call SubPacket.clear(msg);
-       }
-
-/*----------------- Packet -----------------*/
-
-       command void Packet.clear(message_t* msg)
-       {
-               call RadioPacket.clear(msg);
-       }
-
-       command uint8_t Packet.payloadLength(message_t* msg)
-       {
-               return call RadioPacket.payloadLength(msg);
-       }
-
-       command void Packet.setPayloadLength(message_t* msg, uint8_t len)
-       {
-               call RadioPacket.setPayloadLength(msg, len);
-       }
-
-       command uint8_t Packet.maxPayloadLength()
-       {
-               return call RadioPacket.maxPayloadLength();
-       }
-
-       command void* Packet.getPayload(message_t* msg, uint8_t len)
-       {
-               if( len > call RadioPacket.maxPayloadLength() )
-                       return NULL;
-
-               return getPayload(msg);
-       }
-
-/*----------------- Ieee154Send -----------------*/
-
-       command void * Ieee154Send.getPayload(message_t* msg, uint8_t len)
-       {
-               return call Packet.getPayload(msg, len);
-       }
-
-       command uint8_t Ieee154Send.maxPayloadLength()
-       {
-               return call Packet.maxPayloadLength();
-       }
-
-       command error_t Ieee154Send.cancel(message_t* msg)
-       {
-               return call SubSend.cancel(msg);
-       }
-
-       command error_t Ieee154Send.send(ieee154_saddr_t addr, message_t* msg, uint8_t len)
-       {
-               if( len > call Packet.maxPayloadLength() )
-                       return EINVAL;
-
-               // user forgot to call Packet.clear(), maybe we should return EFAIL
-               if( ! call IEEE154MessageLayer.isDataFrame(msg) )
-                       call IEEE154MessageLayer.createDataFrame(msg);
-
-               call Packet.setPayloadLength(msg, len);
-               call Ieee154Packet.setSource(msg, call Ieee154Packet.address());
-               call Ieee154Packet.setDestination(msg, addr);
-               call Ieee154Packet.setPan(msg, call Ieee154Packet.localPan());
-               
-               signal SendNotifier.aboutToSend(addr, msg);
-       
-               return call SubSend.send(msg);
-       }
-
-       default event void Ieee154Send.sendDone(message_t* msg, error_t error)
-       {
-       }
-
-       default event void SendNotifier.aboutToSend(am_addr_t addr, message_t* msg)
-       {
-       }
-
-/*----------------- Send -----------------*/
-
-       command error_t Send.send(message_t* msg)
-       {
-               // user forgot to call Packet.clear(), lower levels can send other types
-               if( ! call IEEE154MessageLayer.isDataFrame(msg) )
-                       call IEEE154MessageLayer.createDataFrame(msg);
-
-               return call SubSend.send(msg);
-       }
-
-       command error_t Send.cancel(message_t* msg)
-       {
-               return call SubSend.cancel(msg);
-       }
-
-       event void SubSend.sendDone(message_t* msg, error_t error)
-       {
-               // we signal  both, only one of them should be connected
-               signal Ieee154Send.sendDone(msg, error);
-               signal Send.sendDone(msg, error);
-       }
-
-       default event void Send.sendDone(message_t* msg, error_t error)
-       {
-       }
-
-/*----------------- Receive -----------------*/
-
-       event message_t* SubReceive.receive(message_t* msg)
-       {
-               if( call Ieee154Packet.isForMe(msg) )
-                       return signal Ieee154Receive.receive(msg,
-                               getPayload(msg), call Packet.payloadLength(msg));
-               else
-                       return msg;
-       }
-}
diff --git a/tos/chips/rf2xx/layers/Ieee154MessageLayerC.nc b/tos/chips/rf2xx/layers/Ieee154MessageLayerC.nc
new file mode 100644 (file)
index 0000000..d7e6311
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2007-2009, 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
+ */
+
+module Ieee154MessageLayerC
+{
+       provides 
+       {
+               interface Packet;
+               interface Ieee154Send;
+               interface Receive as Ieee154Receive;
+               interface SendNotifier;
+       }
+
+       uses
+       {
+               interface Ieee154PacketLayer;
+               interface Ieee154Packet;
+               interface RadioPacket;
+               interface BareSend as SubSend;
+               interface BareReceive as SubReceive;
+       }
+}
+
+implementation
+{
+       void* getPayload(message_t* msg)
+       {
+               return ((void*)msg) + call RadioPacket.headerLength(msg);
+       }
+
+/*----------------- Packet -----------------*/
+
+       command void Packet.clear(message_t* msg)
+       {
+               call RadioPacket.clear(msg);
+       }
+
+       command uint8_t Packet.payloadLength(message_t* msg)
+       {
+               return call RadioPacket.payloadLength(msg);
+       }
+
+       command void Packet.setPayloadLength(message_t* msg, uint8_t len)
+       {
+               call RadioPacket.setPayloadLength(msg, len);
+       }
+
+       command uint8_t Packet.maxPayloadLength()
+       {
+               return call RadioPacket.maxPayloadLength();
+       }
+
+       command void* Packet.getPayload(message_t* msg, uint8_t len)
+       {
+               if( len > call RadioPacket.maxPayloadLength() )
+                       return NULL;
+
+               return getPayload(msg);
+       }
+
+/*----------------- Ieee154Send -----------------*/
+
+       command void * Ieee154Send.getPayload(message_t* msg, uint8_t len)
+       {
+               return call Packet.getPayload(msg, len);
+       }
+
+       command uint8_t Ieee154Send.maxPayloadLength()
+       {
+               return call Packet.maxPayloadLength();
+       }
+
+       command error_t Ieee154Send.cancel(message_t* msg)
+       {
+               return call SubSend.cancel(msg);
+       }
+
+       command error_t Ieee154Send.send(ieee154_saddr_t addr, message_t* msg, uint8_t len)
+       {
+               if( len > call Packet.maxPayloadLength() )
+                       return EINVAL;
+
+               // user forgot to call Packet.clear(), maybe we should return EFAIL
+               if( ! call Ieee154PacketLayer.isDataFrame(msg) )
+                       call Ieee154PacketLayer.createDataFrame(msg);
+
+               call Packet.setPayloadLength(msg, len);
+               call Ieee154Packet.setSource(msg, call Ieee154Packet.address());
+               call Ieee154Packet.setDestination(msg, addr);
+               call Ieee154Packet.setPan(msg, call Ieee154Packet.localPan());
+               
+               signal SendNotifier.aboutToSend(addr, msg);
+       
+               return call SubSend.send(msg);
+       }
+
+       event void SubSend.sendDone(message_t* msg, error_t error)
+       {
+               signal Ieee154Send.sendDone(msg, error);
+       }
+
+       default event void Ieee154Send.sendDone(message_t* msg, error_t error)
+       {
+       }
+
+       default event void SendNotifier.aboutToSend(am_addr_t addr, message_t* msg)
+       {
+       }
+
+/*----------------- Receive -----------------*/
+
+       event message_t* SubReceive.receive(message_t* msg)
+       {
+               if( call Ieee154Packet.isForMe(msg) )
+                       return signal Ieee154Receive.receive(msg,
+                               getPayload(msg), call Packet.payloadLength(msg));
+               else
+                       return msg;
+       }
+
+       default event message_t* Ieee154Receive.receive(message_t* msg, void* payload, uint8_t len)
+       {
+               return msg;
+       }
+}
diff --git a/tos/chips/rf2xx/layers/LowpanNetworkLayer.h b/tos/chips/rf2xx/layers/LowpanNetworkLayer.h
deleted file mode 100644 (file)
index 96111bd..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 __LOWPANNETWORKLAYER_H__
-#define __LOWPANNETWORKLAYER_H__
-
-typedef nx_struct lowpan_header_t
-{
-       nxle_uint8_t network;
-} lowpan_header_t;
-
-#endif//__LOWPANNETWORKLAYER_H__
diff --git a/tos/chips/rf2xx/layers/LowpanNetworkLayerC.nc b/tos/chips/rf2xx/layers/LowpanNetworkLayerC.nc
deleted file mode 100644 (file)
index 027ce10..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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
- */
-
-#include <LowpanNetworkLayer.h>
-
-module LowpanNetworkLayerC
-{
-       provides
-       {
-               interface BareSend as Send;
-               interface BareReceive as Receive;
-               interface RadioPacket;
-
-               interface Receive as NonTinyosReceive[uint8_t network];
-       }
-
-       uses
-       {
-               interface BareSend as SubSend;
-               interface BareReceive as SubReceive;
-               interface RadioPacket as SubPacket;
-       }
-}
-
-implementation
-{
-       lowpan_header_t* getHeader(message_t* msg)
-       {
-               return ((void*)msg) + call SubPacket.headerLength(msg);
-       }
-
-       void* getPayload(message_t* msg)
-       {
-               return ((void*)msg) + call RadioPacket.headerLength(msg);
-       }
-
-#ifndef TINYOS_6LOWPAN_NETWORK_ID
-#define TINYOS_6LOWPAN_NETWORK_ID 0x3f
-#endif
-
-       command error_t Send.send(message_t* msg)
-       {
-               getHeader(msg)->network = TINYOS_6LOWPAN_NETWORK_ID;
-               return call SubSend.send(msg);
-       }
-
-       command error_t Send.cancel(message_t* msg)
-       {
-               return call SubSend.cancel(msg);
-       }
-
-       event void SubSend.sendDone(message_t* msg, error_t error)
-       {
-               signal Send.sendDone(msg, error);
-       }
-  
-       event message_t *SubReceive.receive(message_t *msg)
-       {
-               uint8_t network = getHeader(msg)->network;
-               if( network == TINYOS_6LOWPAN_NETWORK_ID )
-                       return signal Receive.receive(msg);
-               else
-                       return signal NonTinyosReceive.receive[network](msg, 
-                               getPayload(msg), call RadioPacket.payloadLength(msg));
-       }
-
-       default event message_t *NonTinyosReceive.receive[uint8_t network](message_t *msg, void *payload, uint8_t len)
-       {
-               return msg;
-       }
-
-/*----------------- RadioPacket -----------------*/
-
-       async command uint8_t RadioPacket.headerLength(message_t* msg)
-       {
-               return call SubPacket.headerLength(msg) + sizeof(lowpan_header_t);
-       }
-
-       async command uint8_t RadioPacket.payloadLength(message_t* msg)
-       {
-               return call SubPacket.payloadLength(msg) - sizeof(lowpan_header_t);
-       }
-
-       async command void RadioPacket.setPayloadLength(message_t* msg, uint8_t length)
-       {
-               call SubPacket.setPayloadLength(msg, length + sizeof(lowpan_header_t));
-       }
-
-       async command uint8_t RadioPacket.maxPayloadLength()
-       {
-               return call SubPacket.maxPayloadLength() - sizeof(lowpan_header_t);
-       }
-
-       async command uint8_t RadioPacket.metadataLength(message_t* msg)
-       {
-               return call SubPacket.metadataLength(msg);
-       }
-
-       async command void RadioPacket.clear(message_t* msg)
-       {
-               call SubPacket.clear(msg);
-       }
-}
diff --git a/tos/chips/rf2xx/layers/TinyosNetworkLayer.h b/tos/chips/rf2xx/layers/TinyosNetworkLayer.h
new file mode 100644 (file)
index 0000000..11693c7
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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 __TINYOSNETWORKLAYER_H__
+#define __TINYOSNETWORKLAYER_H__
+
+typedef nx_struct network_header_t
+{
+       nxle_uint8_t network;
+} network_header_t;
+
+#endif//__TINYOSNETWORKLAYER_H__
diff --git a/tos/chips/rf2xx/layers/TinyosNetworkLayerC.nc b/tos/chips/rf2xx/layers/TinyosNetworkLayerC.nc
new file mode 100644 (file)
index 0000000..6757cbf
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ * 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
+ */
+
+#include <TinyosNetworkLayer.h>
+
+#ifndef TINYOS_6LOWPAN_NETWORK_ID
+#define TINYOS_6LOWPAN_NETWORK_ID 0x3f
+#endif
+
+/*
+   If TFRAMES_ENABLED is defined, then only TinyOS frames will be supported
+   (with no network byte). If IEEE154FRAMES_ENABLED, then only IEEE 802.15.4 
+   frames will be supported (the network byte is part of the payload). If 
+   neither is defined, then both TinyOS frames and IEEE 802.15.4 frames will
+   be supported where TinyOS frames are the ones whose network byte is
+   TINYOS_6LOWPAN_NETWORK_ID.
+*/
+
+#if defined(TFRAMES_ENABLED) && defined(IEEE154FRAMES_ENABLED)
+#error You cannot specify both TFRAMES_ENABLED and IEEE154FRAMES_ENABLED at the same time
+#endif
+
+module TinyosNetworkLayerC
+{
+       provides
+       {
+#ifndef TFRAMES_ENABLED
+               interface BareSend as Ieee154Send;
+               interface BareReceive as Ieee154Receive;
+               interface RadioPacket as Ieee154Packet;
+#endif
+
+#ifndef IEEE154FRAMES_ENABLED
+               interface BareSend as TinyosSend;
+               interface BareReceive as TinyosReceive;
+               interface RadioPacket as TinyosPacket;
+#endif
+       }
+
+       uses
+       {
+               interface BareSend as SubSend;
+               interface BareReceive as SubReceive;
+               interface RadioPacket as SubPacket;
+       }
+}
+
+implementation
+{
+/*----------------- Ieee154MessageC -----------------*/
+
+#ifndef TFRAMES_ENABLED
+
+       command error_t Ieee154Send.send(message_t* msg)
+       {
+               return call SubSend.send(msg);
+       }
+
+       command error_t Ieee154Send.cancel(message_t* msg)
+       {
+               return call SubSend.cancel(msg);
+       }
+       
+       async command uint8_t Ieee154Packet.headerLength(message_t* msg)
+       {
+               return call SubPacket.headerLength(msg);
+       }
+
+       async command uint8_t Ieee154Packet.payloadLength(message_t* msg)
+       {
+               return call SubPacket.payloadLength(msg);
+       }
+
+       async command void Ieee154Packet.setPayloadLength(message_t* msg, uint8_t length)
+       {
+               call SubPacket.setPayloadLength(msg, length);
+       }
+
+       async command uint8_t Ieee154Packet.maxPayloadLength()
+       {
+               return call SubPacket.maxPayloadLength();
+       }
+
+       async command uint8_t Ieee154Packet.metadataLength(message_t* msg)
+       {
+               return call SubPacket.metadataLength(msg);
+       }
+
+       async command void Ieee154Packet.clear(message_t* msg)
+       {
+               call SubPacket.clear(msg);
+       }
+
+#endif
+
+/*----------------- ActiveMessageC -----------------*/
+
+#ifndef IEEE154FRAMES_ENABLED
+
+       network_header_t* getHeader(message_t* msg)
+       {
+               return ((void*)msg) + call SubPacket.headerLength(msg);
+       }
+
+       command error_t TinyosSend.send(message_t* msg)
+       {
+#ifndef TFRAMES_ENABLED
+               getHeader(msg)->network = TINYOS_6LOWPAN_NETWORK_ID;
+#endif
+               return call SubSend.send(msg);
+       }
+
+       command error_t TinyosSend.cancel(message_t* msg)
+       {
+               return call SubSend.cancel(msg);
+       }
+
+       enum
+       {
+#ifndef TFRAMES_ENABLED
+               PAYLOAD_OFFSET = sizeof(network_header_t),
+#else
+               PAYLOAD_OFFSET = 0,
+#endif
+       };
+
+       async command uint8_t TinyosPacket.headerLength(message_t* msg)
+       {
+               return call SubPacket.headerLength(msg) + PAYLOAD_OFFSET;
+       }
+
+       async command uint8_t TinyosPacket.payloadLength(message_t* msg)
+       {
+               return call SubPacket.payloadLength(msg) - PAYLOAD_OFFSET;
+       }
+
+       async command void TinyosPacket.setPayloadLength(message_t* msg, uint8_t length)
+       {
+               call SubPacket.setPayloadLength(msg, length + PAYLOAD_OFFSET);
+       }
+
+       async command uint8_t TinyosPacket.maxPayloadLength()
+       {
+               return call SubPacket.maxPayloadLength() - PAYLOAD_OFFSET;
+       }
+
+       async command uint8_t TinyosPacket.metadataLength(message_t* msg)
+       {
+               return call SubPacket.metadataLength(msg);
+       }
+
+       async command void TinyosPacket.clear(message_t* msg)
+       {
+               call SubPacket.clear(msg);
+       }
+
+#endif
+
+/*----------------- Events -----------------*/
+
+#if defined(TFRAMES_ENABLED)
+
+       event void SubSend.sendDone(message_t* msg, error_t result)
+       {
+               signal TinyosSend.sendDone(msg, result);
+       }
+
+       event message_t* SubReceive.receive(message_t* msg)
+       {
+               return signal TinyosReceive.receive(msg);
+       }
+
+#elif defined(IEEE154FRAMES_ENABLED)
+
+       event void SubSend.sendDone(message_t* msg, error_t result)
+       {
+               signal Ieee154Send.sendDone(msg, result);
+       }
+
+       event message_t* SubReceive.receive(message_t* msg)
+       {
+               return signal Ieee154Receive.receive(msg);
+       }
+
+#else
+
+       event void SubSend.sendDone(message_t* msg, error_t result)
+       {
+               if( getHeader(msg)->network == TINYOS_6LOWPAN_NETWORK_ID )
+                       signal TinyosSend.sendDone(msg, result);
+               else
+                       signal Ieee154Send.sendDone(msg, result);
+       }
+
+       event message_t* SubReceive.receive(message_t* msg)
+       {
+               if( getHeader(msg)->network == TINYOS_6LOWPAN_NETWORK_ID )
+                       return signal TinyosReceive.receive(msg);
+               else
+                       return signal Ieee154Receive.receive(msg);
+       }
+
+#endif
+}
diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessage.h b/tos/chips/rf2xx/rf230/RF230ActiveMessage.h
deleted file mode 100644 (file)
index e91bf22..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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 <IEEE154MessageLayer.h>
-#include <LowpanNetworkLayer.h>
-#include <ActiveMessageLayer.h>
-#include <MetadataFlagsLayer.h>
-#include <RF230DriverLayer.h>
-#include <TimeStampingLayer.h>
-#include <LowPowerListeningLayer.h>
-#include <PacketLinkLayer.h>
-
-typedef nx_struct rf230packet_header_t
-{
-       rf230_header_t rf230;
-       ieee154_header_t ieee154;
-#ifndef TFRAMES_ENABLED
-       lowpan_header_t lowpan;
-#endif
-       activemessage_header_t am;
-} 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
-{
-#ifdef LOW_POWER_LISTENING
-       lpl_metadata_t lpl;
-#endif
-#ifdef PACKET_LINK
-       link_metadata_t link;
-#endif
-       timestamp_metadata_t timestamp;
-       flags_metadata_t flags;
-       rf230_metadata_t rf230;
-} rf230packet_metadata_t;
-
-#endif//__RF230ACTIVEMESSAGE_H__
index e491ecae04cb3f57c024553d664d377f4fac89be..38f8d3dac66045f00a674dd2397f0b7d368c8ff0 100644 (file)
 
 #include <RadioConfig.h>
 
+#ifdef IEEE154FRAMES_ENABLED
+#error "You cannot use ActiveMessageC with IEEE154FRAMES_ENABLED defined"
+#endif
+
 configuration RF230ActiveMessageC
 {
        provides 
@@ -36,9 +40,9 @@ configuration RF230ActiveMessageC
 
                interface Packet;
                interface AMPacket;
+
                interface PacketAcknowledgements;
                interface LowPowerListening;
-
 #ifdef PACKET_LINK
                interface PacketLink;
 #endif
@@ -57,155 +61,31 @@ configuration RF230ActiveMessageC
 
 implementation
 {
-       components RF230ActiveMessageP, RadioAlarmC;
-
-#ifdef RADIO_DEBUG
-       components AssertC;
-#endif
-
-       RF230ActiveMessageP.IEEE154MessageLayer -> IEEE154MessageLayerC;
-       RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
-       RF230ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
-       RF230ActiveMessageP.ActiveMessagePacket -> ActiveMessageLayerC;
-       RF230ActiveMessageP.RF230Packet -> RF230DriverLayerC;
-
-// -------- Active Message
-
-       components ActiveMessageLayerC;
-       ActiveMessageLayerC.Config -> RF230ActiveMessageP;
-       ActiveMessageLayerC.SubSend -> LowpanNetworkLayerC;
-       ActiveMessageLayerC.SubReceive -> LowpanNetworkLayerC;
-       ActiveMessageLayerC.SubPacket ->LowpanNetworkLayerC;
-       AMSend = ActiveMessageLayerC;
-       Packet = ActiveMessageLayerC;
-       Receive = ActiveMessageLayerC.Receive;
-       Snoop = ActiveMessageLayerC.Snoop;
-       AMPacket = ActiveMessageLayerC;
-       SendNotifier = ActiveMessageLayerC;
-
-// -------- Lowpan Network
-
-#ifdef TFRAMES_ENABLED
-       components new DummyLayerC() as LowpanNetworkLayerC;
-#else
-       components LowpanNetworkLayerC;
-#endif
-       LowpanNetworkLayerC.SubSend -> IEEE154MessageLayerC;
-       LowpanNetworkLayerC.SubReceive -> LowPowerListeningLayerC;
-       LowpanNetworkLayerC.SubPacket -> IEEE154MessageLayerC;
+       components RF230RadioC;
 
-// -------- IEEE154 Message
+       SplitControl = RF230RadioC;
 
-       components IEEE154MessageLayerC;
-       IEEE154MessageLayerC.SubPacket -> LowPowerListeningLayerC;
-       IEEE154MessageLayerC.SubSend -> UniqueLayerC;
+       AMSend = RF230RadioC;
+       Receive = RF230RadioC.Receive;
+       Snoop = RF230RadioC.Snoop;
+       SendNotifier = RF230RadioC;
 
-// -------- UniqueLayer Send part (wired twice)
-
-       components UniqueLayerC;
-       UniqueLayerC.Config -> RF230ActiveMessageP;
-       UniqueLayerC.SubSend -> LowPowerListeningLayerC;
-
-// -------- Low Power Listening 
-
-#ifdef LOW_POWER_LISTENING
-       #warning "*** USING LOW POWER LISTENING LAYER"
-       components LowPowerListeningLayerC;
-       LowPowerListeningLayerC.Config -> RF230ActiveMessageP;
-       LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
-#else  
-       components LowPowerListeningDummyC as LowPowerListeningLayerC;
-#endif
-       LowPowerListeningLayerC.SubControl -> MessageBufferLayerC;
-       LowPowerListeningLayerC.SubSend -> PacketLinkLayerC;
-       LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
-       LowPowerListeningLayerC.SubPacket -> PacketLinkLayerC;
-       SplitControl = LowPowerListeningLayerC;
-       LowPowerListening = LowPowerListeningLayerC;
-
-// -------- Packet Link
+       Packet = RF230RadioC.PacketForActiveMessage;
+       AMPacket = RF230RadioC;
 
+       PacketAcknowledgements = RF230RadioC;
+       LowPowerListening = RF230RadioC;
 #ifdef PACKET_LINK
-       #warning "*** USING PACKET LINK LAYER"
-       components PacketLinkLayerC;
-       PacketLink = PacketLinkLayerC;
-       PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
-#else
-       components new DummyLayerC() as PacketLinkLayerC;
-#endif
-       PacketLinkLayerC.SubSend -> MessageBufferLayerC;
-       PacketLinkLayerC.SubPacket -> TimeStampingLayerC;
-
-// -------- MessageBuffer
-
-       components MessageBufferLayerC;
-       MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
-       MessageBufferLayerC.RadioReceive -> UniqueLayerC;
-       MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
-       RadioChannel = MessageBufferLayerC;
-
-// -------- UniqueLayer receive part (wired twice)
-
-       UniqueLayerC.SubReceive -> TrafficMonitorLayerC;
-
-// -------- Traffic Monitor
-
-#ifdef TRAFFIC_MONITOR
-       components TrafficMonitorLayerC;
-#else
-       components new DummyLayerC() as TrafficMonitorLayerC;
-#endif
-       TrafficMonitorLayerC.Config -> RF230ActiveMessageP;
-       TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend;
-       TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive;
-       TrafficMonitorLayerC -> RF230DriverLayerC.RadioState;
-
-// -------- CollisionAvoidance
-
-#ifdef SLOTTED_MAC
-       components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
-#else
-       components RandomCollisionLayerC as CollisionAvoidanceLayerC;
+       PacketLink = RF230RadioC;
 #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;
-
-// -------- TimeStamping
-
-       components TimeStampingLayerC;
-       TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC;
-       TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC;
-       PacketTimeStampRadio = TimeStampingLayerC;
-       PacketTimeStampMilli = TimeStampingLayerC;
-
-// -------- MetadataFlags
 
-       components MetadataFlagsLayerC;
-       MetadataFlagsLayerC.SubPacket -> RF230DriverLayerC;
+       RadioChannel = RF230RadioC;
 
-// -------- RF230 Driver
+       PacketLinkQuality = RF230RadioC.PacketLinkQuality;
+       PacketTransmitPower = RF230RadioC.PacketTransmitPower;
+       PacketRSSI = RF230RadioC.PacketRSSI;
 
-       components RF230DriverLayerC;
-       RF230DriverLayerC.Config -> RF230ActiveMessageP;
-       RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
-       PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower;
-       PacketLinkQuality = RF230DriverLayerC.PacketLinkQuality;
-       PacketRSSI = RF230DriverLayerC.PacketRSSI;
-       LocalTimeRadio = RF230DriverLayerC;
+       LocalTimeRadio = RF230RadioC;
+       PacketTimeStampMilli = RF230RadioC;
+       PacketTimeStampRadio = RF230RadioC;
 }
diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc b/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc
deleted file mode 100644 (file)
index 301a110..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * 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
- */
-
-#include <RF230ActiveMessage.h>
-#include <RadioConfig.h>
-#include <Tasklet.h>
-
-module RF230ActiveMessageP
-{
-       provides
-       {
-               interface RF230DriverConfig;
-               interface SoftwareAckConfig;
-               interface UniqueConfig;
-               interface CsmaConfig;
-               interface TrafficMonitorConfig;
-               interface RandomCollisionConfig;
-               interface SlottedCollisionConfig;
-               interface ActiveMessageConfig;
-               interface DummyConfig;
-
-#ifdef LOW_POWER_LISTENING
-               interface LowPowerListeningConfig;
-#endif
-       }
-
-       uses
-       {
-               interface IEEE154MessageLayer;
-               interface RadioAlarm;
-               interface RadioPacket as ActiveMessagePacket;
-               interface RadioPacket as RF230Packet;
-
-               interface PacketTimeStamp<TRadio, uint32_t>;
-       }
-}
-
-implementation
-{
-
-/*----------------- RF230DriverConfig -----------------*/
-
-       async command uint8_t RF230DriverConfig.headerLength(message_t* msg)
-       {
-               return offsetof(message_t, data) - sizeof(rf230packet_header_t);
-       }
-
-       async command uint8_t RF230DriverConfig.maxPayloadLength()
-       {
-               return sizeof(rf230packet_header_t) + TOSH_DATA_LENGTH;
-       }
-
-       async command uint8_t RF230DriverConfig.metadataLength(message_t* msg)
-       {
-               return 0;
-       }
-
-       async command uint8_t RF230DriverConfig.headerPreloadLength()
-       {
-               // we need the fcf, dsn, destpan and dest
-               return 7;
-       }
-
-       async command bool RF230DriverConfig.requiresRssiCca(message_t* msg)
-       {
-               return call IEEE154MessageLayer.isDataFrame(msg);
-       }
-
-/*----------------- SoftwareAckConfig -----------------*/
-
-       async command bool SoftwareAckConfig.requiresAckWait(message_t* msg)
-       {
-               return call IEEE154MessageLayer.requiresAckWait(msg);
-       }
-
-       async command bool SoftwareAckConfig.isAckPacket(message_t* msg)
-       {
-               return call IEEE154MessageLayer.isAckFrame(msg);
-       }
-
-       async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack)
-       {
-               return call IEEE154MessageLayer.verifyAckReply(data, ack);
-       }
-
-       async command void SoftwareAckConfig.setAckRequired(message_t* msg, bool ack)
-       {
-               call IEEE154MessageLayer.setAckRequired(msg, ack);
-       }
-
-       async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
-       {
-               return call IEEE154MessageLayer.requiresAckReply(msg);
-       }
-
-       async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
-       {
-               call IEEE154MessageLayer.createAckReply(data, ack);
-       }
-
-#ifndef SOFTWAREACK_TIMEOUT
-#define SOFTWAREACK_TIMEOUT    1000
-#endif
-
-       async command uint16_t SoftwareAckConfig.getAckTimeout()
-       {
-               return (uint16_t)(SOFTWAREACK_TIMEOUT * RADIO_ALARM_MICROSEC);
-       }
-
-       tasklet_async command void SoftwareAckConfig.reportChannelError()
-       {
-#ifdef TRAFFIC_MONITOR
-               signal TrafficMonitorConfig.channelError();
-#endif
-       }
-
-/*----------------- UniqueConfig -----------------*/
-
-       async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getDSN(msg);
-       }
-
-       async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn)
-       {
-               call IEEE154MessageLayer.setDSN(msg, dsn);
-       }
-
-       async command am_addr_t UniqueConfig.getSender(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getSrcAddr(msg);
-       }
-
-       tasklet_async command void UniqueConfig.reportChannelError()
-       {
-#ifdef TRAFFIC_MONITOR
-               signal TrafficMonitorConfig.channelError();
-#endif
-       }
-
-/*----------------- ActiveMessageConfig -----------------*/
-
-       command am_addr_t ActiveMessageConfig.destination(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getDestAddr(msg);
-       }
-
-       command void ActiveMessageConfig.setDestination(message_t* msg, am_addr_t addr)
-       {
-               call IEEE154MessageLayer.setDestAddr(msg, addr);
-       }
-
-       command am_addr_t ActiveMessageConfig.source(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getSrcAddr(msg);
-       }
-
-       command void ActiveMessageConfig.setSource(message_t* msg, am_addr_t addr)
-       {
-               call IEEE154MessageLayer.setSrcAddr(msg, addr);
-       }
-
-       command am_group_t ActiveMessageConfig.group(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getDestPan(msg);
-       }
-
-       command void ActiveMessageConfig.setGroup(message_t* msg, am_group_t grp)
-       {
-               call IEEE154MessageLayer.setDestPan(msg, grp);
-       }
-
-/*----------------- CsmaConfig -----------------*/
-
-       async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg)
-       {
-               return call IEEE154MessageLayer.isDataFrame(msg);
-       }
-
-/*----------------- TrafficMonitorConfig -----------------*/
-
-       enum
-       {
-               TRAFFIC_UPDATE_PERIOD = 100,    // in milliseconds
-               TRAFFIC_MAX_BYTES = (uint16_t)(TRAFFIC_UPDATE_PERIOD * 1000UL / 32),    // 3125
-       };
-
-       async command uint16_t TrafficMonitorConfig.getUpdatePeriod()
-       {
-               return TRAFFIC_UPDATE_PERIOD;
-       }
-
-       async command uint16_t TrafficMonitorConfig.getChannelTime(message_t* msg)
-       {
-               /* We count in bytes, one byte is 32 microsecond. We are conservative here.
-                *
-                * pure airtime: preable (4 bytes), SFD (1 byte), length (1 byte), payload + CRC (len bytes)
-                * frame separation: 5-10 bytes
-                * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation
-                */
-
-               uint8_t len = call RF230Packet.payloadLength(msg);
-               return call IEEE154MessageLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
-       }
-
-       async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getSrcAddr(msg);
-       }
-
-/*----------------- RandomCollisionConfig -----------------*/
-
-       /*
-        * We try to use the same values as in CC2420
-        *
-        * CC2420_MIN_BACKOFF = 10 jiffies = 320 microsec
-        * CC2420_BACKOFF_PERIOD = 10 jiffies
-        * initial backoff = 0x1F * CC2420_BACKOFF_PERIOD = 310 jiffies = 9920 microsec
-        * congestion backoff = 0x7 * CC2420_BACKOFF_PERIOD = 70 jiffies = 2240 microsec
-        */
-
-       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)(9920 * RADIO_ALARM_MICROSEC);
-       }
-
-       async command uint16_t RandomCollisionConfig.getCongestionBackoff(message_t* msg)
-       {
-               return (uint16_t)(2240 * RADIO_ALARM_MICROSEC);
-       }
-
-       async command uint16_t RandomCollisionConfig.getTransmitBarrier(message_t* msg)
-       {
-               uint16_t time;
-
-               // TODO: maybe we should use the embedded timestamp of the message
-               time = call RadioAlarm.getNow();
-
-               // estimated response time (download the message, etc) is 5-8 bytes
-               if( call IEEE154MessageLayer.requiresAckReply(msg) )
-                       time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RADIO_ALARM_MICROSEC);
-               else
-                       time += (uint16_t)(32 * (-5 + 5) * RADIO_ALARM_MICROSEC);
-
-               return time;
-       }
-
-       tasklet_async event void RadioAlarm.fired()
-       {
-       }
-
-/*----------------- SlottedCollisionConfig -----------------*/
-
-       async command uint16_t SlottedCollisionConfig.getInitialDelay()
-       {
-               return 300;
-       }
-
-       async command uint8_t SlottedCollisionConfig.getScheduleExponent()
-       {
-               return 1 + RADIO_ALARM_MILLI_EXP;
-       }
-
-       async command uint16_t SlottedCollisionConfig.getTransmitTime(message_t* msg)
-       {
-               // TODO: check if the timestamp is correct
-               return call PacketTimeStamp.timestamp(msg);
-       }
-
-       async command uint16_t SlottedCollisionConfig.getCollisionWindowStart(message_t* msg)
-       {
-               // the preamble (4 bytes), SFD (1 byte), plus two extra for safety
-               return (call PacketTimeStamp.timestamp(msg)) - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC);
-       }
-
-       async command uint16_t SlottedCollisionConfig.getCollisionWindowLength(message_t* msg)
-       {
-               return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
-       }
-
-/*----------------- Dummy -----------------*/
-
-       async command void DummyConfig.nothing()
-       {
-       }
-
-/*----------------- LowPowerListening -----------------*/
-
-#ifdef LOW_POWER_LISTENING
-
-       async command bool LowPowerListeningConfig.getAckRequired(message_t* msg)
-       {
-               return call IEEE154MessageLayer.getAckRequired(msg);
-       }
-
-#endif
-
-}
index 553af9b889690fc74ebfdd6ada7e69a9fa717362..089d4369c8e96ae4625c36bb68b77817e0479ea4 100644 (file)
 
 #include <RadioConfig.h>
 
+#ifdef TFRAMES_ENABLED
+#error "You cannot use Ieee154MessageC with TFRAMES_ENABLED defined"
+#endif
+
 configuration RF230Ieee154MessageC
 {
        provides 
@@ -31,12 +35,15 @@ configuration RF230Ieee154MessageC
 
                interface Ieee154Send;
                interface Receive as Ieee154Receive;
+               interface SendNotifier;
+
                interface Ieee154Packet;
                interface Packet;
+               interface Resource as RadioSendResource[uint8_t clint];
+
                interface PacketAcknowledgements;
                interface LowPowerListening;
                interface PacketLink;
-               interface SendNotifier;
 
                interface RadioChannel;
 
@@ -52,117 +59,29 @@ configuration RF230Ieee154MessageC
 
 implementation
 {
-       components RF230ActiveMessageP, RadioAlarmC;
-
-#ifdef RADIO_DEBUG
-       components AssertC;
-#endif
-
-       RF230ActiveMessageP.IEEE154MessageLayer -> IEEE154MessageLayerC;
-       RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
-       RF230ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
-       RF230ActiveMessageP.RF230Packet -> RF230DriverLayerC;
-
-// -------- IEEE154 Message
-
-       components IEEE154MessageLayerC;
-       IEEE154MessageLayerC.SubPacket -> LowPowerListeningLayerC;
-       IEEE154MessageLayerC.SubSend -> UniqueLayerC;
-       IEEE154MessageLayerC.SubReceive -> LowPowerListeningLayerC;
-       Ieee154Send = IEEE154MessageLayerC;
-       Packet = IEEE154MessageLayerC;
-       Ieee154Receive = IEEE154MessageLayerC;
-       Ieee154Packet = IEEE154MessageLayerC;
-       SendNotifier = IEEE154MessageLayerC;
-
-// -------- UniqueLayer Send part (wired twice)
-
-       components UniqueLayerC;
-       UniqueLayerC.Config -> RF230ActiveMessageP;
-       UniqueLayerC.SubSend -> LowPowerListeningLayerC;
-
-// -------- Low Power Listening 
-
-#ifdef LOW_POWER_LISTENING
-       components LowPowerListeningLayerC;
-       LowPowerListeningLayerC.Config -> RF230ActiveMessageP;
-       LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
-#else  
-       components LowPowerListeningDummyC as LowPowerListeningLayerC;
-#endif
-       LowPowerListeningLayerC.SubControl -> MessageBufferLayerC;
-       LowPowerListeningLayerC.SubSend -> PacketLinkLayerC;
-       LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
-       LowPowerListeningLayerC.SubPacket -> PacketLinkLayerC;
-       SplitControl = LowPowerListeningLayerC;
-       LowPowerListening = LowPowerListeningLayerC;
-
-// -------- Packet Link
-
-       components PacketLinkLayerC;
-       PacketLink = PacketLinkLayerC;
-       PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
-       PacketLinkLayerC.SubSend -> MessageBufferLayerC;
-       PacketLinkLayerC.SubPacket -> TimeStampingLayerC;
-
-// -------- MessageBuffer
-
-       components MessageBufferLayerC;
-       MessageBufferLayerC.RadioSend -> CollisionAvoidanceLayerC;
-       MessageBufferLayerC.RadioReceive -> UniqueLayerC;
-       MessageBufferLayerC.RadioState -> RF230DriverLayerC;
-       RadioChannel = MessageBufferLayerC;
-
-// -------- UniqueLayer receive part (wired twice)
-
-       UniqueLayerC.SubReceive -> CollisionAvoidanceLayerC;
-
-// -------- 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 RF230RadioC;
 
-       components new DummyLayerC() as CsmaLayerC;
-       CsmaLayerC.Config -> RF230ActiveMessageP;
-       CsmaLayerC -> RF230DriverLayerC.RadioSend;
-       CsmaLayerC -> RF230DriverLayerC.RadioCCA;
+       SplitControl = RF230RadioC;
 
-// -------- TimeStamping
+       Ieee154Send = RF230RadioC.Ieee154Send;
+       Ieee154Receive = RF230RadioC.Ieee154Receive;
+       SendNotifier = RF230RadioC.Ieee154Notifier;
 
-       components TimeStampingLayerC;
-       TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC;
-       TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC;
-       PacketTimeStampRadio = TimeStampingLayerC;
-       PacketTimeStampMilli = TimeStampingLayerC;
+       Packet = RF230RadioC.PacketForIeee154Message;
+       Ieee154Packet = RF230RadioC;
+       RadioSendResource = RF230RadioC;
 
-// -------- MetadataFlags
+       PacketAcknowledgements = RF230RadioC;
+       LowPowerListening = RF230RadioC;
+       PacketLink = RF230RadioC;
 
-       components MetadataFlagsLayerC;
-       MetadataFlagsLayerC.SubPacket -> RF230DriverLayerC;
+       RadioChannel = RF230RadioC;
 
-// -------- RF230 Driver
+       PacketLinkQuality = RF230RadioC.PacketLinkQuality;
+       PacketTransmitPower = RF230RadioC.PacketTransmitPower;
+       PacketRSSI = RF230RadioC.PacketRSSI;
 
-       components RF230DriverLayerC;
-       RF230DriverLayerC.Config -> RF230ActiveMessageP;
-       RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
-       PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower;
-       PacketLinkQuality = RF230DriverLayerC.PacketLinkQuality;
-       PacketRSSI = RF230DriverLayerC.PacketRSSI;
-       LocalTimeRadio = RF230DriverLayerC;
+       LocalTimeRadio = RF230RadioC;
+       PacketTimeStampMilli = RF230RadioC;
+       PacketTimeStampRadio = RF230RadioC;
 }
diff --git a/tos/chips/rf2xx/rf230/RF230Radio.h b/tos/chips/rf2xx/rf230/RF230Radio.h
new file mode 100644 (file)
index 0000000..c6461d2
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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 __RF230RADIO_H__
+#define __RF230RADIO_H__
+
+#include <TinyosNetworkLayer.h>
+#include <Ieee154PacketLayer.h>
+#include <ActiveMessageLayer.h>
+#include <MetadataFlagsLayer.h>
+#include <RF230DriverLayer.h>
+#include <TimeStampingLayer.h>
+#include <LowPowerListeningLayer.h>
+#include <PacketLinkLayer.h>
+
+typedef nx_struct rf230packet_header_t
+{
+       rf230_header_t rf230;
+       ieee154_header_t ieee154;
+#ifndef TFRAMES_ENABLED
+       network_header_t network;
+#endif
+#ifndef IEEE154FRAMES_ENABLED
+       activemessage_header_t am;
+#endif
+} 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
+{
+#ifdef LOW_POWER_LISTENING
+       lpl_metadata_t lpl;
+#endif
+#ifdef PACKET_LINK
+       link_metadata_t link;
+#endif
+       timestamp_metadata_t timestamp;
+       flags_metadata_t flags;
+       rf230_metadata_t rf230;
+} rf230packet_metadata_t;
+
+#endif//__RF230RADIO_H__
diff --git a/tos/chips/rf2xx/rf230/RF230RadioC.nc b/tos/chips/rf2xx/rf230/RF230RadioC.nc
new file mode 100644 (file)
index 0000000..adee914
--- /dev/null
@@ -0,0 +1,260 @@
+/*
+ * 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
+ */
+
+#include <RadioConfig.h>
+
+#ifndef TFRAMES_ENABLED
+#define PACKET_LINK
+#endif
+
+configuration RF230RadioC
+{
+       provides 
+       {
+               interface SplitControl;
+
+#ifndef IEEE154FRAMES_ENABLED
+               interface AMSend[am_id_t id];
+               interface Receive[am_id_t id];
+               interface Receive as Snoop[am_id_t id];
+               interface SendNotifier[am_id_t id];
+
+               interface AMPacket;
+               interface Packet as PacketForActiveMessage;
+#endif
+
+#ifndef TFRAMES_ENABLED
+               interface Ieee154Send;
+               interface Receive as Ieee154Receive;
+               interface SendNotifier as Ieee154Notifier;
+
+               interface Resource as RadioSendResource[uint8_t clint];
+
+               interface Ieee154Packet;
+               interface Packet as PacketForIeee154Message;
+#endif
+
+               interface PacketAcknowledgements;
+               interface LowPowerListening;
+
+#ifdef PACKET_LINK
+               interface PacketLink;
+#endif
+
+               interface RadioChannel;
+
+               interface PacketField<uint8_t> as PacketLinkQuality;
+               interface PacketField<uint8_t> as PacketTransmitPower;
+               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;
+       }
+}
+
+implementation
+{
+       components RF230RadioP, RadioAlarmC;
+
+#ifdef RADIO_DEBUG
+       components AssertC;
+#endif
+
+       RF230RadioP.Ieee154PacketLayer -> Ieee154PacketLayerC;
+       RF230RadioP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
+       RF230RadioP.PacketTimeStamp -> TimeStampingLayerC;
+       RF230RadioP.RF230Packet -> RF230DriverLayerC;
+
+// -------- Active Message
+
+#ifndef IEEE154FRAMES_ENABLED
+       components ActiveMessageLayerC;
+       ActiveMessageLayerC.Config -> RF230RadioP;
+       ActiveMessageLayerC.SubSend -> AutoResourceAcquireLayerC;
+       ActiveMessageLayerC.SubReceive -> TinyosNetworkLayerC.TinyosReceive;
+       ActiveMessageLayerC.SubPacket -> TinyosNetworkLayerC.TinyosPacket;
+
+       AMSend = ActiveMessageLayerC;
+       Receive = ActiveMessageLayerC.Receive;
+       Snoop = ActiveMessageLayerC.Snoop;
+       SendNotifier = ActiveMessageLayerC;
+       AMPacket = ActiveMessageLayerC;
+       PacketForActiveMessage = ActiveMessageLayerC;
+#endif
+
+// -------- Automatic RadioSend Resource
+
+#ifndef IEEE154FRAMES_ENABLED
+#ifndef TFRAMES_ENABLED
+       components new AutoResourceAcquireLayerC();
+       AutoResourceAcquireLayerC.Resource -> RadioSendResourceC.Resource[unique("RADIO_SEND_RESOURCE")];
+#else
+       components new DummyLayerC() as AutoResourceAcquireLayerC;
+#endif
+       AutoResourceAcquireLayerC.SubSend -> TinyosNetworkLayerC.TinyosSend;
+#endif
+
+// -------- RadioSend Resource
+
+#ifndef TFRAMES_ENABLED
+       components new SimpleFcfsArbiterC("RADIO_SEND_RESOURCE") as RadioSendResourceC;
+       RadioSendResource = RadioSendResourceC;
+
+// -------- Ieee154 Message
+
+       components Ieee154MessageLayerC;
+       Ieee154MessageLayerC.Ieee154PacketLayer -> Ieee154PacketLayerC;
+       Ieee154MessageLayerC.Ieee154Packet -> Ieee154PacketLayerC;
+       Ieee154MessageLayerC.SubSend -> TinyosNetworkLayerC.Ieee154Send;
+       Ieee154MessageLayerC.SubReceive -> TinyosNetworkLayerC.Ieee154Receive;
+       Ieee154MessageLayerC.RadioPacket -> TinyosNetworkLayerC.Ieee154Packet;
+
+       Ieee154Send = Ieee154MessageLayerC;
+       Ieee154Receive = Ieee154MessageLayerC;
+       Ieee154Notifier = Ieee154MessageLayerC;
+       Ieee154Packet = Ieee154PacketLayerC;
+       PacketForIeee154Message = Ieee154MessageLayerC;
+#endif
+
+// -------- Tinyos Network
+
+       components TinyosNetworkLayerC;
+
+       TinyosNetworkLayerC.SubSend -> UniqueLayerC;
+       TinyosNetworkLayerC.SubReceive -> LowPowerListeningLayerC;
+       TinyosNetworkLayerC.SubPacket -> Ieee154PacketLayerC;
+
+// -------- IEEE 802.15.4 Packet
+
+       components Ieee154PacketLayerC;
+       Ieee154PacketLayerC.SubPacket -> LowPowerListeningLayerC;
+
+// -------- UniqueLayer Send part (wired twice)
+
+       components UniqueLayerC;
+       UniqueLayerC.Config -> RF230RadioP;
+       UniqueLayerC.SubSend -> LowPowerListeningLayerC;
+
+// -------- Low Power Listening 
+
+#ifdef LOW_POWER_LISTENING
+       #warning "*** USING LOW POWER LISTENING LAYER"
+       components LowPowerListeningLayerC;
+       LowPowerListeningLayerC.Config -> RF230RadioP;
+       LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
+#else  
+       components LowPowerListeningDummyC as LowPowerListeningLayerC;
+#endif
+       LowPowerListeningLayerC.SubControl -> MessageBufferLayerC;
+       LowPowerListeningLayerC.SubSend -> PacketLinkLayerC;
+       LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
+       LowPowerListeningLayerC.SubPacket -> PacketLinkLayerC;
+       SplitControl = LowPowerListeningLayerC;
+       LowPowerListening = LowPowerListeningLayerC;
+
+// -------- Packet Link
+
+#ifdef PACKET_LINK
+       components PacketLinkLayerC;
+       PacketLink = PacketLinkLayerC;
+       PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
+#else
+       components new DummyLayerC() as PacketLinkLayerC;
+#endif
+       PacketLinkLayerC.SubSend -> MessageBufferLayerC;
+       PacketLinkLayerC.SubPacket -> TimeStampingLayerC;
+
+// -------- MessageBuffer
+
+       components MessageBufferLayerC;
+       MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
+       MessageBufferLayerC.RadioReceive -> UniqueLayerC;
+       MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
+       RadioChannel = MessageBufferLayerC;
+
+// -------- UniqueLayer receive part (wired twice)
+
+       UniqueLayerC.SubReceive -> TrafficMonitorLayerC;
+
+// -------- Traffic Monitor
+
+#ifdef TRAFFIC_MONITOR
+       components TrafficMonitorLayerC;
+#else
+       components new DummyLayerC() as TrafficMonitorLayerC;
+#endif
+       TrafficMonitorLayerC.Config -> RF230RadioP;
+       TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend;
+       TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive;
+       TrafficMonitorLayerC -> RF230DriverLayerC.RadioState;
+
+// -------- CollisionAvoidance
+
+#ifdef SLOTTED_MAC
+       components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
+#else
+       components RandomCollisionLayerC as CollisionAvoidanceLayerC;
+#endif
+       CollisionAvoidanceLayerC.Config -> RF230RadioP;
+       CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC;
+       CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC;
+
+// -------- SoftwareAcknowledgement
+
+       components SoftwareAckLayerC;
+       SoftwareAckLayerC.Config -> RF230RadioP;
+       SoftwareAckLayerC.SubSend -> CsmaLayerC;
+       SoftwareAckLayerC.SubReceive -> RF230DriverLayerC;
+       PacketAcknowledgements = SoftwareAckLayerC;
+
+// -------- Carrier Sense
+
+       components new DummyLayerC() as CsmaLayerC;
+       CsmaLayerC.Config -> RF230RadioP;
+       CsmaLayerC -> RF230DriverLayerC.RadioSend;
+       CsmaLayerC -> RF230DriverLayerC.RadioCCA;
+
+// -------- TimeStamping
+
+       components TimeStampingLayerC;
+       TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC;
+       TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC;
+       PacketTimeStampRadio = TimeStampingLayerC;
+       PacketTimeStampMilli = TimeStampingLayerC;
+
+// -------- MetadataFlags
+
+       components MetadataFlagsLayerC;
+       MetadataFlagsLayerC.SubPacket -> RF230DriverLayerC;
+
+// -------- RF230 Driver
+
+       components RF230DriverLayerC;
+       RF230DriverLayerC.Config -> RF230RadioP;
+       RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
+       PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower;
+       PacketLinkQuality = RF230DriverLayerC.PacketLinkQuality;
+       PacketRSSI = RF230DriverLayerC.PacketRSSI;
+       LocalTimeRadio = RF230DriverLayerC;
+}
diff --git a/tos/chips/rf2xx/rf230/RF230RadioP.nc b/tos/chips/rf2xx/rf230/RF230RadioP.nc
new file mode 100644 (file)
index 0000000..57ad57a
--- /dev/null
@@ -0,0 +1,322 @@
+/*
+ * 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
+ */
+
+#include <RF230Radio.h>
+#include <RadioConfig.h>
+#include <Tasklet.h>
+
+module RF230RadioP
+{
+       provides
+       {
+               interface RF230DriverConfig;
+               interface SoftwareAckConfig;
+               interface UniqueConfig;
+               interface CsmaConfig;
+               interface TrafficMonitorConfig;
+               interface RandomCollisionConfig;
+               interface SlottedCollisionConfig;
+               interface ActiveMessageConfig;
+               interface DummyConfig;
+
+#ifdef LOW_POWER_LISTENING
+               interface LowPowerListeningConfig;
+#endif
+       }
+
+       uses
+       {
+               interface Ieee154PacketLayer;
+               interface RadioAlarm;
+               interface RadioPacket as RF230Packet;
+
+               interface PacketTimeStamp<TRadio, uint32_t>;
+       }
+}
+
+implementation
+{
+
+/*----------------- RF230DriverConfig -----------------*/
+
+       async command uint8_t RF230DriverConfig.headerLength(message_t* msg)
+       {
+               return offsetof(message_t, data) - sizeof(rf230packet_header_t);
+       }
+
+       async command uint8_t RF230DriverConfig.maxPayloadLength()
+       {
+               return sizeof(rf230packet_header_t) + TOSH_DATA_LENGTH;
+       }
+
+       async command uint8_t RF230DriverConfig.metadataLength(message_t* msg)
+       {
+               return 0;
+       }
+
+       async command uint8_t RF230DriverConfig.headerPreloadLength()
+       {
+               // we need the fcf, dsn, destpan and dest
+               return 7;
+       }
+
+       async command bool RF230DriverConfig.requiresRssiCca(message_t* msg)
+       {
+               return call Ieee154PacketLayer.isDataFrame(msg);
+       }
+
+/*----------------- SoftwareAckConfig -----------------*/
+
+       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);
+       }
+
+#ifndef SOFTWAREACK_TIMEOUT
+#define SOFTWAREACK_TIMEOUT    1000
+#endif
+
+       async command uint16_t SoftwareAckConfig.getAckTimeout()
+       {
+               return (uint16_t)(SOFTWAREACK_TIMEOUT * RADIO_ALARM_MICROSEC);
+       }
+
+       tasklet_async command void SoftwareAckConfig.reportChannelError()
+       {
+#ifdef TRAFFIC_MONITOR
+               signal TrafficMonitorConfig.channelError();
+#endif
+       }
+
+/*----------------- UniqueConfig -----------------*/
+
+       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);
+       }
+
+       tasklet_async command void UniqueConfig.reportChannelError()
+       {
+#ifdef TRAFFIC_MONITOR
+               signal TrafficMonitorConfig.channelError();
+#endif
+       }
+
+/*----------------- ActiveMessageConfig -----------------*/
+
+       command am_addr_t ActiveMessageConfig.destination(message_t* msg)
+       {
+               return call Ieee154PacketLayer.getDestAddr(msg);
+       }
+
+       command void ActiveMessageConfig.setDestination(message_t* msg, am_addr_t addr)
+       {
+               call Ieee154PacketLayer.setDestAddr(msg, addr);
+       }
+
+       command am_addr_t ActiveMessageConfig.source(message_t* msg)
+       {
+               return call Ieee154PacketLayer.getSrcAddr(msg);
+       }
+
+       command void ActiveMessageConfig.setSource(message_t* msg, am_addr_t addr)
+       {
+               call Ieee154PacketLayer.setSrcAddr(msg, addr);
+       }
+
+       command am_group_t ActiveMessageConfig.group(message_t* msg)
+       {
+               return call Ieee154PacketLayer.getDestPan(msg);
+       }
+
+       command void ActiveMessageConfig.setGroup(message_t* msg, am_group_t grp)
+       {
+               call Ieee154PacketLayer.setDestPan(msg, grp);
+       }
+
+/*----------------- CsmaConfig -----------------*/
+
+       async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg)
+       {
+               return call Ieee154PacketLayer.isDataFrame(msg);
+       }
+
+/*----------------- TrafficMonitorConfig -----------------*/
+
+       enum
+       {
+               TRAFFIC_UPDATE_PERIOD = 100,    // in milliseconds
+               TRAFFIC_MAX_BYTES = (uint16_t)(TRAFFIC_UPDATE_PERIOD * 1000UL / 32),    // 3125
+       };
+
+       async command uint16_t TrafficMonitorConfig.getUpdatePeriod()
+       {
+               return TRAFFIC_UPDATE_PERIOD;
+       }
+
+       async command uint16_t TrafficMonitorConfig.getChannelTime(message_t* msg)
+       {
+               /* We count in bytes, one byte is 32 microsecond. We are conservative here.
+                *
+                * pure airtime: preable (4 bytes), SFD (1 byte), length (1 byte), payload + CRC (len bytes)
+                * frame separation: 5-10 bytes
+                * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation
+                */
+
+               uint8_t len = call RF230Packet.payloadLength(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);
+       }
+
+/*----------------- RandomCollisionConfig -----------------*/
+
+       /*
+        * We try to use the same values as in CC2420
+        *
+        * CC2420_MIN_BACKOFF = 10 jiffies = 320 microsec
+        * CC2420_BACKOFF_PERIOD = 10 jiffies
+        * initial backoff = 0x1F * CC2420_BACKOFF_PERIOD = 310 jiffies = 9920 microsec
+        * congestion backoff = 0x7 * CC2420_BACKOFF_PERIOD = 70 jiffies = 2240 microsec
+        */
+
+       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)(9920 * RADIO_ALARM_MICROSEC);
+       }
+
+       async command uint16_t RandomCollisionConfig.getCongestionBackoff(message_t* msg)
+       {
+               return (uint16_t)(2240 * RADIO_ALARM_MICROSEC);
+       }
+
+       async command uint16_t RandomCollisionConfig.getTransmitBarrier(message_t* msg)
+       {
+               uint16_t time;
+
+               // TODO: maybe we should use the embedded timestamp of the message
+               time = call RadioAlarm.getNow();
+
+               // 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
+                       time += (uint16_t)(32 * (-5 + 5) * RADIO_ALARM_MICROSEC);
+
+               return time;
+       }
+
+       tasklet_async event void RadioAlarm.fired()
+       {
+       }
+
+/*----------------- SlottedCollisionConfig -----------------*/
+
+       async command uint16_t SlottedCollisionConfig.getInitialDelay()
+       {
+               return 300;
+       }
+
+       async command uint8_t SlottedCollisionConfig.getScheduleExponent()
+       {
+               return 1 + RADIO_ALARM_MILLI_EXP;
+       }
+
+       async command uint16_t SlottedCollisionConfig.getTransmitTime(message_t* msg)
+       {
+               // TODO: check if the timestamp is correct
+               return call PacketTimeStamp.timestamp(msg);
+       }
+
+       async command uint16_t SlottedCollisionConfig.getCollisionWindowStart(message_t* msg)
+       {
+               // the preamble (4 bytes), SFD (1 byte), plus two extra for safety
+               return (call PacketTimeStamp.timestamp(msg)) - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC);
+       }
+
+       async command uint16_t SlottedCollisionConfig.getCollisionWindowLength(message_t* msg)
+       {
+               return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
+       }
+
+/*----------------- Dummy -----------------*/
+
+       async command void DummyConfig.nothing()
+       {
+       }
+
+/*----------------- LowPowerListening -----------------*/
+
+#ifdef LOW_POWER_LISTENING
+
+       async command bool LowPowerListeningConfig.getAckRequired(message_t* msg)
+       {
+               return call Ieee154PacketLayer.getAckRequired(msg);
+       }
+
+#endif
+
+}
index b9273dac1a895cab81f8a8648b80550f8babe9ff..a4c2ae7784572e2bda1a8e0016329548f99957e6 100644 (file)
@@ -48,24 +48,24 @@ configuration ActiveMessageC
 
 implementation
 {
-       components RF230ActiveMessageC as MAC;
+       components RF230ActiveMessageC as MessageC;
 
-       SplitControl    = MAC;
+       SplitControl = MessageC;
 
-       AMSend          = MAC;
-       Receive         = MAC.Receive;
-       Snoop           = MAC.Snoop;
-       SendNotifier    = MAC;
+       AMSend = MessageC;
+       Receive = MessageC.Receive;
+       Snoop = MessageC.Snoop;
+       SendNotifier = MessageC;
 
-       Packet          = MAC;
-       AMPacket        = MAC;
+       Packet = MessageC;
+       AMPacket = MessageC;
 
-       PacketAcknowledgements  = MAC;
-       LowPowerListening       = MAC;
+       PacketAcknowledgements = MessageC;
+       LowPowerListening = MessageC;
 #ifdef PACKET_LINK
-       PacketLink      = MAC;
+       PacketLink = MessageC;
 #endif
 
-       PacketTimeStampMilli    = MAC;
-       PacketTimeStampMicro    = MAC;
+       PacketTimeStampMilli = MessageC;
+       PacketTimeStampMicro = MessageC;
 }
index 9e2de9e8d594b80602dae799ac81c8311a459ce9..ce1d59bc982d48ed42581b955b7a89bcb25fac01 100644 (file)
@@ -21,7 +21,7 @@
  * Author: Miklos Maroti
  */
 
-configuration ActiveMessageC
+configuration Ieee154MessageC
 {
        provides
        {
@@ -33,6 +33,7 @@ configuration ActiveMessageC
 
                interface Packet;
                interface Ieee154Packet;
+               interface Resource as RadioSendResource[uint8_t clint];
 
                interface PacketAcknowledgements;
                interface LowPowerListening;
@@ -45,21 +46,22 @@ configuration ActiveMessageC
 
 implementation
 {
-       components RF230Ieee154MessageC as MAC;
+       components RF230Ieee154MessageC as MessageC;
 
-       SplitControl    = MAC;
+       SplitControl = MessageC;
 
-       Ieee154Send     = MAC;
-       Ieee154Receive  = MAC.Receive;
-       SendNotifier    = MAC;
+       Ieee154Send = MessageC;
+       Ieee154Receive = MessageC;
+       SendNotifier = MessageC;
 
-       Packet          = MAC;
-       Ieee154Packet   = MAC;
+       Packet = MessageC;
+       Ieee154Packet = MessageC;
+       RadioSendResource = MessageC;
 
-       PacketAcknowledgements  = MAC;
-       LowPowerListening       = MAC;
-       PacketLink      = MAC;
+       PacketAcknowledgements = MessageC;
+       LowPowerListening = MessageC;
+       PacketLink = MessageC;
 
-       PacketTimeStampMilli    = MAC;
-       PacketTimeStampMicro    = MAC;
+       PacketTimeStampMilli = MessageC;
+       PacketTimeStampMicro = MessageC;
 }
index 387d74fe34b04072aeec3f7ffeeb8d6030a072f6..3b2ffb021e2a6226ac3065550c189304d42ba4ff 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef PLATFORM_MESSAGE_H
 #define PLATFORM_MESSAGE_H
 
-#include <RF230ActiveMessage.h>
+#include <RF230Radio.h>
 #include <Serial.h>
 
 typedef union message_header {