]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
reorganized packet header handling
authormmaroti <mmaroti>
Sat, 4 Apr 2009 00:43:55 +0000 (00:43 +0000)
committermmaroti <mmaroti>
Sat, 4 Apr 2009 00:43:55 +0000 (00:43 +0000)
30 files changed:
tos/chips/rf2xx/layers/ActiveMessageConfig.nc
tos/chips/rf2xx/layers/ActiveMessageLayer.h [new file with mode: 0644]
tos/chips/rf2xx/layers/ActiveMessageLayerC.nc
tos/chips/rf2xx/layers/ActiveMessageLayerP.nc [new file with mode: 0644]
tos/chips/rf2xx/layers/IEEE154MessageConfig.nc [new file with mode: 0644]
tos/chips/rf2xx/layers/IEEE154MessageLayer.h [new file with mode: 0644]
tos/chips/rf2xx/layers/IEEE154MessageLayer.nc [new file with mode: 0644]
tos/chips/rf2xx/layers/IEEE154MessageLayerC.nc [new file with mode: 0644]
tos/chips/rf2xx/layers/IEEE154MessageLayerP.nc [new file with mode: 0644]
tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc [deleted file]
tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc [deleted file]
tos/chips/rf2xx/layers/IEEE154PacketLayer.h [deleted file]
tos/chips/rf2xx/layers/IEEE154PacketLayer.nc [deleted file]
tos/chips/rf2xx/layers/IEEE154PacketLayerC.nc [deleted file]
tos/chips/rf2xx/layers/IEEE154PacketLayerP.nc [deleted file]
tos/chips/rf2xx/layers/LowPowerListeningConfig.nc [new file with mode: 0644]
tos/chips/rf2xx/layers/LowPowerListeningLayerC.nc
tos/chips/rf2xx/layers/LowPowerListeningLayerP.nc
tos/chips/rf2xx/layers/LowpanNetworkConfig.nc [new file with mode: 0644]
tos/chips/rf2xx/layers/LowpanNetworkLayer.h [new file with mode: 0644]
tos/chips/rf2xx/layers/LowpanNetworkLayerC.nc [new file with mode: 0644]
tos/chips/rf2xx/rf212/RF212ActiveMessage.h
tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc
tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc
tos/chips/rf2xx/rf230/RF230ActiveMessage.h
tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc
tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc
tos/chips/rf2xx/util/IEEE802154.h [new file with mode: 0644]
tos/chips/rf2xx/util/Ieee154Packet.nc [new file with mode: 0644]
tos/chips/rf2xx/util/Ieee154Send.nc [new file with mode: 0644]

index e47f0e8bcc0f129514425d9349a932e969ac4824..d3dadd427c8861de48132f766418884282926dfc 100755 (executable)
@@ -21,6 +21,8 @@
  * Author: Miklos Maroti
  */
 
+#include <ActiveMessageLayer.h>
+
 interface ActiveMessageConfig
 {
        /**
@@ -29,4 +31,27 @@ interface ActiveMessageConfig
         * forgot to do so (or return EINVAL to be strict).
         */
        command error_t checkPacket(message_t* msg);
+
+       /**
+        * Returns a pointer to the ActiveMessage header field in the message
+        */
+       command activemessage_header_t* getHeader(message_t* msg);
+
+       /** Same as AMPacket.destination */
+       command am_addr_t destination(message_t* msg);
+
+       /** Same as AMPacket.setDestination */
+       command void setDestination(message_t* msg, am_addr_t addr);
+
+       /** Same as AMPacket.source */
+       command am_addr_t source(message_t* msg);
+
+       /** Same as AMPacket.setSource */
+       command void setSource(message_t* msg, am_addr_t addr);
+
+       /** Same as AMPacket.group */
+       command am_group_t group(message_t* msg);
+
+       /** Same as AMPacket.setGroup */
+       command void setGroup(message_t* msg, am_group_t grp);
 }
diff --git a/tos/chips/rf2xx/layers/ActiveMessageLayer.h b/tos/chips/rf2xx/layers/ActiveMessageLayer.h
new file mode 100644 (file)
index 0000000..1a6d5af
--- /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 __ACTIVEMESSAGELAYER_H__
+#define __ACTIVEMESSAGELAYER_H__
+
+typedef nx_struct activemessage_header_t
+{
+       nxle_uint8_t type;
+} activemessage_header_t;
+
+#endif//__ACTIVEMESSAGELAYER_H__
index f635a9c67cf225b850753a76f7ca661f53828953..055aaa729a3eace08120105d012f35a2ee5316dc 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Vanderbilt University
+ * Copyright (c) 2009, Vanderbilt University
  * All rights reserved.
  *
  * Permission to use, copy, modify, and distribute this software and its
  * Author: Miklos Maroti
  */
 
-module ActiveMessageLayerC
+#include <ActiveMessageLayer.h>
+
+configuration ActiveMessageLayerC
 {
        provides
        {
+               interface AMPacket;
                interface AMSend[am_id_t id];
                interface Receive[am_id_t id];
                interface Receive as Snoop[am_id_t id]; 
        }
+
        uses
        {
                interface Send as SubSend;
                interface Receive as SubReceive;
-               interface AMPacket;
                interface ActiveMessageConfig as Config;
        }
 }
 
 implementation
 {
-/*----------------- Send -----------------*/
-
-       command error_t AMSend.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len)
-       {
-               error_t error;
-
-               error = call Config.checkPacket(msg);
-               if( error != SUCCESS )
-                       return error;
-
-               call AMPacket.setSource(msg, call AMPacket.address());
-               call AMPacket.setGroup(msg, call AMPacket.localGroup());
-               call AMPacket.setType(msg, id);
-               call AMPacket.setDestination(msg, addr);
-
-               return call SubSend.send(msg, len);
-       }
-
-       inline event void SubSend.sendDone(message_t* msg, error_t error)
-       {
-               signal AMSend.sendDone[call AMPacket.type(msg)](msg, error);
-       }
-
-       inline command error_t AMSend.cancel[am_id_t id](message_t* msg)
-       {
-               return call SubSend.cancel(msg);
-       }
-
-       default event void AMSend.sendDone[am_id_t id](message_t* msg, error_t error)
-       {
-       }
-
-       inline command uint8_t AMSend.maxPayloadLength[am_id_t id]()
-       {
-               return call SubSend.maxPayloadLength();
-       }
-
-       inline command void* AMSend.getPayload[am_id_t id](message_t* msg, uint8_t len)
-       {
-               return call SubSend.getPayload(msg, len);
-       }
-
-/*----------------- Receive -----------------*/
-
-       event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len)
-       {
-               am_id_t type = call AMPacket.type(msg);
-
-               msg = call AMPacket.isForMe(msg) 
-                       ? signal Receive.receive[type](msg, payload, len)
-                       : signal Snoop.receive[type](msg, payload, len);
-
-               return msg;
-       }
-
-       default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len)
-       {
-               return msg;
-       }
-
-       default event message_t* Snoop.receive[am_id_t id](message_t* msg, void* payload, uint8_t len)
-       {
-               return msg;
-       }
+       components ActiveMessageLayerP, ActiveMessageAddressC;
+       ActiveMessageLayerP.ActiveMessageAddress -> ActiveMessageAddressC;
+
+       AMPacket = ActiveMessageLayerP;
+       AMSend = ActiveMessageLayerP;
+       Receive = ActiveMessageLayerP.Receive;
+       Snoop = ActiveMessageLayerP.Snoop;
+       
+       SubSend = ActiveMessageLayerP;
+       SubReceive = ActiveMessageLayerP;
+       Config = ActiveMessageLayerP;
 }
