* Author: Miklos Maroti
*/
+#include <ActiveMessageLayer.h>
+
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);
}
--- /dev/null
+/*
+ * 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__
/*
- * 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;
}
--- /dev/null
+/*
+ * 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()
+ {
+ }
+}
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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__
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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();
+ }
+}
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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__
+++ /dev/null
-/*
- * 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);
-}
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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);
- }
-}
--- /dev/null
+/*
+ * 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);
+}
interface Send as SubSend;
interface Receive as SubReceive;
- interface PacketData<lpl_metadata_t> as PacketLplMetadata;
- interface IEEE154PacketLayer;
+ interface LowPowerListeningConfig as Config;
interface PacketAcknowledgements;
}
}
SubControl = LowPowerListeningLayerP;
SubSend = LowPowerListeningLayerP;
SubReceive = LowPowerListeningLayerP;
- PacketLplMetadata = LowPowerListeningLayerP;
- IEEE154PacketLayer = LowPowerListeningLayerP;
+ Config = LowPowerListeningLayerP;
PacketAcknowledgements = LowPowerListeningLayerP;
LowPowerListeningLayerP.Timer -> TimerMilliC;
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>;
}
}
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;
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;
}
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;
}
}
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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__
--- /dev/null
+/*
+ * 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;
+ }
+}
#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
{
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)
#ifdef LOW_POWER_LISTENING
components LowPowerListeningLayerC;
- LowPowerListeningLayerC.PacketLplMetadata -> RF212ActiveMessageP;
- LowPowerListeningLayerC.IEEE154PacketLayer -> IEEE154PacketLayerC;
+ LowPowerListeningLayerC.Config -> RF212ActiveMessageP;
LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
#else
components LowPowerListeningDummyC as LowPowerListeningLayerC;
interface RandomCollisionConfig;
interface SlottedCollisionConfig;
interface ActiveMessageConfig;
+ interface LowpanNetworkConfig;
+ interface IEEE154MessageConfig;
interface DummyConfig;
interface Packet;
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;
uses
{
- interface IEEE154PacketLayer;
+ interface IEEE154MessageLayer;
interface RadioAlarm;
interface PacketTimeStamp<TRadio, uint32_t>;
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()
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()
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()
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 -----------------*/
* 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()
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);
return time;
}
- tasklet_async event void RadioAlarm.fired() { }
+ tasklet_async event void RadioAlarm.fired()
+ {
+ }
/*----------------- SlottedCollisionConfig -----------------*/
{
}
-/*----------------- 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);
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)
{
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;
}
#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
{
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)
#ifdef LOW_POWER_LISTENING
components LowPowerListeningLayerC;
- LowPowerListeningLayerC.PacketLplMetadata -> RF230ActiveMessageP;
- LowPowerListeningLayerC.IEEE154PacketLayer -> IEEE154PacketLayerC;
+ LowPowerListeningLayerC.Config -> RF230ActiveMessageP;
LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
#else
components LowPowerListeningDummyC as LowPowerListeningLayerC;
interface RandomCollisionConfig;
interface SlottedCollisionConfig;
interface ActiveMessageConfig;
+ interface LowpanNetworkConfig;
+ interface IEEE154MessageConfig;
interface DummyConfig;
interface Packet;
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;
uses
{
- interface IEEE154PacketLayer;
+ interface IEEE154MessageLayer;
interface RadioAlarm;
interface PacketTimeStamp<TRadio, uint32_t>;
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()
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()
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()
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 -----------------*/
* 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()
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);
return time;
}
- tasklet_async event void RadioAlarm.fired() { }
+ tasklet_async event void RadioAlarm.fired()
+ {
+ }
/*----------------- SlottedCollisionConfig -----------------*/
{
}
-/*----------------- 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);
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)
{
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;
}
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * "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();
+}
--- /dev/null
+/*
+ * "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);
+}