diff --git a/tos/chips/rf2xx/layers/ActiveMessageLayerP.nc b/tos/chips/rf2xx/layers/ActiveMessageLayerP.nc
new file mode 100644 (file)
index 0000000..90406a9
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * 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
+ */
+
+module ActiveMessageLayerP
+{
+       provides
+       {
+               interface AMPacket;
+               interface AMSend[am_id_t id];
+               interface Receive[am_id_t id];
+               interface Receive as Snoop[am_id_t id]; 
+       }
+
+       uses
+       {
+               interface Send as SubSend;
+               interface Receive as SubReceive;
+               interface ActiveMessageConfig as Config;
+               interface ActiveMessageAddress;
+       }
+}
+
+implementation
+{
+/*----------------- Send -----------------*/
+
+       command error_t AMSend.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len)
+       {
+               error_t error;
+
+               error = call Config.checkPacket(msg);
+               if( error != SUCCESS )
+                       return error;
+
+               call AMPacket.setSource(msg, call AMPacket.address());
+               call AMPacket.setGroup(msg, call AMPacket.localGroup());
+               call AMPacket.setType(msg, id);
+               call AMPacket.setDestination(msg, addr);
+
+               return call SubSend.send(msg, len);
+       }
+
+       inline event void SubSend.sendDone(message_t* msg, error_t error)
+       {
+               signal AMSend.sendDone[call AMPacket.type(msg)](msg, error);
+       }
+
+       inline command error_t AMSend.cancel[am_id_t id](message_t* msg)
+       {
+               return call SubSend.cancel(msg);
+       }
+
+       default event void AMSend.sendDone[am_id_t id](message_t* msg, error_t error)
+       {
+       }
+
+       inline command uint8_t AMSend.maxPayloadLength[am_id_t id]()
+       {
+               return call SubSend.maxPayloadLength();
+       }
+
+       inline command void* AMSend.getPayload[am_id_t id](message_t* msg, uint8_t len)
+       {
+               return call SubSend.getPayload(msg, len);
+       }
+
+/*----------------- Receive -----------------*/
+
+       event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len)
+       {
+               am_id_t type = call AMPacket.type(msg);
+
+               msg = call AMPacket.isForMe(msg) 
+                       ? signal Receive.receive[type](msg, payload, len)
+                       : signal Snoop.receive[type](msg, payload, len);
+
+               return msg;
+       }
+
+       default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len)
+       {
+               return msg;
+       }
+
+       default event message_t* Snoop.receive[am_id_t id](message_t* msg, void* payload, uint8_t len)
+       {
+               return msg;
+       }
+
+/*----------------- AMPacket -----------------*/
+
+       inline command am_addr_t AMPacket.address()
+       {
+               return call ActiveMessageAddress.amAddress();
+       }
+       inline command am_group_t AMPacket.localGroup()
+       {
+               return call ActiveMessageAddress.amGroup();
+       }
+
+       inline command bool AMPacket.isForMe(message_t* msg)
+       {
+               am_addr_t addr = call AMPacket.destination(msg);
+               return addr == call AMPacket.address() || addr == AM_BROADCAST_ADDR;
+       }
+
+       inline command am_addr_t AMPacket.destination(message_t* msg)
+       {
+               return call Config.destination(msg);
+       }
+       inline command void AMPacket.setDestination(message_t* msg, am_addr_t addr)
+       {
+               call Config.setDestination(msg, addr);
+       }
+
+       inline command am_addr_t AMPacket.source(message_t* msg)
+       {
+               return call Config.source(msg);
+       }
+
+       inline command void AMPacket.setSource(message_t* msg, am_addr_t addr)
+       {
+               call Config.setSource(msg, addr);
+       }
+
+       inline command am_id_t AMPacket.type(message_t* msg)
+       {
+               return (call Config.getHeader(msg))->type;
+       }
+
+       inline command void AMPacket.setType(message_t* msg, am_id_t type)
+       {
+               (call Config.getHeader(msg))->type = type;
+       }
+  
+       inline command am_group_t AMPacket.group(message_t* msg) 
+       {
+               return call Config.group(msg);
+       }
+
+       inline command void AMPacket.setGroup(message_t* msg, am_group_t grp)
+       {
+               call Config.setGroup(msg, grp);
+       }
+
+       inline async event void ActiveMessageAddress.changed()
+       {
+       }
+}
diff --git a/tos/chips/rf2xx/layers/IEEE154MessageConfig.nc b/tos/chips/rf2xx/layers/IEEE154MessageConfig.nc
new file mode 100644 (file)
index 0000000..c02bca4
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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
+ */
+
+#include <IEEE154MessageLayer.h>
+
+interface IEEE154MessageConfig
+{
+       /**
+        * Returns a pointer to the IEEE 802.15.4 header fields in the message
+        */
+       async command ieee154_header_t* getHeader(message_t* msg);
+}
diff --git a/tos/chips/rf2xx/layers/IEEE154MessageLayer.h b/tos/chips/rf2xx/layers/IEEE154MessageLayer.h
new file mode 100644 (file)
index 0000000..9748012
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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_uint8_t length;
+       nxle_uint16_t fcf;
+       nxle_uint8_t dsn;
+       nxle_uint16_t destpan;
+       nxle_uint16_t dest;
+       nxle_uint16_t src;
+} ieee154_header_t;
+
+// the actual radio driver might not use this
+typedef nx_struct ieee154_footer_t
+{ 
+       nxle_uint16_t crc;
+} ieee154_footer_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
new file mode 100644 (file)
index 0000000..f1e34fd
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * 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 raw value (unadjusted) of the length field
+        */
+       async command uint8_t getLength(message_t* msg);
+
+       /**
+        * Sets the length field
+        */
+       async command void setLength(message_t* msg, uint8_t length);
+
+       /**
+        * 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
new file mode 100644 (file)
index 0000000..2040739
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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;
+       }
+
+       uses
+       {
+               interface IEEE154MessageConfig as Config;
+       }
+}
+
+implementation
+{
+       components IEEE154MessageLayerP, ActiveMessageAddressC;
+       IEEE154MessageLayerP.ActiveMessageAddress -> ActiveMessageAddressC;
+
+       IEEE154MessageLayer = IEEE154MessageLayerP;
+       Config = IEEE154MessageLayerP;
+}
diff --git a/tos/chips/rf2xx/layers/IEEE154MessageLayerP.nc b/tos/chips/rf2xx/layers/IEEE154MessageLayerP.nc
new file mode 100644 (file)
index 0000000..a9a82bb
--- /dev/null
@@ -0,0 +1,258 @@
+/*
+ * 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 Ieee154Packet;
+       }
+
+       uses
+       {
+               interface ActiveMessageAddress;
+               interface IEEE154MessageConfig as Config;
+       }
+}
+
+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 = 5,   // includes the FCF, DSN and FCS
+               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 call Config.getHeader(msg);
+       }
+
+       async command uint8_t IEEE154MessageLayer.getLength(message_t* msg)
+       {
+               return getHeader(msg)->length;
+       }
+
+       async command void IEEE154MessageLayer.setLength(message_t* msg, uint8_t length)
+       {
+               getHeader(msg)->length = length;
+       }
+
+       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)
+       {
+               ieee154_header_t* header = getHeader(msg);
+
+               header->length = IEEE154_ACK_FRAME_LENGTH;
+               header->fcf = IEEE154_ACK_FRAME_VALUE;
+       }
+
+       async command void IEEE154MessageLayer.createAckReply(message_t* data, message_t* ack)
+       {
+               ieee154_header_t* header = getHeader(ack);
+
+               header->length = 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();
+       }
+}
diff --git a/tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc b/tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc
deleted file mode 100644 (file)
index 64cb933..0000000
+++ /dev/null
@@ -1,53 +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 IEEE154NetworkLayerC
-{
-       provides
-       {
-               interface SplitControl;
-               interface Send;
-               interface Receive;
-       }
-       uses
-       {
-               interface SplitControl as SubControl;
-               interface Send as SubSend;
-               interface Receive as SubReceive;
-       }
-}
-
-implementation
-{
-       components IEEE154NetworkLayerP, IEEE154PacketLayerC;
-
-       SplitControl = SubControl;
-
-       Send = IEEE154NetworkLayerP;
-       Receive = IEEE154NetworkLayerP;
-
-       SubSend = IEEE154NetworkLayerP;
-       SubReceive = IEEE154NetworkLayerP;
-
-       IEEE154NetworkLayerP.IEEE154PacketLayer -> IEEE154PacketLayerC;
-}
diff --git a/tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc b/tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc
deleted file mode 100644 (file)
index d5b33bf..0000000
+++ /dev/null
@@ -1,87 +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
- */
-
-module IEEE154NetworkLayerP
-{
-       provides
-       {
-               interface Send;
-               interface Receive;
-               interface Receive as NonTinyosReceive[uint8_t network];
-       }
-
-       uses
-       {
-               interface Send as SubSend;
-               interface Receive as SubReceive;
-
-               interface IEEE154PacketLayer;
-       }
-}
-
-implementation
-{
-#ifndef TINYOS_6LOWPAN_NETWORK_ID
-#define TINYOS_6LOWPAN_NETWORK_ID 0x3f
-#endif
-
-       command error_t Send.send(message_t* msg, uint8_t len)
-       {
-               call IEEE154PacketLayer.set6LowPan(msg, TINYOS_6LOWPAN_NETWORK_ID);
-               return call SubSend.send(msg, len);
-       }
-
-       command error_t Send.cancel(message_t* msg)
-       {
-               return call SubSend.cancel(msg);
-       }
-
-       command uint8_t Send.maxPayloadLength()
-       {
-               return call SubSend.maxPayloadLength();
-       }
-
-       command void* Send.getPayload(message_t* msg, uint8_t len)
-       {
-               return call SubSend.getPayload(msg, len);
-       }
-  
-       event void SubSend.sendDone(message_t* msg, error_t error)
-       {
-               signal Send.sendDone(msg, error);
-       }
-  
-       event message_t *SubReceive.receive(message_t *msg, void *payload, uint8_t len)
-       {
-               uint8_t network = call IEEE154PacketLayer.get6LowPan(msg);
-               if( network == TINYOS_6LOWPAN_NETWORK_ID )
-                       return signal Receive.receive(msg, payload, len);
-               else
-                       return signal NonTinyosReceive.receive[network](msg, payload, len);
-       }
-
-       default event message_t *NonTinyosReceive.receive[uint8_t network](message_t *msg, void *payload, uint8_t len)
-       {
-               return msg;
-       }
-}
diff --git a/tos/chips/rf2xx/layers/IEEE154PacketLayer.h b/tos/chips/rf2xx/layers/IEEE154PacketLayer.h
deleted file mode 100644 (file)
index 721d96d..0000000
+++ /dev/null
@@ -1,75 +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 __IEEE154PACKETLAYER_H__
-#define __IEEE154PACKETLAYER_H__
-
-typedef nx_struct ieee154_header_t
-{
-       nxle_uint8_t length;
-       nxle_uint16_t fcf;
-       nxle_uint8_t dsn;
-       nxle_uint16_t destpan;
-       nxle_uint16_t dest;
-       nxle_uint16_t src;
-
-// I-Frame 6LowPAN interoperability byte
-#ifndef TFRAMES_ENABLED        
-       nxle_uint8_t network;
-#endif
-
-       nxle_uint8_t type;
-} ieee154_header_t;
-
-// the actual radio driver might not use this
-typedef nx_struct ieee154_footer_t
-{ 
-       nxle_uint16_t crc;
-} ieee154_footer_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//__IEEE154PACKETLAYER_H__
diff --git a/tos/chips/rf2xx/layers/IEEE154PacketLayer.nc b/tos/chips/rf2xx/layers/IEEE154PacketLayer.nc
deleted file mode 100644 (file)
index 896b9cd..0000000
+++ /dev/null
@@ -1,197 +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 <IEEE154PacketLayer.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 IEEE154PacketLayer
-{
-       /**
-        * Returns the IEEE 802.15.4 header including the length field.
-        */
-       async command ieee154_header_t* getHeader(message_t* msg);
-
-       /**
-        * Returns the raw value (unadjusted) of the length field
-        */
-       async command uint8_t getLength(message_t* msg);
-
-       /**
-        * Sets the length field
-        */
-       async command void setLength(message_t* msg, uint8_t length);
-
-       /**
-        * 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);
-
-#ifndef TFRAMES_ENABLED
-
-       /**
-        * Returns the value of the 6LowPan network field.
-        */
-       async command uint8_t get6LowPan(message_t* msg);
-
-       /**
-        * Sets the value of the 6LowPan network field.
-        */
-       async command void set6LowPan(message_t* msg, uint8_t network);
-
-#endif
-
-       /**
-        * Returns the active message type of the message
-        */
-       async command am_id_t getType(message_t* msg);
-
-       /**
-        * Sets the active message type
-        */
-       async command void setType(message_t* msg, am_id_t type);
-
-       /**
-        * 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/IEEE154PacketLayerC.nc b/tos/chips/rf2xx/layers/IEEE154PacketLayerC.nc
deleted file mode 100644 (file)
index a0768a9..0000000
+++ /dev/null
@@ -1,40 +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 IEEE154PacketLayerC
-{
-       provides
-       {
-               interface IEEE154PacketLayer;
-               interface AMPacket;
-       }
-}
-
-implementation
-{
-       components IEEE154PacketLayerP, ActiveMessageAddressC;
-       IEEE154PacketLayerP.ActiveMessageAddress -> ActiveMessageAddressC;
-
-       IEEE154PacketLayer = IEEE154PacketLayerP;
-       AMPacket = IEEE154PacketLayerP;
-}
diff --git a/tos/chips/rf2xx/layers/IEEE154PacketLayerP.nc b/tos/chips/rf2xx/layers/IEEE154PacketLayerP.nc
deleted file mode 100644 (file)
index 5857365..0000000
+++ /dev/null
@@ -1,294 +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 <IEEE154PacketLayer.h>
-
-module IEEE154PacketLayerP
-{
-       provides 
-       {
-               interface IEEE154PacketLayer;
-               interface AMPacket;
-       }
-
-       uses interface ActiveMessageAddress;
-}
-
-implementation
-{
-/*----------------- IEEE154Packet -----------------*/
-
-       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 = 5,   // includes the FCF, DSN and FCS
-               IEEE154_ACK_FRAME_MASK = (IEEE154_TYPE_MASK << IEEE154_FCF_FRAME_TYPE), 
-               IEEE154_ACK_FRAME_VALUE = (IEEE154_TYPE_ACK << IEEE154_FCF_FRAME_TYPE),
-       };
-
-       inline ieee154_header_t* getHeader(message_t* msg)
-       {
-               return (ieee154_header_t*)(msg->data - sizeof(ieee154_header_t));
-       }
-
-       inline async command ieee154_header_t* IEEE154PacketLayer.getHeader(message_t* msg)
-       {
-               return getHeader(msg);
-       }
-
-       inline async command uint8_t IEEE154PacketLayer.getLength(message_t* msg)
-       {
-               return getHeader(msg)->length;
-       }
-
-       inline async command void IEEE154PacketLayer.setLength(message_t* msg, uint8_t length)
-       {
-               getHeader(msg)->length = length;
-       }
-
-       inline async command uint16_t IEEE154PacketLayer.getFCF(message_t* msg)
-       {
-               return getHeader(msg)->fcf;
-       }
-
-       inline async command void IEEE154PacketLayer.setFCF(message_t* msg, uint16_t fcf)
-       {
-               getHeader(msg)->fcf = fcf;
-       }
-
-       inline async command bool IEEE154PacketLayer.isDataFrame(message_t* msg)
-       {
-               return (getHeader(msg)->fcf & IEEE154_DATA_FRAME_MASK) == IEEE154_DATA_FRAME_VALUE;
-       }
-
-       inline async command void IEEE154PacketLayer.createDataFrame(message_t* msg)
-       {
-               getHeader(msg)->fcf = IEEE154_DATA_FRAME_VALUE;
-       }
-
-       inline async command bool IEEE154PacketLayer.isAckFrame(message_t* msg)
-       {
-               return (getHeader(msg)->fcf & IEEE154_ACK_FRAME_MASK) == IEEE154_ACK_FRAME_VALUE;
-       }
-
-       inline async command void IEEE154PacketLayer.createAckFrame(message_t* msg)
-       {
-               ieee154_header_t* header = getHeader(msg);
-
-               header->length = IEEE154_ACK_FRAME_LENGTH;
-               header->fcf = IEEE154_ACK_FRAME_VALUE;
-       }
-
-       inline async command void IEEE154PacketLayer.createAckReply(message_t* data, message_t* ack)
-       {
-               ieee154_header_t* header = getHeader(ack);
-
-               header->length = IEEE154_ACK_FRAME_LENGTH;
-               header->fcf = IEEE154_ACK_FRAME_VALUE;
-               header->dsn = getHeader(data)->dsn;
-       }
-
-       inline async command bool IEEE154PacketLayer.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;
-       }
-
-       inline async command bool IEEE154PacketLayer.getAckRequired(message_t* msg)
-       {
-               return getHeader(msg)->fcf & (1 << IEEE154_FCF_ACK_REQ);
-       }
-
-       inline async command void IEEE154PacketLayer.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);
-       }
-
-       inline async command bool IEEE154PacketLayer.getFramePending(message_t* msg)
-       {
-               return getHeader(msg)->fcf & (1 << IEEE154_FCF_FRAME_PENDING);
-       }
-
-       inline async command void IEEE154PacketLayer.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);
-       }
-
-       inline async command uint8_t IEEE154PacketLayer.getDSN(message_t* msg)
-       {
-               return getHeader(msg)->dsn;
-       }
-
-       inline async command void IEEE154PacketLayer.setDSN(message_t* msg, uint8_t dsn)
-       {
-               getHeader(msg)->dsn = dsn;
-       }
-
-       inline async command uint16_t IEEE154PacketLayer.getDestPan(message_t* msg)
-       {
-               return getHeader(msg)->destpan;
-       }
-
-       inline async command void IEEE154PacketLayer.setDestPan(message_t* msg, uint16_t pan)
-       {
-               getHeader(msg)->destpan = pan;
-       }
-
-       inline async command uint16_t IEEE154PacketLayer.getDestAddr(message_t* msg)
-       {
-               return getHeader(msg)->dest;
-       }
-
-       inline async command void IEEE154PacketLayer.setDestAddr(message_t* msg, uint16_t addr)
-       {
-               getHeader(msg)->dest = addr;
-       }
-
-       inline async command uint16_t IEEE154PacketLayer.getSrcAddr(message_t* msg)
-       {
-               return getHeader(msg)->src;
-       }
-
-       inline async command void IEEE154PacketLayer.setSrcAddr(message_t* msg, uint16_t addr)
-       {
-               getHeader(msg)->src = addr;
-       }
-
-#ifndef TFRAMES_ENABLED
-
-       inline async command uint8_t IEEE154PacketLayer.get6LowPan(message_t* msg)
-       {
-               return getHeader(msg)->network;
-       }
-
-       inline async command void IEEE154PacketLayer.set6LowPan(message_t* msg, uint8_t network)
-       {
-               getHeader(msg)->network = network;
-       }
-
-#endif
-
-       inline async command am_id_t IEEE154PacketLayer.getType(message_t* msg)
-       {
-               return getHeader(msg)->type;
-       }
-
-       inline async command void IEEE154PacketLayer.setType(message_t* msg, am_id_t type)
-       {
-               getHeader(msg)->type = type;
-       }
-
-       async command bool IEEE154PacketLayer.requiresAckWait(message_t* msg)
-       {
-               return call IEEE154PacketLayer.getAckRequired(msg)
-                       && call IEEE154PacketLayer.isDataFrame(msg)
-                       && call IEEE154PacketLayer.getDestAddr(msg) != 0xFFFF;
-       }
-
-       async command bool IEEE154PacketLayer.requiresAckReply(message_t* msg)
-       {
-               return call IEEE154PacketLayer.getAckRequired(msg)
-                       && call IEEE154PacketLayer.isDataFrame(msg)
-                       && call IEEE154PacketLayer.getDestAddr(msg) == call ActiveMessageAddress.amAddress();
-       }
-
-       inline async event void ActiveMessageAddress.changed()
-       {
-       }
-
-/*----------------- AMPacket -----------------*/
-
-       inline command am_addr_t AMPacket.address()
-       {
-               return call ActiveMessageAddress.amAddress();
-       }
-       inline command am_group_t AMPacket.localGroup()
-       {
-               // TODO: check if this is correct
-               return call ActiveMessageAddress.amGroup();
-       }
-
-       inline command am_addr_t AMPacket.destination(message_t* msg)
-       {
-               return call IEEE154PacketLayer.getDestAddr(msg);
-       }
-       inline command am_addr_t AMPacket.source(message_t* msg)
-       {
-               return call IEEE154PacketLayer.getSrcAddr(msg);
-       }
-
-       inline command void AMPacket.setDestination(message_t* msg, am_addr_t addr)
-       {
-               call IEEE154PacketLayer.setDestAddr(msg, addr);
-       }
-
-       inline command void AMPacket.setSource(message_t* msg, am_addr_t addr)
-       {
-               call IEEE154PacketLayer.setSrcAddr(msg, addr);
-       }
-
-       inline command bool AMPacket.isForMe(message_t* msg)
-       {
-               am_addr_t addr = call AMPacket.destination(msg);
-               return addr == call AMPacket.address() || addr == AM_BROADCAST_ADDR;
-       }
-
-       inline command am_id_t AMPacket.type(message_t* msg)
-       {
-               return call IEEE154PacketLayer.getType(msg);
-       }
-
-       inline command void AMPacket.setType(message_t* msg, am_id_t type)
-       {
-               call IEEE154PacketLayer.setType(msg, type);
-       }
-  
-       inline command am_group_t AMPacket.group(message_t* msg) 
-       {
-               return call IEEE154PacketLayer.getDestPan(msg);
-       }
-
-       inline command void AMPacket.setGroup(message_t* msg, am_group_t grp)
-       {
-               call IEEE154PacketLayer.setDestPan(msg, grp);
-       }
-}
diff --git a/tos/chips/rf2xx/layers/LowPowerListeningConfig.nc b/tos/chips/rf2xx/layers/LowPowerListeningConfig.nc
new file mode 100644 (file)
index 0000000..c0f2157
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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
+ */
+
+#include <LowPowerListeningLayer.h>
+
+interface LowPowerListeningConfig
+{
+       /**
+        * Returns a pointer to the low power listening metadata fields in 
+        * the message
+        */
+       async command lpl_metadata_t* metadata(message_t* msg);
+
+       /**
+        * Clears the low power listening metadata fields in order to disable 
+        * low power listening for the message
+        */
+       async event void clear(message_t* msg);
+
+       /**
+        * Returns TRUE if an acknowledgement is requested for this message.
+        */
+       async command bool getAckRequired(message_t* msg);
+}
index 0c6898bfbf2e5cafae0f187685fcdd133a0a666b..ddb2a38aa26aabeb18b51a227853c1d4602dd284 100644 (file)
@@ -41,8 +41,7 @@ configuration LowPowerListeningLayerC
                interface Send as SubSend;
                interface Receive as SubReceive;
 
-               interface PacketData<lpl_metadata_t> as PacketLplMetadata;
-               interface IEEE154PacketLayer;
+               interface LowPowerListeningConfig as Config;
                interface PacketAcknowledgements;
        }
 }
@@ -59,8 +58,7 @@ implementation
        SubControl = LowPowerListeningLayerP;
        SubSend = LowPowerListeningLayerP;
        SubReceive = LowPowerListeningLayerP;
-       PacketLplMetadata = LowPowerListeningLayerP;
-       IEEE154PacketLayer = LowPowerListeningLayerP;
+       Config = LowPowerListeningLayerP;
        PacketAcknowledgements = LowPowerListeningLayerP;
        
        LowPowerListeningLayerP.Timer -> TimerMilliC;
index 226192232fa5f038134c851594c1edf7889994b9..4bdd79ee301312431ddc65de466b030170d147c7 100644 (file)
@@ -41,9 +41,8 @@ module LowPowerListeningLayerP
                interface Send as SubSend;
                interface Receive as SubReceive;
 
-               interface PacketData<lpl_metadata_t> as PacketLplMetadata;
-               interface IEEE154PacketLayer;
                interface PacketAcknowledgements;
+               interface LowPowerListeningConfig as Config;
                interface Timer<TMilli>;
        }
 }
@@ -336,7 +335,7 @@ implementation
                if( error != SUCCESS
                        || call LowPowerListening.getRxSleepInterval(msg) == 0
                        || state == SEND_SUBSEND_DONE_LAST
-                       || (call IEEE154PacketLayer.getAckRequired(msg) && call PacketAcknowledgements.wasAcked(msg)) )
+                       || (call Config.getAckRequired(msg) && call PacketAcknowledgements.wasAcked(msg)) )
                {
                        call Timer.stop();
                        state = SEND_DONE;
@@ -419,12 +418,12 @@ implementation
                else if( interval > MAX_SLEEP )
                        interval = MAX_SLEEP;
 
-               (call PacketLplMetadata.get(msg))->sleepint = interval;
+               (call Config.metadata(msg))->sleepint = interval;
        }
 
        command uint16_t LowPowerListening.getRxSleepInterval(message_t *msg)
        {
-               uint16_t sleepint = (call PacketLplMetadata.get(msg))->sleepint;
+               uint16_t sleepint = (call Config.metadata(msg))->sleepint;
 
                return sleepint != 0 ? sleepint : sleepInterval;
        }
@@ -441,8 +440,8 @@ implementation
                        call LowPowerListening.getRxSleepInterval(msg));
        }
 
-       async event void PacketLplMetadata.clear(message_t* msg)
+       async event void Config.clear(message_t* msg)
        {
-               (call PacketLplMetadata.get(msg))->sleepint = 0;
+               (call Config.metadata(msg))->sleepint = 0;
        }
 }
diff --git a/tos/chips/rf2xx/layers/LowpanNetworkConfig.nc b/tos/chips/rf2xx/layers/LowpanNetworkConfig.nc
new file mode 100644 (file)
index 0000000..9159a1e
--- /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
+ */
+
+#include <LowpanNetworkLayer.h>
+
+interface LowpanNetworkConfig
+{
+       /**
+        * Returns a pointer to the 6LowPAN header field in the message
+        */
+       command lowpan_header_t* getHeader(message_t* msg);
+}
diff --git a/tos/chips/rf2xx/layers/LowpanNetworkLayer.h b/tos/chips/rf2xx/layers/LowpanNetworkLayer.h
new file mode 100644 (file)
index 0000000..96111bd
--- /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 __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
new file mode 100644 (file)
index 0000000..f52c4d8
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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
+ */
+
+module LowpanNetworkLayerC
+{
+       provides
+       {
+               interface Send;
+               interface Receive;
+
+               interface Receive as NonTinyosReceive[uint8_t network];
+       }
+
+       uses
+       {
+               interface Send as SubSend;
+               interface Receive as SubReceive;
+               interface LowpanNetworkConfig as Config;
+       }
+}
+
+implementation
+{
+#ifndef TINYOS_6LOWPAN_NETWORK_ID
+#define TINYOS_6LOWPAN_NETWORK_ID 0x3f
+#endif
+
+       command error_t Send.send(message_t* msg, uint8_t len)
+       {
+               (call Config.getHeader(msg))->network = TINYOS_6LOWPAN_NETWORK_ID;
+               return call SubSend.send(msg, len);
+       }
+
+       command error_t Send.cancel(message_t* msg)
+       {
+               return call SubSend.cancel(msg);
+       }
+
+       command uint8_t Send.maxPayloadLength()
+       {
+               return call SubSend.maxPayloadLength();
+       }
+
+       command void* Send.getPayload(message_t* msg, uint8_t len)
+       {
+               return call SubSend.getPayload(msg, len);
+       }
+  
+       event void SubSend.sendDone(message_t* msg, error_t error)
+       {
+               signal Send.sendDone(msg, error);
+       }
+  
+       event message_t *SubReceive.receive(message_t *msg, void *payload, uint8_t len)
+       {
+               uint8_t network = (call Config.getHeader(msg))->network;
+               if( network == TINYOS_6LOWPAN_NETWORK_ID )
+                       return signal Receive.receive(msg, payload, len);
+               else
+                       return signal NonTinyosReceive.receive[network](msg, payload, len);
+       }
+
+       default event message_t *NonTinyosReceive.receive[uint8_t network](message_t *msg, void *payload, uint8_t len)
+       {
+               return msg;
+       }
+}
index e13bba9844251d69be0d22eed591900f11a2ad6d..1f789e85cab12b002f924d7f137254566f21f388 100644 (file)
 #ifndef __RF212ACTIVEMESSAGE_H__
 #define __RF212ACTIVEMESSAGE_H__
 
-#include <IEEE154PacketLayer.h>
+#include <IEEE154MessageLayer.h>
+#include <LowpanNetworkLayer.h>
+#include <ActiveMessageLayer.h>
 #include <MetadataFlagsLayer.h>
 #include <RF212DriverLayer.h>
 #include <TimeStampingLayer.h>
 #include <LowPowerListeningLayer.h>
 #include <PacketLinkLayer.h>
 
-typedef ieee154_header_t rf212packet_header_t;
+typedef nx_struct rf212packet_header_t
+{
+       ieee154_header_t ieee154;
+#ifndef TFRAMES_ENABLED
+       lowpan_header_t lowpan;
+#endif
+       activemessage_header_t am;
+} rf212packet_header_t;
 
 typedef nx_struct rf212packet_footer_t
 {
index bd5fe3c01372fc4e7c7c35388a727326d7f18c90..18ffdf6a2535c389b1c2e21a13ff43a6356be47d 100644 (file)
@@ -56,39 +56,43 @@ configuration RF212ActiveMessageC
 
 implementation
 {
-       components RF212ActiveMessageP, IEEE154PacketLayerC, RadioAlarmC;
+       components RF212ActiveMessageP, RadioAlarmC;
 
 #ifdef RADIO_DEBUG
        components AssertC;
 #endif
 
-       RF212ActiveMessageP.IEEE154PacketLayer -> IEEE154PacketLayerC;
+       RF212ActiveMessageP.IEEE154MessageLayer -> IEEE154MessageLayerC;
        RF212ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
        RF212ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
-
        Packet = RF212ActiveMessageP;
 
-// -------- ActiveMessage
+// -------- Active Message
 
        components ActiveMessageLayerC;
        ActiveMessageLayerC.Config -> RF212ActiveMessageP;
-       ActiveMessageLayerC.AMPacket -> IEEE154PacketLayerC;
-       ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC;
-       ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC;
+       ActiveMessageLayerC.SubSend -> LowpanNetworkLayerC;
+       ActiveMessageLayerC.SubReceive -> LowpanNetworkLayerC;
        AMSend = ActiveMessageLayerC;
        Receive = ActiveMessageLayerC.Receive;
        Snoop = ActiveMessageLayerC.Snoop;
-       AMPacket = IEEE154PacketLayerC;
+       AMPacket = ActiveMessageLayerC;
 
-// -------- IEEE154Network
+// -------- Lowpan Network
 
 #ifdef TFRAMES_ENABLED
-       components new DummyLayerC() as IEEE154NetworkLayerC;
+       components new DummyLayerC() as LowpanNetworkLayerC;
 #else
-       components IEEE154NetworkLayerC;
+       components LowpanNetworkLayerC;
+       LowpanNetworkLayerC.Config -> RF212ActiveMessageP;
 #endif
-       IEEE154NetworkLayerC.SubSend -> UniqueLayerC;
-       IEEE154NetworkLayerC.SubReceive -> LowPowerListeningLayerC;
+       LowpanNetworkLayerC.SubSend -> UniqueLayerC;
+       LowpanNetworkLayerC.SubReceive -> LowPowerListeningLayerC;
+
+// -------- IEEE154 Packet
+
+       components IEEE154MessageLayerC;
+       IEEE154MessageLayerC.Config -> RF212ActiveMessageP;
 
 // -------- UniqueLayer Send part (wired twice)
 
@@ -100,8 +104,7 @@ implementation
 
 #ifdef LOW_POWER_LISTENING
        components LowPowerListeningLayerC;
-       LowPowerListeningLayerC.PacketLplMetadata -> RF212ActiveMessageP;
-       LowPowerListeningLayerC.IEEE154PacketLayer -> IEEE154PacketLayerC;
+       LowPowerListeningLayerC.Config -> RF212ActiveMessageP;
        LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
 #else  
        components LowPowerListeningDummyC as LowPowerListeningLayerC;
index e9f4cfcb0d6a045138979e0db12973ec1219b351..f304b53c4e4077d6dc3cf5fb14fc4ffaff413034 100644 (file)
@@ -37,6 +37,8 @@ module RF212ActiveMessageP
                interface RandomCollisionConfig;
                interface SlottedCollisionConfig;
                interface ActiveMessageConfig;
+               interface LowpanNetworkConfig;
+               interface IEEE154MessageConfig;
                interface DummyConfig;
 
                interface Packet;
@@ -46,7 +48,7 @@ module RF212ActiveMessageP
                interface PacketData<timestamp_metadata_t> as PacketTimeStampMetadata;
 
 #ifdef LOW_POWER_LISTENING
-               interface PacketData<lpl_metadata_t> as PacketLplMetadata;
+               interface LowPowerListeningConfig;
 #endif
 #ifdef PACKET_LINK
                interface PacketData<link_metadata_t> as PacketLinkMetadata;
@@ -55,7 +57,7 @@ module RF212ActiveMessageP
 
        uses
        {
-               interface IEEE154PacketLayer;
+               interface IEEE154MessageLayer;
                interface RadioAlarm;
 
                interface PacketTimeStamp<TRadio, uint32_t>;
@@ -64,21 +66,31 @@ module RF212ActiveMessageP
 
 implementation
 {
+       rf212packet_header_t* getHeader(message_t* msg)
+       {
+               return (rf212packet_header_t*)(msg->data - sizeof(rf212packet_header_t));
+       }
+
+       rf212packet_metadata_t* getMeta(message_t* msg)
+       {
+               return (rf212packet_metadata_t*)(msg->metadata);
+       }
+
 /*----------------- RF212DriverConfig -----------------*/
 
        async command uint8_t RF212DriverConfig.getLength(message_t* msg)
        {
-               return call IEEE154PacketLayer.getLength(msg);
+               return call IEEE154MessageLayer.getLength(msg);
        }
 
        async command void RF212DriverConfig.setLength(message_t* msg, uint8_t len)
        {
-               call IEEE154PacketLayer.setLength(msg, len);
+               call IEEE154MessageLayer.setLength(msg, len);
        }
 
        async command uint8_t* RF212DriverConfig.getPayload(message_t* msg)
        {
-               return ((uint8_t*)(call IEEE154PacketLayer.getHeader(msg))) + 1;
+               return ((uint8_t*)(call IEEE154MessageConfig.getHeader(msg))) + 1;
        }
 
        async command uint8_t RF212DriverConfig.getHeaderLength()
@@ -95,39 +107,39 @@ implementation
 
        async command bool RF212DriverConfig.requiresRssiCca(message_t* msg)
        {
-               return call IEEE154PacketLayer.isDataFrame(msg);
+               return call IEEE154MessageLayer.isDataFrame(msg);
        }
 
 /*----------------- SoftwareAckConfig -----------------*/
 
        async command bool SoftwareAckConfig.requiresAckWait(message_t* msg)
        {
-               return call IEEE154PacketLayer.requiresAckWait(msg);
+               return call IEEE154MessageLayer.requiresAckWait(msg);
        }
 
        async command bool SoftwareAckConfig.isAckPacket(message_t* msg)
        {
-               return call IEEE154PacketLayer.isAckFrame(msg);
+               return call IEEE154MessageLayer.isAckFrame(msg);
        }
 
        async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack)
        {
-               return call IEEE154PacketLayer.verifyAckReply(data, ack);
+               return call IEEE154MessageLayer.verifyAckReply(data, ack);
        }
 
        async command void SoftwareAckConfig.setAckRequired(message_t* msg, bool ack)
        {
-               call IEEE154PacketLayer.setAckRequired(msg, ack);
+               call IEEE154MessageLayer.setAckRequired(msg, ack);
        }
 
        async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
        {
-               return call IEEE154PacketLayer.requiresAckReply(msg);
+               return call IEEE154MessageLayer.requiresAckReply(msg);
        }
 
        async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
        {
-               call IEEE154PacketLayer.createAckReply(data, ack);
+               call IEEE154MessageLayer.createAckReply(data, ack);
        }
 
        async command uint16_t SoftwareAckConfig.getAckTimeout()
@@ -144,17 +156,17 @@ implementation
 
        async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg)
        {
-               return call IEEE154PacketLayer.getDSN(msg);
+               return call IEEE154MessageLayer.getDSN(msg);
        }
 
        async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn)
        {
-               call IEEE154PacketLayer.setDSN(msg, dsn);
+               call IEEE154MessageLayer.setDSN(msg, dsn);
        }
 
        async command am_addr_t UniqueConfig.getSender(message_t* msg)
        {
-               return call IEEE154PacketLayer.getSrcAddr(msg);
+               return call IEEE154MessageLayer.getSrcAddr(msg);
        }
 
        tasklet_async command void UniqueConfig.reportChannelError()
@@ -167,17 +179,52 @@ implementation
        command error_t ActiveMessageConfig.checkPacket(message_t* msg)
        {
                // the user forgot to call clear, we should return EINVAL
-               if( ! call IEEE154PacketLayer.isDataFrame(msg) )
+               if( ! call IEEE154MessageLayer.isDataFrame(msg) )
                        call Packet.clear(msg);
 
                return SUCCESS;
        }
 
+       command activemessage_header_t* ActiveMessageConfig.getHeader(message_t* msg)
+       {
+               return &(getHeader(msg)->am);
+       }
+
+       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 IEEE154PacketLayer.isDataFrame(msg);
+               return call IEEE154MessageLayer.isDataFrame(msg);
        }
 
 /*----------------- TrafficMonitorConfig -----------------*/
@@ -202,13 +249,13 @@ implementation
                 * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation
                 */
 
-               uint8_t len = call IEEE154PacketLayer.getLength(msg);
-               return call IEEE154PacketLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
+               uint8_t len = call IEEE154MessageLayer.getLength(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 IEEE154PacketLayer.getSrcAddr(msg);
+               return call IEEE154MessageLayer.getSrcAddr(msg);
        }
 
        tasklet_async command void TrafficMonitorConfig.timerTick()
@@ -250,7 +297,7 @@ implementation
                time = call RadioAlarm.getNow();
 
                // estimated response time (download the message, etc) is 5-8 bytes
-               if( call IEEE154PacketLayer.requiresAckReply(msg) )
+               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);
@@ -258,7 +305,9 @@ implementation
                return time;
        }
 
-       tasklet_async event void RadioAlarm.fired()     { }
+       tasklet_async event void RadioAlarm.fired()
+       {
+       }
 
 /*----------------- SlottedCollisionConfig -----------------*/
 
@@ -297,13 +346,38 @@ implementation
        {
        }
 
-/*----------------- Metadata -----------------*/
+/*----------------- LowpanNetwork -----------------*/
 
-       inline rf212packet_metadata_t* getMeta(message_t* msg)
+       command lowpan_header_t* LowpanNetworkConfig.getHeader(message_t* msg)
        {
-               return (rf212packet_metadata_t*)(msg->metadata);
+               return &(getHeader(msg)->lowpan);
+       }
+
+/*----------------- IEEE154Message -----------------*/
+
+       async command ieee154_header_t* IEEE154MessageConfig.getHeader(message_t* msg)
+       {
+               return &(getHeader(msg)->ieee154);
        }
 
+/*----------------- LowPowerListening -----------------*/
+
+#ifdef LOW_POWER_LISTENING
+
+       async command lpl_metadata_t* LowPowerListeningConfig.metadata(message_t* msg)
+       {
+               return &(getMeta(msg)->lpl);
+       }
+
+       async command bool LowPowerListeningConfig.getAckRequired(message_t* msg)
+       {
+               return call IEEE154MessageLayer.getAckRequired(msg);
+       }
+
+#endif
+
+/*----------------- Headers and Metadata -----------------*/
+
        async command flags_metadata_t* PacketFlagsMetadata.get(message_t* msg)
        {
                return &(getMeta(msg)->flags);
@@ -319,13 +393,6 @@ implementation
                return &(getMeta(msg)->timestamp);
        }
 
-#ifdef LOW_POWER_LISTENING
-       async command lpl_metadata_t* PacketLplMetadata.get(message_t* msg)
-       {
-               return &(getMeta(msg)->lpl);
-       }
-#endif
-
 #ifdef PACKET_LINK
        async command link_metadata_t* PacketLinkMetadata.get(message_t* msg)
        {
@@ -348,25 +415,25 @@ implementation
                signal PacketRF212Metadata.clear(msg);
                signal PacketTimeStampMetadata.clear(msg);
 #ifdef LOW_POWER_LISTENING
-               signal PacketLplMetadata.clear(msg);
+               signal LowPowerListeningConfig.clear(msg);
 #endif
 #ifdef PACKET_LINK
                signal PacketLinkMetadata.clear(msg);
 #endif
-               call IEEE154PacketLayer.createDataFrame(msg);
+               call IEEE154MessageLayer.createDataFrame(msg);
        }
 
-       inline command void Packet.setPayloadLength(message_t* msg, uint8_t len)
+       command void Packet.setPayloadLength(message_t* msg, uint8_t len)
        {
-               call IEEE154PacketLayer.setLength(msg, len + PACKET_LENGTH_INCREASE);
+               call IEEE154MessageLayer.setLength(msg, len + PACKET_LENGTH_INCREASE);
        }
 
-       inline command uint8_t Packet.payloadLength(message_t* msg)
+       command uint8_t Packet.payloadLength(message_t* msg)
        {
-               return call IEEE154PacketLayer.getLength(msg) - PACKET_LENGTH_INCREASE;
+               return call IEEE154MessageLayer.getLength(msg) - PACKET_LENGTH_INCREASE;
        }
 
-       inline command uint8_t Packet.maxPayloadLength()
+       command uint8_t Packet.maxPayloadLength()
        {
                return TOSH_DATA_LENGTH;
        }
index e219b7cf146f9e43b5e639bc363c893ba516f042..940da72354a01e4aa4c5806511ae092974f73452 100644 (file)
 #ifndef __RF230ACTIVEMESSAGE_H__
 #define __RF230ACTIVEMESSAGE_H__
 
-#include <IEEE154PacketLayer.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 ieee154_header_t rf230packet_header_t;
+typedef nx_struct rf230packet_header_t
+{
+       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
 {
index b11d0e2378b230f3a04256ad42170c5af5f79575..aa5cffe0b6d3302916640f538cb4b62e18bd29d1 100644 (file)
@@ -56,39 +56,43 @@ configuration RF230ActiveMessageC
 
 implementation
 {
-       components RF230ActiveMessageP, IEEE154PacketLayerC, RadioAlarmC;
+       components RF230ActiveMessageP, RadioAlarmC;
 
 #ifdef RADIO_DEBUG
        components AssertC;
 #endif
 
-       RF230ActiveMessageP.IEEE154PacketLayer -> IEEE154PacketLayerC;
+       RF230ActiveMessageP.IEEE154MessageLayer -> IEEE154MessageLayerC;
        RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
        RF230ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
-
        Packet = RF230ActiveMessageP;
 
-// -------- ActiveMessage
+// -------- Active Message
 
        components ActiveMessageLayerC;
        ActiveMessageLayerC.Config -> RF230ActiveMessageP;
-       ActiveMessageLayerC.AMPacket -> IEEE154PacketLayerC;
-       ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC;
-       ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC;
+       ActiveMessageLayerC.SubSend -> LowpanNetworkLayerC;
+       ActiveMessageLayerC.SubReceive -> LowpanNetworkLayerC;
        AMSend = ActiveMessageLayerC;
        Receive = ActiveMessageLayerC.Receive;
        Snoop = ActiveMessageLayerC.Snoop;
-       AMPacket = IEEE154PacketLayerC;
+       AMPacket = ActiveMessageLayerC;
 
-// -------- IEEE154Network
+// -------- Lowpan Network
 
 #ifdef TFRAMES_ENABLED
-       components new DummyLayerC() as IEEE154NetworkLayerC;
+       components new DummyLayerC() as LowpanNetworkLayerC;
 #else
-       components IEEE154NetworkLayerC;
+       components LowpanNetworkLayerC;
+       LowpanNetworkLayerC.Config -> RF230ActiveMessageP;
 #endif
-       IEEE154NetworkLayerC.SubSend -> UniqueLayerC;
-       IEEE154NetworkLayerC.SubReceive -> LowPowerListeningLayerC;
+       LowpanNetworkLayerC.SubSend -> UniqueLayerC;
+       LowpanNetworkLayerC.SubReceive -> LowPowerListeningLayerC;
+
+// -------- IEEE154 Packet
+
+       components IEEE154MessageLayerC;
+       IEEE154MessageLayerC.Config -> RF230ActiveMessageP;
 
 // -------- UniqueLayer Send part (wired twice)
 
@@ -100,8 +104,7 @@ implementation
 
 #ifdef LOW_POWER_LISTENING
        components LowPowerListeningLayerC;
-       LowPowerListeningLayerC.PacketLplMetadata -> RF230ActiveMessageP;
-       LowPowerListeningLayerC.IEEE154PacketLayer -> IEEE154PacketLayerC;
+       LowPowerListeningLayerC.Config -> RF230ActiveMessageP;
        LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
 #else  
        components LowPowerListeningDummyC as LowPowerListeningLayerC;
index 0842b5af1ae456795ebf0a75aa9c39d4cb87ff31..3f1100a20e8af808d4183e52a8f9e7caf9e717e4 100644 (file)
@@ -37,6 +37,8 @@ module RF230ActiveMessageP
                interface RandomCollisionConfig;
                interface SlottedCollisionConfig;
                interface ActiveMessageConfig;
+               interface LowpanNetworkConfig;
+               interface IEEE154MessageConfig;
                interface DummyConfig;
 
                interface Packet;
@@ -46,7 +48,7 @@ module RF230ActiveMessageP
                interface PacketData<timestamp_metadata_t> as PacketTimeStampMetadata;
 
 #ifdef LOW_POWER_LISTENING
-               interface PacketData<lpl_metadata_t> as PacketLplMetadata;
+               interface LowPowerListeningConfig;
 #endif
 #ifdef PACKET_LINK
                interface PacketData<link_metadata_t> as PacketLinkMetadata;
@@ -55,7 +57,7 @@ module RF230ActiveMessageP
 
        uses
        {
-               interface IEEE154PacketLayer;
+               interface IEEE154MessageLayer;
                interface RadioAlarm;
 
                interface PacketTimeStamp<TRadio, uint32_t>;
@@ -64,21 +66,31 @@ module RF230ActiveMessageP
 
 implementation
 {
+       rf230packet_header_t* getHeader(message_t* msg)
+       {
+               return (rf230packet_header_t*)(msg->data - sizeof(rf230packet_header_t));
+       }
+
+       rf230packet_metadata_t* getMeta(message_t* msg)
+       {
+               return (rf230packet_metadata_t*)(msg->metadata);
+       }
+
 /*----------------- RF230DriverConfig -----------------*/
 
        async command uint8_t RF230DriverConfig.getLength(message_t* msg)
        {
-               return call IEEE154PacketLayer.getLength(msg);
+               return call IEEE154MessageLayer.getLength(msg);
        }
 
        async command void RF230DriverConfig.setLength(message_t* msg, uint8_t len)
        {
-               call IEEE154PacketLayer.setLength(msg, len);
+               call IEEE154MessageLayer.setLength(msg, len);
        }
 
        async command uint8_t* RF230DriverConfig.getPayload(message_t* msg)
        {
-               return ((uint8_t*)(call IEEE154PacketLayer.getHeader(msg))) + 1;
+               return ((uint8_t*)(call IEEE154MessageConfig.getHeader(msg))) + 1;
        }
 
        async command uint8_t RF230DriverConfig.getHeaderLength()
@@ -95,39 +107,39 @@ implementation
 
        async command bool RF230DriverConfig.requiresRssiCca(message_t* msg)
        {
-               return call IEEE154PacketLayer.isDataFrame(msg);
+               return call IEEE154MessageLayer.isDataFrame(msg);
        }
 
 /*----------------- SoftwareAckConfig -----------------*/
 
        async command bool SoftwareAckConfig.requiresAckWait(message_t* msg)
        {
-               return call IEEE154PacketLayer.requiresAckWait(msg);
+               return call IEEE154MessageLayer.requiresAckWait(msg);
        }
 
        async command bool SoftwareAckConfig.isAckPacket(message_t* msg)
        {
-               return call IEEE154PacketLayer.isAckFrame(msg);
+               return call IEEE154MessageLayer.isAckFrame(msg);
        }
 
        async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack)
        {
-               return call IEEE154PacketLayer.verifyAckReply(data, ack);
+               return call IEEE154MessageLayer.verifyAckReply(data, ack);
        }
 
        async command void SoftwareAckConfig.setAckRequired(message_t* msg, bool ack)
        {
-               call IEEE154PacketLayer.setAckRequired(msg, ack);
+               call IEEE154MessageLayer.setAckRequired(msg, ack);
        }
 
        async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
        {
-               return call IEEE154PacketLayer.requiresAckReply(msg);
+               return call IEEE154MessageLayer.requiresAckReply(msg);
        }
 
        async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
        {
-               call IEEE154PacketLayer.createAckReply(data, ack);
+               call IEEE154MessageLayer.createAckReply(data, ack);
        }
 
        async command uint16_t SoftwareAckConfig.getAckTimeout()
@@ -144,17 +156,17 @@ implementation
 
        async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg)
        {
-               return call IEEE154PacketLayer.getDSN(msg);
+               return call IEEE154MessageLayer.getDSN(msg);
        }
 
        async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn)
        {
-               call IEEE154PacketLayer.setDSN(msg, dsn);
+               call IEEE154MessageLayer.setDSN(msg, dsn);
        }
 
        async command am_addr_t UniqueConfig.getSender(message_t* msg)
        {
-               return call IEEE154PacketLayer.getSrcAddr(msg);
+               return call IEEE154MessageLayer.getSrcAddr(msg);
        }
 
        tasklet_async command void UniqueConfig.reportChannelError()
@@ -167,17 +179,52 @@ implementation
        command error_t ActiveMessageConfig.checkPacket(message_t* msg)
        {
                // the user forgot to call clear, we should return EINVAL
-               if( ! call IEEE154PacketLayer.isDataFrame(msg) )
+               if( ! call IEEE154MessageLayer.isDataFrame(msg) )
                        call Packet.clear(msg);
 
                return SUCCESS;
        }
 
+       command activemessage_header_t* ActiveMessageConfig.getHeader(message_t* msg)
+       {
+               return &(getHeader(msg)->am);
+       }
+
+       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 IEEE154PacketLayer.isDataFrame(msg);
+               return call IEEE154MessageLayer.isDataFrame(msg);
        }
 
 /*----------------- TrafficMonitorConfig -----------------*/
@@ -202,13 +249,13 @@ implementation
                 * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation
                 */
 
-               uint8_t len = call IEEE154PacketLayer.getLength(msg);
-               return call IEEE154PacketLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
+               uint8_t len = call IEEE154MessageLayer.getLength(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 IEEE154PacketLayer.getSrcAddr(msg);
+               return call IEEE154MessageLayer.getSrcAddr(msg);
        }
 
        tasklet_async command void TrafficMonitorConfig.timerTick()
@@ -250,7 +297,7 @@ implementation
                time = call RadioAlarm.getNow();
 
                // estimated response time (download the message, etc) is 5-8 bytes
-               if( call IEEE154PacketLayer.requiresAckReply(msg) )
+               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);
@@ -258,7 +305,9 @@ implementation
                return time;
        }
 
-       tasklet_async event void RadioAlarm.fired()     { }
+       tasklet_async event void RadioAlarm.fired()
+       {
+       }
 
 /*----------------- SlottedCollisionConfig -----------------*/
 
@@ -297,13 +346,38 @@ implementation
        {
        }
 
-/*----------------- Metadata -----------------*/
+/*----------------- LowpanNetwork -----------------*/
 
-       inline rf230packet_metadata_t* getMeta(message_t* msg)
+       command lowpan_header_t* LowpanNetworkConfig.getHeader(message_t* msg)
        {
-               return (rf230packet_metadata_t*)(msg->metadata);
+               return &(getHeader(msg)->lowpan);
+       }
+
+/*----------------- IEEE154Message -----------------*/
+
+       async command ieee154_header_t* IEEE154MessageConfig.getHeader(message_t* msg)
+       {
+               return &(getHeader(msg)->ieee154);
        }
 
+/*----------------- LowPowerListening -----------------*/
+
+#ifdef LOW_POWER_LISTENING
+
+       async command lpl_metadata_t* LowPowerListeningConfig.metadata(message_t* msg)
+       {
+               return &(getMeta(msg)->lpl);
+       }
+
+       async command bool LowPowerListeningConfig.getAckRequired(message_t* msg)
+       {
+               return call IEEE154MessageLayer.getAckRequired(msg);
+       }
+
+#endif
+
+/*----------------- Headers and Metadata -----------------*/
+
        async command flags_metadata_t* PacketFlagsMetadata.get(message_t* msg)
        {
                return &(getMeta(msg)->flags);
@@ -319,13 +393,6 @@ implementation
                return &(getMeta(msg)->timestamp);
        }
 
-#ifdef LOW_POWER_LISTENING
-       async command lpl_metadata_t* PacketLplMetadata.get(message_t* msg)
-       {
-               return &(getMeta(msg)->lpl);
-       }
-#endif
-
 #ifdef PACKET_LINK
        async command link_metadata_t* PacketLinkMetadata.get(message_t* msg)
        {
@@ -348,25 +415,25 @@ implementation
                signal PacketRF230Metadata.clear(msg);
                signal PacketTimeStampMetadata.clear(msg);
 #ifdef LOW_POWER_LISTENING
-               signal PacketLplMetadata.clear(msg);
+               signal LowPowerListeningConfig.clear(msg);
 #endif
 #ifdef PACKET_LINK
                signal PacketLinkMetadata.clear(msg);
 #endif
-               call IEEE154PacketLayer.createDataFrame(msg);
+               call IEEE154MessageLayer.createDataFrame(msg);
        }
 
-       inline command void Packet.setPayloadLength(message_t* msg, uint8_t len)
+       command void Packet.setPayloadLength(message_t* msg, uint8_t len)
        {
-               call IEEE154PacketLayer.setLength(msg, len + PACKET_LENGTH_INCREASE);
+               call IEEE154MessageLayer.setLength(msg, len + PACKET_LENGTH_INCREASE);
        }
 
-       inline command uint8_t Packet.payloadLength(message_t* msg)
+       command uint8_t Packet.payloadLength(message_t* msg)
        {
-               return call IEEE154PacketLayer.getLength(msg) - PACKET_LENGTH_INCREASE;
+               return call IEEE154MessageLayer.getLength(msg) - PACKET_LENGTH_INCREASE;
        }
 
-       inline command uint8_t Packet.maxPayloadLength()
+       command uint8_t Packet.maxPayloadLength()
        {
                return TOSH_DATA_LENGTH;
        }
diff --git a/tos/chips/rf2xx/util/IEEE802154.h b/tos/chips/rf2xx/util/IEEE802154.h
new file mode 100644 (file)
index 0000000..028bdb6
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2005-2006 Arch Rock Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Arch Rock Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ *
+ * @author Jonathan Hui <jhui@archrock.com>
+ * @version $Revision$ $Date$
+ */
+
+#ifndef __IEEE802154_H__
+#define __IEEE802154_H__
+
+/*
+ * Define an address representation.
+ * Only short addresses are currently used in this stack.
+ */
+typedef uint16_t ieee154_panid_t;
+typedef uint16_t ieee154_saddr_t;
+
+enum {
+  IEEE154_BROADCAST_ADDR = 0xffff,
+};
+
+#if 0
+// some ideas of how to represent long addresses
+typedef enum {
+  IEEE154_SHORT_ADDR,
+  IEEE154_LONG_ADDR,
+} ieee154_atype_t;
+
+typedef union {
+  uint8_t  u_addr[8];
+  uint16_t u_addr16[4];
+  uint32_t u_addr32[2];
+} ieee154_laddr_t;
+
+typedef struct {
+  ieee154_atype_t type;
+  union {
+    ieee154_saddr_t s_addr;
+    ieee154_laddr_t l_addr;
+  } addr;
+#define addr    addr.l_addr.u_addr
+#define addr16  addr.l_addr.u_addr16
+#define addr32  addr.l_addr.u_addr32
+} ieee154_addr_t;
+#endif
+
+#endif
diff --git a/tos/chips/rf2xx/util/Ieee154Packet.nc b/tos/chips/rf2xx/util/Ieee154Packet.nc
new file mode 100644 (file)
index 0000000..7b9352f
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * "Copyright (c) 2008 The Regents of the University  of California.
+ * 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 UNIVERSITY OF CALIFORNIA 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 UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA 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 UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+
+#include <IEEE802154.h>
+
+interface Ieee154Packet {
+
+  command ieee154_saddr_t address();
+  command ieee154_saddr_t destination(message_t* msg);
+  command ieee154_saddr_t source(message_t* msg);
+
+  command void setDestination(message_t* msg, ieee154_saddr_t addr);
+
+  command void setSource(message_t* msg, ieee154_saddr_t addr);
+
+  command bool isForMe(message_t* msg);
+
+  command ieee154_panid_t pan(message_t* msg);
+
+  command void setPan(message_t* msg, ieee154_panid_t grp);
+
+  command ieee154_panid_t localPan();
+}
diff --git a/tos/chips/rf2xx/util/Ieee154Send.nc b/tos/chips/rf2xx/util/Ieee154Send.nc
new file mode 100644 (file)
index 0000000..3728c72
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * "Copyright (c) 2008 The Regents of the University  of California.
+ * 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 UNIVERSITY OF CALIFORNIA 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 UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA 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 UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+
+#include <TinyError.h>
+#include <message.h>
+#include <IEEE802154.h>
+
+/*
+ *
+ * The only change from the AMSend interface is that instead of
+ * sending to an AMID, we now send to a ieee154_saddr_t.
+ *
+ */
+
+interface Ieee154Send {
+
+  /** 
+   * Send a packet with a data payload of <tt>len</tt> to address
+   * <tt>addr</tt>. To determine the maximum available size, use the
+   * Packet interface of the component providing AMSend. If send
+   * returns SUCCESS, then the component will signal the sendDone
+   * event in the future; if send returns an error, it will not
+   * signal the event.  Note that a component may accept a send
+   * request which it later finds it cannot satisfy; in this case, it
+   * will signal sendDone with error code.
+   *
+   * @param addr   address to which to send the packet
+   * @param msg    the packet
+   * @param len    the length of the data in the packet payload
+   * @return       SUCCESS if the request to send succeeded and a
+   *               sendDone will be signaled later, EBUSY if the
+   *               abstraction cannot send now but will be able to
+   *               later, or FAIL if the communication layer is not
+   *               in a state that can send (e.g., off).
+   * @see          sendDone
+   */ 
+  command error_t send(ieee154_saddr_t addr, message_t* msg, uint8_t len);
+
+  /**
+   * Cancel a requested transmission. Returns SUCCESS if the 
+   * transmission was canceled properly (not sent in its
+   * entirety). Note that the component may not know
+   * if the send was successfully canceled, if the radio is
+   * handling much of the logic; in this case, a component
+   * should be conservative and return an appropriate error code.
+   * A successful call to cancel must always result in a 
+   * sendFailed event, and never a sendSucceeded event.
+   * 
+   * @param  msg     the packet whose transmission should be cancelled.
+   * @return SUCCESS if the transmission was cancelled, FAIL otherwise.
+   * @see    sendDone
+   */
+  command error_t cancel(message_t* msg);
+
+  /** 
+   * Signaled in response to an accepted send request. <tt>msg</tt> is
+   * the message buffer sent, and <tt>error</tt> indicates whether
+   * the send was successful.
+   *
+   * @param  msg   the packet which was submitted as a send request
+   * @param  error SUCCESS if it was sent successfully, FAIL if it was not,
+   *               ECANCEL if it was cancelled
+   * @see send
+   * @see cancel
+   */ 
+  event void sendDone(message_t* msg, error_t error);
+
+
+  /**
+   * Return the maximum payload length that this communication layer
+   * can provide. This command behaves identically to
+   * <tt>Packet.maxPayloadLength</tt> and is included in this
+   * interface as a convenience.
+   *
+   * @return the maximum payload length
+   */
+  command uint8_t maxPayloadLength();
+
+  /**
+   * Return a pointer to a protocol's payload region in a packet.
+   * This command behaves identically to <tt>Packet.getPayload</tt>
+   * (minus the length parameter) and is included in this interface
+   * as a convenience.
+   *
+   * @param  msg    the packet
+   * @return        the payload of the packet
+   */
+  command void* getPayload(message_t* msg, uint8_t len);
+}