From 17b072b6cdd381b02de1d26645dfb9927f0d8132 Mon Sep 17 00:00:00 2001 From: mmaroti Date: Fri, 18 Sep 2009 22:04:48 +0000 Subject: [PATCH] support ActiveMessageC and Ieee154MessageC simultaneously --- tos/chips/rf2xx/layers/ActiveMessageLayerC.nc | 2 - ...LayerC.nc => AutoResourceAcquireLayerC.nc} | 70 +-- tos/chips/rf2xx/layers/IEEE154MessageLayer.h | 61 --- tos/chips/rf2xx/layers/IEEE154MessageLayer.nc | 158 ------- .../rf2xx/layers/IEEE154MessageLayerP.nc | 404 ------------------ .../rf2xx/layers/Ieee154MessageLayerC.nc | 145 +++++++ tos/chips/rf2xx/layers/LowpanNetworkLayerC.nc | 123 ------ ...panNetworkLayer.h => TinyosNetworkLayer.h} | 10 +- tos/chips/rf2xx/layers/TinyosNetworkLayerC.nc | 224 ++++++++++ tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc | 166 +------ tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc | 133 ++---- .../{RF230ActiveMessage.h => RF230Radio.h} | 14 +- tos/chips/rf2xx/rf230/RF230RadioC.nc | 260 +++++++++++ ...{RF230ActiveMessageP.nc => RF230RadioP.nc} | 49 ++- tos/platforms/iris/ActiveMessageC.nc | 26 +- tos/platforms/iris/Ieee154MessageC.nc | 28 +- tos/platforms/iris/platform_message.h | 2 +- 17 files changed, 782 insertions(+), 1093 deletions(-) rename tos/chips/rf2xx/layers/{IEEE154MessageLayerC.nc => AutoResourceAcquireLayerC.nc} (52%) delete mode 100644 tos/chips/rf2xx/layers/IEEE154MessageLayer.h delete mode 100644 tos/chips/rf2xx/layers/IEEE154MessageLayer.nc delete mode 100644 tos/chips/rf2xx/layers/IEEE154MessageLayerP.nc create mode 100644 tos/chips/rf2xx/layers/Ieee154MessageLayerC.nc delete mode 100644 tos/chips/rf2xx/layers/LowpanNetworkLayerC.nc rename tos/chips/rf2xx/layers/{LowpanNetworkLayer.h => TinyosNetworkLayer.h} (87%) create mode 100644 tos/chips/rf2xx/layers/TinyosNetworkLayerC.nc rename tos/chips/rf2xx/rf230/{RF230ActiveMessage.h => RF230Radio.h} (90%) create mode 100644 tos/chips/rf2xx/rf230/RF230RadioC.nc rename tos/chips/rf2xx/rf230/{RF230ActiveMessageP.nc => RF230RadioP.nc} (85%) diff --git a/tos/chips/rf2xx/layers/ActiveMessageLayerC.nc b/tos/chips/rf2xx/layers/ActiveMessageLayerC.nc index 5404beca..8ca6dce1 100755 --- a/tos/chips/rf2xx/layers/ActiveMessageLayerC.nc +++ b/tos/chips/rf2xx/layers/ActiveMessageLayerC.nc @@ -25,7 +25,6 @@ configuration ActiveMessageLayerC { provides { - interface RadioPacket; interface AMPacket; interface Packet; interface AMSend[am_id_t id]; @@ -48,7 +47,6 @@ implementation components ActiveMessageLayerP, ActiveMessageAddressC; ActiveMessageLayerP.ActiveMessageAddress -> ActiveMessageAddressC; - RadioPacket = ActiveMessageLayerP; AMPacket = ActiveMessageLayerP; Packet = ActiveMessageLayerP; AMSend = ActiveMessageLayerP; diff --git a/tos/chips/rf2xx/layers/IEEE154MessageLayerC.nc b/tos/chips/rf2xx/layers/AutoResourceAcquireLayerC.nc similarity index 52% rename from tos/chips/rf2xx/layers/IEEE154MessageLayerC.nc rename to tos/chips/rf2xx/layers/AutoResourceAcquireLayerC.nc index 8c93f429..7d3c846b 100644 --- a/tos/chips/rf2xx/layers/IEEE154MessageLayerC.nc +++ b/tos/chips/rf2xx/layers/AutoResourceAcquireLayerC.nc @@ -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 @@ -21,51 +21,57 @@ * Author: Miklos Maroti */ -configuration IEEE154MessageLayerC +generic module AutoResourceAcquireLayerC() { provides { - interface IEEE154MessageLayer; - interface RadioPacket; - - // for passthrough wiring - interface BareSend as Send; - - // for gateway wiring - interface Ieee154Packet; - interface Packet; - interface Ieee154Send; - interface Receive as Ieee154Receive; - interface SendNotifier; + interface BareSend; } uses { - interface RadioPacket as SubPacket; interface BareSend as SubSend; - - // for gateway wiring - interface BareReceive as SubReceive; + interface Resource; } } implementation { - components IEEE154MessageLayerP, ActiveMessageAddressC; - IEEE154MessageLayerP.ActiveMessageAddress -> ActiveMessageAddressC; + message_t *pending; + + command error_t BareSend.send(message_t* msg) + { + if( call Resource.immediateRequest() == SUCCESS ) + { + error_t result = call SubSend.send(msg); + if( result != SUCCESS ) + call Resource.release(); + + return result; + } + + pending = msg; + return call Resource.request(); + } - IEEE154MessageLayer = IEEE154MessageLayerP; - RadioPacket = IEEE154MessageLayerP; - SubPacket = IEEE154MessageLayerP; + event void Resource.granted() + { + error_t result = call SubSend.send(pending); + if( result != SUCCESS ) + { + call Resource.release(); + signal BareSend.sendDone(pending, result); + } + } - // for passthrough - Send = IEEE154MessageLayerP; - SubSend = IEEE154MessageLayerP; + event void SubSend.sendDone(message_t* msg, error_t result) + { + call Resource.release(); + signal BareSend.sendDone(msg, result); + } - Ieee154Packet = IEEE154MessageLayerP; - Packet = IEEE154MessageLayerP; - Ieee154Send = IEEE154MessageLayerP; - Ieee154Receive = IEEE154MessageLayerP; - SubReceive = IEEE154MessageLayerP; - SendNotifier = IEEE154MessageLayerP; + command error_t BareSend.cancel(message_t* msg) + { + return call SubSend.cancel(msg); + } } diff --git a/tos/chips/rf2xx/layers/IEEE154MessageLayer.h b/tos/chips/rf2xx/layers/IEEE154MessageLayer.h deleted file mode 100644 index 31ab0ea5..00000000 --- a/tos/chips/rf2xx/layers/IEEE154MessageLayer.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2007, Vanderbilt University - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT - * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Author: Miklos Maroti - */ - -#ifndef __IEEE154MESSAGELAYER_H__ -#define __IEEE154MESSAGELAYER_H__ - -typedef nx_struct ieee154_header_t -{ - nxle_uint16_t fcf; - nxle_uint8_t dsn; - nxle_uint16_t destpan; - nxle_uint16_t dest; - nxle_uint16_t src; -} ieee154_header_t; - -enum ieee154_fcf_enums { - IEEE154_FCF_FRAME_TYPE = 0, - IEEE154_FCF_SECURITY_ENABLED = 3, - IEEE154_FCF_FRAME_PENDING = 4, - IEEE154_FCF_ACK_REQ = 5, - IEEE154_FCF_INTRAPAN = 6, - IEEE154_FCF_DEST_ADDR_MODE = 10, - IEEE154_FCF_SRC_ADDR_MODE = 14, -}; - -enum ieee154_fcf_type_enums { - IEEE154_TYPE_BEACON = 0, - IEEE154_TYPE_DATA = 1, - IEEE154_TYPE_ACK = 2, - IEEE154_TYPE_MAC_CMD = 3, - IEEE154_TYPE_MASK = 7, -}; - -enum iee154_fcf_addr_mode_enums { - IEEE154_ADDR_NONE = 0, - IEEE154_ADDR_SHORT = 2, - IEEE154_ADDR_EXT = 3, - IEEE154_ADDR_MASK = 3, -}; - -#endif//__IEEE154MESSAGELAYER_H__ diff --git a/tos/chips/rf2xx/layers/IEEE154MessageLayer.nc b/tos/chips/rf2xx/layers/IEEE154MessageLayer.nc deleted file mode 100644 index be98e1b9..00000000 --- a/tos/chips/rf2xx/layers/IEEE154MessageLayer.nc +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2007, Vanderbilt University - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT - * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Author: Miklos Maroti - */ - -#include -#include - -/** - * This interface encapsulates IEEE 802.15.4 intrapan data frames with - * 16-bit destination pan, source and destination addresses. It also - * supports 6LowPan interoperability mode, and acknowledgement frames. - * Note, that this interface does not support the CRC-16 value, which - * should be verified before the data can be trusted. - */ -interface IEEE154MessageLayer -{ - /** - * Returns the frame control field. This method should not be used, - * isDataFrame and isAckFrame should be used instead. - */ - async command uint16_t getFCF(message_t* msg); - - /** - * Sets the frame control field. This method should not be used, - * createDataFrame and createAckFrame should be used instead. - */ - async command void setFCF(message_t* msg, uint16_t fcf); - - /** - * Returns TRUE if the message is a data frame supported by - * this interface (based on the value of the FCF). - */ - async command bool isDataFrame(message_t* msg); - - /** - * Sets the FCF to create a data frame supported by this interface. - * You may call setAckRequired and setFramePending commands after this. - */ - async command void createDataFrame(message_t* msg); - - /** - * Returns TRUE if the message is an acknowledgement frame supported - * by this interface (based on the value of the FCF). - */ - async command bool isAckFrame(message_t* msg); - - /** - * Sets the FCF to create an acknowledgement frame supported by - * this interface. You may call setFramePending after this. - */ - async command void createAckFrame(message_t* msg); - - /** - * Creates an acknowledgement packet for the given data packet. - * This also sets the DSN value. The data message must be a - * data frame, the ack message will be overwritten. - */ - async command void createAckReply(message_t* data, message_t* ack); - - /** - * Returns TRUE if the acknowledgement packet corresponds to the - * data packet. The data message must be a data packet. - */ - async command bool verifyAckReply(message_t* data, message_t* ack); - - /** - * Returns TRUE if the ACK required field is set in the FCF. - */ - async command bool getAckRequired(message_t* msg); - - /** - * Sets the ACK required field in the FCF, should never be set - * for acknowledgement frames. - */ - async command void setAckRequired(message_t* msg, bool ack); - - /** - * Returns TRUE if the frame pending field is set in the FCF. - */ - async command bool getFramePending(message_t* msg); - - /** - * Sets the frame pending field in the FCF. - */ - async command void setFramePending(message_t* msg, bool pending); - - /** - * Returns the data sequence number - */ - async command uint8_t getDSN(message_t* msg); - - /** - * Sets the data sequence number - */ - async command void setDSN(message_t* msg, uint8_t dsn); - - /** - * returns the destination PAN id, values <= 255 are tinyos groups, - * valid only for data frames - */ - async command uint16_t getDestPan(message_t* msg); - - /** - * Sets the destination PAN id, valid only for data frames - */ - async command void setDestPan(message_t* msg, uint16_t pan); - - /** - * Returns the destination address, valid only for data frames - */ - async command uint16_t getDestAddr(message_t* msg); - - /** - * Sets the destination address, valid only for data frames - */ - async command void setDestAddr(message_t* msg, uint16_t addr); - - /** - * Returns the source address, valid only for data frames - */ - async command uint16_t getSrcAddr(message_t* msg); - - /** - * Sets the source address, valid only for data frames - */ - async command void setSrcAddr(message_t* msg, uint16_t addr); - - /** - * Returns TRUE if the packet is a data packet, the ACK_REQ field - * is set and the destination address is not the broadcast address. - */ - async command bool requiresAckWait(message_t* msg); - - /** - * Returns TRUE if the packet is a data packet, the ACK_REQ field - * is set and the destionation address is this node. - */ - async command bool requiresAckReply(message_t* msg); -} diff --git a/tos/chips/rf2xx/layers/IEEE154MessageLayerP.nc b/tos/chips/rf2xx/layers/IEEE154MessageLayerP.nc deleted file mode 100644 index 9b59ff98..00000000 --- a/tos/chips/rf2xx/layers/IEEE154MessageLayerP.nc +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright (c) 2007, Vanderbilt University - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT - * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Author: Miklos Maroti - */ - -#include - -module IEEE154MessageLayerP -{ - provides - { - interface IEEE154MessageLayer; - interface RadioPacket; - interface Ieee154Packet; - interface Packet; - interface Ieee154Send; - interface BareSend as Send; - interface Receive as Ieee154Receive; - interface SendNotifier; - } - - uses - { - interface ActiveMessageAddress; - interface RadioPacket as SubPacket; - interface BareSend as SubSend; - interface BareReceive as SubReceive; - } -} - -implementation -{ -/*----------------- IEEE154Message -----------------*/ - - enum - { - IEEE154_DATA_FRAME_MASK = (IEEE154_TYPE_MASK << IEEE154_FCF_FRAME_TYPE) - | (1 << IEEE154_FCF_INTRAPAN) - | (IEEE154_ADDR_MASK << IEEE154_FCF_DEST_ADDR_MODE) - | (IEEE154_ADDR_MASK << IEEE154_FCF_SRC_ADDR_MODE), - - IEEE154_DATA_FRAME_VALUE = (IEEE154_TYPE_DATA << IEEE154_FCF_FRAME_TYPE) - | (1 << IEEE154_FCF_INTRAPAN) - | (IEEE154_ADDR_SHORT << IEEE154_FCF_DEST_ADDR_MODE) - | (IEEE154_ADDR_SHORT << IEEE154_FCF_SRC_ADDR_MODE), - - IEEE154_ACK_FRAME_LENGTH = 3, // includes the FCF, DSN - IEEE154_ACK_FRAME_MASK = (IEEE154_TYPE_MASK << IEEE154_FCF_FRAME_TYPE), - IEEE154_ACK_FRAME_VALUE = (IEEE154_TYPE_ACK << IEEE154_FCF_FRAME_TYPE), - }; - - ieee154_header_t* getHeader(message_t* msg) - { - return ((void*)msg) + call SubPacket.headerLength(msg); - } - - void* getPayload(message_t* msg) - { - return ((void*)msg) + call RadioPacket.headerLength(msg); - } - - async command uint16_t IEEE154MessageLayer.getFCF(message_t* msg) - { - return getHeader(msg)->fcf; - } - - async command void IEEE154MessageLayer.setFCF(message_t* msg, uint16_t fcf) - { - getHeader(msg)->fcf = fcf; - } - - async command bool IEEE154MessageLayer.isDataFrame(message_t* msg) - { - return (getHeader(msg)->fcf & IEEE154_DATA_FRAME_MASK) == IEEE154_DATA_FRAME_VALUE; - } - - async command void IEEE154MessageLayer.createDataFrame(message_t* msg) - { - getHeader(msg)->fcf = IEEE154_DATA_FRAME_VALUE; - } - - async command bool IEEE154MessageLayer.isAckFrame(message_t* msg) - { - return (getHeader(msg)->fcf & IEEE154_ACK_FRAME_MASK) == IEEE154_ACK_FRAME_VALUE; - } - - async command void IEEE154MessageLayer.createAckFrame(message_t* msg) - { - call SubPacket.setPayloadLength(msg, IEEE154_ACK_FRAME_LENGTH); - getHeader(msg)->fcf = IEEE154_ACK_FRAME_VALUE; - } - - async command void IEEE154MessageLayer.createAckReply(message_t* data, message_t* ack) - { - ieee154_header_t* header = getHeader(ack); - call SubPacket.setPayloadLength(ack, IEEE154_ACK_FRAME_LENGTH); - - header->fcf = IEEE154_ACK_FRAME_VALUE; - header->dsn = getHeader(data)->dsn; - } - - async command bool IEEE154MessageLayer.verifyAckReply(message_t* data, message_t* ack) - { - ieee154_header_t* header = getHeader(ack); - - return header->dsn == getHeader(data)->dsn - && (header->fcf & IEEE154_ACK_FRAME_MASK) == IEEE154_ACK_FRAME_VALUE; - } - - async command bool IEEE154MessageLayer.getAckRequired(message_t* msg) - { - return getHeader(msg)->fcf & (1 << IEEE154_FCF_ACK_REQ); - } - - async command void IEEE154MessageLayer.setAckRequired(message_t* msg, bool ack) - { - if( ack ) - getHeader(msg)->fcf |= (1 << IEEE154_FCF_ACK_REQ); - else - getHeader(msg)->fcf &= ~(uint16_t)(1 << IEEE154_FCF_ACK_REQ); - } - - async command bool IEEE154MessageLayer.getFramePending(message_t* msg) - { - return getHeader(msg)->fcf & (1 << IEEE154_FCF_FRAME_PENDING); - } - - async command void IEEE154MessageLayer.setFramePending(message_t* msg, bool pending) - { - if( pending ) - getHeader(msg)->fcf |= (1 << IEEE154_FCF_FRAME_PENDING); - else - getHeader(msg)->fcf &= ~(uint16_t)(1 << IEEE154_FCF_FRAME_PENDING); - } - - async command uint8_t IEEE154MessageLayer.getDSN(message_t* msg) - { - return getHeader(msg)->dsn; - } - - async command void IEEE154MessageLayer.setDSN(message_t* msg, uint8_t dsn) - { - getHeader(msg)->dsn = dsn; - } - - async command uint16_t IEEE154MessageLayer.getDestPan(message_t* msg) - { - return getHeader(msg)->destpan; - } - - async command void IEEE154MessageLayer.setDestPan(message_t* msg, uint16_t pan) - { - getHeader(msg)->destpan = pan; - } - - async command uint16_t IEEE154MessageLayer.getDestAddr(message_t* msg) - { - return getHeader(msg)->dest; - } - - async command void IEEE154MessageLayer.setDestAddr(message_t* msg, uint16_t addr) - { - getHeader(msg)->dest = addr; - } - - async command uint16_t IEEE154MessageLayer.getSrcAddr(message_t* msg) - { - return getHeader(msg)->src; - } - - async command void IEEE154MessageLayer.setSrcAddr(message_t* msg, uint16_t addr) - { - getHeader(msg)->src = addr; - } - - async command bool IEEE154MessageLayer.requiresAckWait(message_t* msg) - { - return call IEEE154MessageLayer.getAckRequired(msg) - && call IEEE154MessageLayer.isDataFrame(msg) - && call IEEE154MessageLayer.getDestAddr(msg) != 0xFFFF; - } - - async command bool IEEE154MessageLayer.requiresAckReply(message_t* msg) - { - return call IEEE154MessageLayer.getAckRequired(msg) - && call IEEE154MessageLayer.isDataFrame(msg) - && call IEEE154MessageLayer.getDestAddr(msg) == call ActiveMessageAddress.amAddress(); - } - - async event void ActiveMessageAddress.changed() - { - } - -/*----------------- Ieee154Packet -----------------*/ - - command ieee154_saddr_t Ieee154Packet.address() - { - return call ActiveMessageAddress.amAddress(); - } - - command ieee154_saddr_t Ieee154Packet.destination(message_t* msg) - { - return call IEEE154MessageLayer.getDestAddr(msg); - } - - command ieee154_saddr_t Ieee154Packet.source(message_t* msg) - { - return call IEEE154MessageLayer.getSrcAddr(msg); - } - - command void Ieee154Packet.setDestination(message_t* msg, ieee154_saddr_t addr) - { - call IEEE154MessageLayer.setDestAddr(msg, addr); - } - - command void Ieee154Packet.setSource(message_t* msg, ieee154_saddr_t addr) - { - call IEEE154MessageLayer.setSrcAddr(msg, addr); - } - - command bool Ieee154Packet.isForMe(message_t* msg) - { - ieee154_saddr_t addr = call Ieee154Packet.destination(msg); - return addr == call Ieee154Packet.address() || addr == IEEE154_BROADCAST_ADDR; - } - - command ieee154_panid_t Ieee154Packet.pan(message_t* msg) - { - return call IEEE154MessageLayer.getDestPan(msg); - } - - command void Ieee154Packet.setPan(message_t* msg, ieee154_panid_t grp) - { - call IEEE154MessageLayer.setDestPan(msg, grp); - } - - command ieee154_panid_t Ieee154Packet.localPan() - { - return call ActiveMessageAddress.amGroup(); - } - -/*----------------- RadioPacket -----------------*/ - - async command uint8_t RadioPacket.headerLength(message_t* msg) - { - return call SubPacket.headerLength(msg) + sizeof(ieee154_header_t); - } - - async command uint8_t RadioPacket.payloadLength(message_t* msg) - { - return call SubPacket.payloadLength(msg) - sizeof(ieee154_header_t); - } - - async command void RadioPacket.setPayloadLength(message_t* msg, uint8_t length) - { - call SubPacket.setPayloadLength(msg, length + sizeof(ieee154_header_t)); - } - - async command uint8_t RadioPacket.maxPayloadLength() - { - return call SubPacket.maxPayloadLength() - sizeof(ieee154_header_t); - } - - async command uint8_t RadioPacket.metadataLength(message_t* msg) - { - return call SubPacket.metadataLength(msg); - } - - async command void RadioPacket.clear(message_t* msg) - { - call IEEE154MessageLayer.createDataFrame(msg); - call SubPacket.clear(msg); - } - -/*----------------- Packet -----------------*/ - - command void Packet.clear(message_t* msg) - { - call RadioPacket.clear(msg); - } - - command uint8_t Packet.payloadLength(message_t* msg) - { - return call RadioPacket.payloadLength(msg); - } - - command void Packet.setPayloadLength(message_t* msg, uint8_t len) - { - call RadioPacket.setPayloadLength(msg, len); - } - - command uint8_t Packet.maxPayloadLength() - { - return call RadioPacket.maxPayloadLength(); - } - - command void* Packet.getPayload(message_t* msg, uint8_t len) - { - if( len > call RadioPacket.maxPayloadLength() ) - return NULL; - - return getPayload(msg); - } - -/*----------------- Ieee154Send -----------------*/ - - command void * Ieee154Send.getPayload(message_t* msg, uint8_t len) - { - return call Packet.getPayload(msg, len); - } - - command uint8_t Ieee154Send.maxPayloadLength() - { - return call Packet.maxPayloadLength(); - } - - command error_t Ieee154Send.cancel(message_t* msg) - { - return call SubSend.cancel(msg); - } - - command error_t Ieee154Send.send(ieee154_saddr_t addr, message_t* msg, uint8_t len) - { - if( len > call Packet.maxPayloadLength() ) - return EINVAL; - - // user forgot to call Packet.clear(), maybe we should return EFAIL - if( ! call IEEE154MessageLayer.isDataFrame(msg) ) - call IEEE154MessageLayer.createDataFrame(msg); - - call Packet.setPayloadLength(msg, len); - call Ieee154Packet.setSource(msg, call Ieee154Packet.address()); - call Ieee154Packet.setDestination(msg, addr); - call Ieee154Packet.setPan(msg, call Ieee154Packet.localPan()); - - signal SendNotifier.aboutToSend(addr, msg); - - return call SubSend.send(msg); - } - - default event void Ieee154Send.sendDone(message_t* msg, error_t error) - { - } - - default event void SendNotifier.aboutToSend(am_addr_t addr, message_t* msg) - { - } - -/*----------------- Send -----------------*/ - - command error_t Send.send(message_t* msg) - { - // user forgot to call Packet.clear(), lower levels can send other types - if( ! call IEEE154MessageLayer.isDataFrame(msg) ) - call IEEE154MessageLayer.createDataFrame(msg); - - return call SubSend.send(msg); - } - - command error_t Send.cancel(message_t* msg) - { - return call SubSend.cancel(msg); - } - - event void SubSend.sendDone(message_t* msg, error_t error) - { - // we signal both, only one of them should be connected - signal Ieee154Send.sendDone(msg, error); - signal Send.sendDone(msg, error); - } - - default event void Send.sendDone(message_t* msg, error_t error) - { - } - -/*----------------- Receive -----------------*/ - - event message_t* SubReceive.receive(message_t* msg) - { - if( call Ieee154Packet.isForMe(msg) ) - return signal Ieee154Receive.receive(msg, - getPayload(msg), call Packet.payloadLength(msg)); - else - return msg; - } -} diff --git a/tos/chips/rf2xx/layers/Ieee154MessageLayerC.nc b/tos/chips/rf2xx/layers/Ieee154MessageLayerC.nc new file mode 100644 index 00000000..d7e63113 --- /dev/null +++ b/tos/chips/rf2xx/layers/Ieee154MessageLayerC.nc @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2007-2009, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +module Ieee154MessageLayerC +{ + provides + { + interface Packet; + interface Ieee154Send; + interface Receive as Ieee154Receive; + interface SendNotifier; + } + + uses + { + interface Ieee154PacketLayer; + interface Ieee154Packet; + interface RadioPacket; + interface BareSend as SubSend; + interface BareReceive as SubReceive; + } +} + +implementation +{ + void* getPayload(message_t* msg) + { + return ((void*)msg) + call RadioPacket.headerLength(msg); + } + +/*----------------- Packet -----------------*/ + + command void Packet.clear(message_t* msg) + { + call RadioPacket.clear(msg); + } + + command uint8_t Packet.payloadLength(message_t* msg) + { + return call RadioPacket.payloadLength(msg); + } + + command void Packet.setPayloadLength(message_t* msg, uint8_t len) + { + call RadioPacket.setPayloadLength(msg, len); + } + + command uint8_t Packet.maxPayloadLength() + { + return call RadioPacket.maxPayloadLength(); + } + + command void* Packet.getPayload(message_t* msg, uint8_t len) + { + if( len > call RadioPacket.maxPayloadLength() ) + return NULL; + + return getPayload(msg); + } + +/*----------------- Ieee154Send -----------------*/ + + command void * Ieee154Send.getPayload(message_t* msg, uint8_t len) + { + return call Packet.getPayload(msg, len); + } + + command uint8_t Ieee154Send.maxPayloadLength() + { + return call Packet.maxPayloadLength(); + } + + command error_t Ieee154Send.cancel(message_t* msg) + { + return call SubSend.cancel(msg); + } + + command error_t Ieee154Send.send(ieee154_saddr_t addr, message_t* msg, uint8_t len) + { + if( len > call Packet.maxPayloadLength() ) + return EINVAL; + + // user forgot to call Packet.clear(), maybe we should return EFAIL + if( ! call Ieee154PacketLayer.isDataFrame(msg) ) + call Ieee154PacketLayer.createDataFrame(msg); + + call Packet.setPayloadLength(msg, len); + call Ieee154Packet.setSource(msg, call Ieee154Packet.address()); + call Ieee154Packet.setDestination(msg, addr); + call Ieee154Packet.setPan(msg, call Ieee154Packet.localPan()); + + signal SendNotifier.aboutToSend(addr, msg); + + return call SubSend.send(msg); + } + + event void SubSend.sendDone(message_t* msg, error_t error) + { + signal Ieee154Send.sendDone(msg, error); + } + + default event void Ieee154Send.sendDone(message_t* msg, error_t error) + { + } + + default event void SendNotifier.aboutToSend(am_addr_t addr, message_t* msg) + { + } + +/*----------------- Receive -----------------*/ + + event message_t* SubReceive.receive(message_t* msg) + { + if( call Ieee154Packet.isForMe(msg) ) + return signal Ieee154Receive.receive(msg, + getPayload(msg), call Packet.payloadLength(msg)); + else + return msg; + } + + default event message_t* Ieee154Receive.receive(message_t* msg, void* payload, uint8_t len) + { + return msg; + } +} diff --git a/tos/chips/rf2xx/layers/LowpanNetworkLayerC.nc b/tos/chips/rf2xx/layers/LowpanNetworkLayerC.nc deleted file mode 100644 index 027ce10d..00000000 --- a/tos/chips/rf2xx/layers/LowpanNetworkLayerC.nc +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2007, Vanderbilt University - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT - * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Author: Miklos Maroti - */ - -#include - -module LowpanNetworkLayerC -{ - provides - { - interface BareSend as Send; - interface BareReceive as Receive; - interface RadioPacket; - - interface Receive as NonTinyosReceive[uint8_t network]; - } - - uses - { - interface BareSend as SubSend; - interface BareReceive as SubReceive; - interface RadioPacket as SubPacket; - } -} - -implementation -{ - lowpan_header_t* getHeader(message_t* msg) - { - return ((void*)msg) + call SubPacket.headerLength(msg); - } - - void* getPayload(message_t* msg) - { - return ((void*)msg) + call RadioPacket.headerLength(msg); - } - -#ifndef TINYOS_6LOWPAN_NETWORK_ID -#define TINYOS_6LOWPAN_NETWORK_ID 0x3f -#endif - - command error_t Send.send(message_t* msg) - { - getHeader(msg)->network = TINYOS_6LOWPAN_NETWORK_ID; - return call SubSend.send(msg); - } - - command error_t Send.cancel(message_t* msg) - { - return call SubSend.cancel(msg); - } - - event void SubSend.sendDone(message_t* msg, error_t error) - { - signal Send.sendDone(msg, error); - } - - event message_t *SubReceive.receive(message_t *msg) - { - uint8_t network = getHeader(msg)->network; - if( network == TINYOS_6LOWPAN_NETWORK_ID ) - return signal Receive.receive(msg); - else - return signal NonTinyosReceive.receive[network](msg, - getPayload(msg), call RadioPacket.payloadLength(msg)); - } - - default event message_t *NonTinyosReceive.receive[uint8_t network](message_t *msg, void *payload, uint8_t len) - { - return msg; - } - -/*----------------- RadioPacket -----------------*/ - - async command uint8_t RadioPacket.headerLength(message_t* msg) - { - return call SubPacket.headerLength(msg) + sizeof(lowpan_header_t); - } - - async command uint8_t RadioPacket.payloadLength(message_t* msg) - { - return call SubPacket.payloadLength(msg) - sizeof(lowpan_header_t); - } - - async command void RadioPacket.setPayloadLength(message_t* msg, uint8_t length) - { - call SubPacket.setPayloadLength(msg, length + sizeof(lowpan_header_t)); - } - - async command uint8_t RadioPacket.maxPayloadLength() - { - return call SubPacket.maxPayloadLength() - sizeof(lowpan_header_t); - } - - async command uint8_t RadioPacket.metadataLength(message_t* msg) - { - return call SubPacket.metadataLength(msg); - } - - async command void RadioPacket.clear(message_t* msg) - { - call SubPacket.clear(msg); - } -} diff --git a/tos/chips/rf2xx/layers/LowpanNetworkLayer.h b/tos/chips/rf2xx/layers/TinyosNetworkLayer.h similarity index 87% rename from tos/chips/rf2xx/layers/LowpanNetworkLayer.h rename to tos/chips/rf2xx/layers/TinyosNetworkLayer.h index 96111bd7..11693c7d 100644 --- a/tos/chips/rf2xx/layers/LowpanNetworkLayer.h +++ b/tos/chips/rf2xx/layers/TinyosNetworkLayer.h @@ -21,12 +21,12 @@ * Author: Miklos Maroti */ -#ifndef __LOWPANNETWORKLAYER_H__ -#define __LOWPANNETWORKLAYER_H__ +#ifndef __TINYOSNETWORKLAYER_H__ +#define __TINYOSNETWORKLAYER_H__ -typedef nx_struct lowpan_header_t +typedef nx_struct network_header_t { nxle_uint8_t network; -} lowpan_header_t; +} network_header_t; -#endif//__LOWPANNETWORKLAYER_H__ +#endif//__TINYOSNETWORKLAYER_H__ diff --git a/tos/chips/rf2xx/layers/TinyosNetworkLayerC.nc b/tos/chips/rf2xx/layers/TinyosNetworkLayerC.nc new file mode 100644 index 00000000..6757cbf7 --- /dev/null +++ b/tos/chips/rf2xx/layers/TinyosNetworkLayerC.nc @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +#include + +#ifndef TINYOS_6LOWPAN_NETWORK_ID +#define TINYOS_6LOWPAN_NETWORK_ID 0x3f +#endif + +/* + If TFRAMES_ENABLED is defined, then only TinyOS frames will be supported + (with no network byte). If IEEE154FRAMES_ENABLED, then only IEEE 802.15.4 + frames will be supported (the network byte is part of the payload). If + neither is defined, then both TinyOS frames and IEEE 802.15.4 frames will + be supported where TinyOS frames are the ones whose network byte is + TINYOS_6LOWPAN_NETWORK_ID. +*/ + +#if defined(TFRAMES_ENABLED) && defined(IEEE154FRAMES_ENABLED) +#error You cannot specify both TFRAMES_ENABLED and IEEE154FRAMES_ENABLED at the same time +#endif + +module TinyosNetworkLayerC +{ + provides + { +#ifndef TFRAMES_ENABLED + interface BareSend as Ieee154Send; + interface BareReceive as Ieee154Receive; + interface RadioPacket as Ieee154Packet; +#endif + +#ifndef IEEE154FRAMES_ENABLED + interface BareSend as TinyosSend; + interface BareReceive as TinyosReceive; + interface RadioPacket as TinyosPacket; +#endif + } + + uses + { + interface BareSend as SubSend; + interface BareReceive as SubReceive; + interface RadioPacket as SubPacket; + } +} + +implementation +{ +/*----------------- Ieee154MessageC -----------------*/ + +#ifndef TFRAMES_ENABLED + + command error_t Ieee154Send.send(message_t* msg) + { + return call SubSend.send(msg); + } + + command error_t Ieee154Send.cancel(message_t* msg) + { + return call SubSend.cancel(msg); + } + + async command uint8_t Ieee154Packet.headerLength(message_t* msg) + { + return call SubPacket.headerLength(msg); + } + + async command uint8_t Ieee154Packet.payloadLength(message_t* msg) + { + return call SubPacket.payloadLength(msg); + } + + async command void Ieee154Packet.setPayloadLength(message_t* msg, uint8_t length) + { + call SubPacket.setPayloadLength(msg, length); + } + + async command uint8_t Ieee154Packet.maxPayloadLength() + { + return call SubPacket.maxPayloadLength(); + } + + async command uint8_t Ieee154Packet.metadataLength(message_t* msg) + { + return call SubPacket.metadataLength(msg); + } + + async command void Ieee154Packet.clear(message_t* msg) + { + call SubPacket.clear(msg); + } + +#endif + +/*----------------- ActiveMessageC -----------------*/ + +#ifndef IEEE154FRAMES_ENABLED + + network_header_t* getHeader(message_t* msg) + { + return ((void*)msg) + call SubPacket.headerLength(msg); + } + + command error_t TinyosSend.send(message_t* msg) + { +#ifndef TFRAMES_ENABLED + getHeader(msg)->network = TINYOS_6LOWPAN_NETWORK_ID; +#endif + return call SubSend.send(msg); + } + + command error_t TinyosSend.cancel(message_t* msg) + { + return call SubSend.cancel(msg); + } + + enum + { +#ifndef TFRAMES_ENABLED + PAYLOAD_OFFSET = sizeof(network_header_t), +#else + PAYLOAD_OFFSET = 0, +#endif + }; + + async command uint8_t TinyosPacket.headerLength(message_t* msg) + { + return call SubPacket.headerLength(msg) + PAYLOAD_OFFSET; + } + + async command uint8_t TinyosPacket.payloadLength(message_t* msg) + { + return call SubPacket.payloadLength(msg) - PAYLOAD_OFFSET; + } + + async command void TinyosPacket.setPayloadLength(message_t* msg, uint8_t length) + { + call SubPacket.setPayloadLength(msg, length + PAYLOAD_OFFSET); + } + + async command uint8_t TinyosPacket.maxPayloadLength() + { + return call SubPacket.maxPayloadLength() - PAYLOAD_OFFSET; + } + + async command uint8_t TinyosPacket.metadataLength(message_t* msg) + { + return call SubPacket.metadataLength(msg); + } + + async command void TinyosPacket.clear(message_t* msg) + { + call SubPacket.clear(msg); + } + +#endif + +/*----------------- Events -----------------*/ + +#if defined(TFRAMES_ENABLED) + + event void SubSend.sendDone(message_t* msg, error_t result) + { + signal TinyosSend.sendDone(msg, result); + } + + event message_t* SubReceive.receive(message_t* msg) + { + return signal TinyosReceive.receive(msg); + } + +#elif defined(IEEE154FRAMES_ENABLED) + + event void SubSend.sendDone(message_t* msg, error_t result) + { + signal Ieee154Send.sendDone(msg, result); + } + + event message_t* SubReceive.receive(message_t* msg) + { + return signal Ieee154Receive.receive(msg); + } + +#else + + event void SubSend.sendDone(message_t* msg, error_t result) + { + if( getHeader(msg)->network == TINYOS_6LOWPAN_NETWORK_ID ) + signal TinyosSend.sendDone(msg, result); + else + signal Ieee154Send.sendDone(msg, result); + } + + event message_t* SubReceive.receive(message_t* msg) + { + if( getHeader(msg)->network == TINYOS_6LOWPAN_NETWORK_ID ) + return signal TinyosReceive.receive(msg); + else + return signal Ieee154Receive.receive(msg); + } + +#endif +} diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc b/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc index e491ecae..38f8d3da 100644 --- a/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc +++ b/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc @@ -23,6 +23,10 @@ #include +#ifdef IEEE154FRAMES_ENABLED +#error "You cannot use ActiveMessageC with IEEE154FRAMES_ENABLED defined" +#endif + configuration RF230ActiveMessageC { provides @@ -36,9 +40,9 @@ configuration RF230ActiveMessageC interface Packet; interface AMPacket; + interface PacketAcknowledgements; interface LowPowerListening; - #ifdef PACKET_LINK interface PacketLink; #endif @@ -57,155 +61,31 @@ configuration RF230ActiveMessageC implementation { - components RF230ActiveMessageP, RadioAlarmC; - -#ifdef RADIO_DEBUG - components AssertC; -#endif - - RF230ActiveMessageP.IEEE154MessageLayer -> IEEE154MessageLayerC; - RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; - RF230ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC; - RF230ActiveMessageP.ActiveMessagePacket -> ActiveMessageLayerC; - RF230ActiveMessageP.RF230Packet -> RF230DriverLayerC; - -// -------- Active Message - - components ActiveMessageLayerC; - ActiveMessageLayerC.Config -> RF230ActiveMessageP; - ActiveMessageLayerC.SubSend -> LowpanNetworkLayerC; - ActiveMessageLayerC.SubReceive -> LowpanNetworkLayerC; - ActiveMessageLayerC.SubPacket ->LowpanNetworkLayerC; - AMSend = ActiveMessageLayerC; - Packet = ActiveMessageLayerC; - Receive = ActiveMessageLayerC.Receive; - Snoop = ActiveMessageLayerC.Snoop; - AMPacket = ActiveMessageLayerC; - SendNotifier = ActiveMessageLayerC; - -// -------- Lowpan Network - -#ifdef TFRAMES_ENABLED - components new DummyLayerC() as LowpanNetworkLayerC; -#else - components LowpanNetworkLayerC; -#endif - LowpanNetworkLayerC.SubSend -> IEEE154MessageLayerC; - LowpanNetworkLayerC.SubReceive -> LowPowerListeningLayerC; - LowpanNetworkLayerC.SubPacket -> IEEE154MessageLayerC; + components RF230RadioC; -// -------- IEEE154 Message + SplitControl = RF230RadioC; - components IEEE154MessageLayerC; - IEEE154MessageLayerC.SubPacket -> LowPowerListeningLayerC; - IEEE154MessageLayerC.SubSend -> UniqueLayerC; + AMSend = RF230RadioC; + Receive = RF230RadioC.Receive; + Snoop = RF230RadioC.Snoop; + SendNotifier = RF230RadioC; -// -------- UniqueLayer Send part (wired twice) - - components UniqueLayerC; - UniqueLayerC.Config -> RF230ActiveMessageP; - UniqueLayerC.SubSend -> LowPowerListeningLayerC; - -// -------- Low Power Listening - -#ifdef LOW_POWER_LISTENING - #warning "*** USING LOW POWER LISTENING LAYER" - components LowPowerListeningLayerC; - LowPowerListeningLayerC.Config -> RF230ActiveMessageP; - LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC; -#else - components LowPowerListeningDummyC as LowPowerListeningLayerC; -#endif - LowPowerListeningLayerC.SubControl -> MessageBufferLayerC; - LowPowerListeningLayerC.SubSend -> PacketLinkLayerC; - LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC; - LowPowerListeningLayerC.SubPacket -> PacketLinkLayerC; - SplitControl = LowPowerListeningLayerC; - LowPowerListening = LowPowerListeningLayerC; - -// -------- Packet Link + Packet = RF230RadioC.PacketForActiveMessage; + AMPacket = RF230RadioC; + PacketAcknowledgements = RF230RadioC; + LowPowerListening = RF230RadioC; #ifdef PACKET_LINK - #warning "*** USING PACKET LINK LAYER" - components PacketLinkLayerC; - PacketLink = PacketLinkLayerC; - PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC; -#else - components new DummyLayerC() as PacketLinkLayerC; -#endif - PacketLinkLayerC.SubSend -> MessageBufferLayerC; - PacketLinkLayerC.SubPacket -> TimeStampingLayerC; - -// -------- MessageBuffer - - components MessageBufferLayerC; - MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC; - MessageBufferLayerC.RadioReceive -> UniqueLayerC; - MessageBufferLayerC.RadioState -> TrafficMonitorLayerC; - RadioChannel = MessageBufferLayerC; - -// -------- UniqueLayer receive part (wired twice) - - UniqueLayerC.SubReceive -> TrafficMonitorLayerC; - -// -------- Traffic Monitor - -#ifdef TRAFFIC_MONITOR - components TrafficMonitorLayerC; -#else - components new DummyLayerC() as TrafficMonitorLayerC; -#endif - TrafficMonitorLayerC.Config -> RF230ActiveMessageP; - TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend; - TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive; - TrafficMonitorLayerC -> RF230DriverLayerC.RadioState; - -// -------- CollisionAvoidance - -#ifdef SLOTTED_MAC - components SlottedCollisionLayerC as CollisionAvoidanceLayerC; -#else - components RandomCollisionLayerC as CollisionAvoidanceLayerC; + PacketLink = RF230RadioC; #endif - CollisionAvoidanceLayerC.Config -> RF230ActiveMessageP; - CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC; - CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC; - -// -------- SoftwareAcknowledgement - - components SoftwareAckLayerC; - SoftwareAckLayerC.Config -> RF230ActiveMessageP; - SoftwareAckLayerC.SubSend -> CsmaLayerC; - SoftwareAckLayerC.SubReceive -> RF230DriverLayerC; - PacketAcknowledgements = SoftwareAckLayerC; - -// -------- Carrier Sense - - components new DummyLayerC() as CsmaLayerC; - CsmaLayerC.Config -> RF230ActiveMessageP; - CsmaLayerC -> RF230DriverLayerC.RadioSend; - CsmaLayerC -> RF230DriverLayerC.RadioCCA; - -// -------- TimeStamping - - components TimeStampingLayerC; - TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC; - TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC; - PacketTimeStampRadio = TimeStampingLayerC; - PacketTimeStampMilli = TimeStampingLayerC; - -// -------- MetadataFlags - components MetadataFlagsLayerC; - MetadataFlagsLayerC.SubPacket -> RF230DriverLayerC; + RadioChannel = RF230RadioC; -// -------- RF230 Driver + PacketLinkQuality = RF230RadioC.PacketLinkQuality; + PacketTransmitPower = RF230RadioC.PacketTransmitPower; + PacketRSSI = RF230RadioC.PacketRSSI; - components RF230DriverLayerC; - RF230DriverLayerC.Config -> RF230ActiveMessageP; - RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC; - PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower; - PacketLinkQuality = RF230DriverLayerC.PacketLinkQuality; - PacketRSSI = RF230DriverLayerC.PacketRSSI; - LocalTimeRadio = RF230DriverLayerC; + LocalTimeRadio = RF230RadioC; + PacketTimeStampMilli = RF230RadioC; + PacketTimeStampRadio = RF230RadioC; } diff --git a/tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc b/tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc index 553af9b8..089d4369 100644 --- a/tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc +++ b/tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc @@ -23,6 +23,10 @@ #include +#ifdef TFRAMES_ENABLED +#error "You cannot use Ieee154MessageC with TFRAMES_ENABLED defined" +#endif + configuration RF230Ieee154MessageC { provides @@ -31,12 +35,15 @@ configuration RF230Ieee154MessageC interface Ieee154Send; interface Receive as Ieee154Receive; + interface SendNotifier; + interface Ieee154Packet; interface Packet; + interface Resource as RadioSendResource[uint8_t clint]; + interface PacketAcknowledgements; interface LowPowerListening; interface PacketLink; - interface SendNotifier; interface RadioChannel; @@ -52,117 +59,29 @@ configuration RF230Ieee154MessageC implementation { - components RF230ActiveMessageP, RadioAlarmC; - -#ifdef RADIO_DEBUG - components AssertC; -#endif - - RF230ActiveMessageP.IEEE154MessageLayer -> IEEE154MessageLayerC; - RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; - RF230ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC; - RF230ActiveMessageP.RF230Packet -> RF230DriverLayerC; - -// -------- IEEE154 Message - - components IEEE154MessageLayerC; - IEEE154MessageLayerC.SubPacket -> LowPowerListeningLayerC; - IEEE154MessageLayerC.SubSend -> UniqueLayerC; - IEEE154MessageLayerC.SubReceive -> LowPowerListeningLayerC; - Ieee154Send = IEEE154MessageLayerC; - Packet = IEEE154MessageLayerC; - Ieee154Receive = IEEE154MessageLayerC; - Ieee154Packet = IEEE154MessageLayerC; - SendNotifier = IEEE154MessageLayerC; - -// -------- UniqueLayer Send part (wired twice) - - components UniqueLayerC; - UniqueLayerC.Config -> RF230ActiveMessageP; - UniqueLayerC.SubSend -> LowPowerListeningLayerC; - -// -------- Low Power Listening - -#ifdef LOW_POWER_LISTENING - components LowPowerListeningLayerC; - LowPowerListeningLayerC.Config -> RF230ActiveMessageP; - LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC; -#else - components LowPowerListeningDummyC as LowPowerListeningLayerC; -#endif - LowPowerListeningLayerC.SubControl -> MessageBufferLayerC; - LowPowerListeningLayerC.SubSend -> PacketLinkLayerC; - LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC; - LowPowerListeningLayerC.SubPacket -> PacketLinkLayerC; - SplitControl = LowPowerListeningLayerC; - LowPowerListening = LowPowerListeningLayerC; - -// -------- Packet Link - - components PacketLinkLayerC; - PacketLink = PacketLinkLayerC; - PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC; - PacketLinkLayerC.SubSend -> MessageBufferLayerC; - PacketLinkLayerC.SubPacket -> TimeStampingLayerC; - -// -------- MessageBuffer - - components MessageBufferLayerC; - MessageBufferLayerC.RadioSend -> CollisionAvoidanceLayerC; - MessageBufferLayerC.RadioReceive -> UniqueLayerC; - MessageBufferLayerC.RadioState -> RF230DriverLayerC; - RadioChannel = MessageBufferLayerC; - -// -------- UniqueLayer receive part (wired twice) - - UniqueLayerC.SubReceive -> CollisionAvoidanceLayerC; - -// -------- CollisionAvoidance - -#ifdef SLOTTED_MAC - components SlottedCollisionLayerC as CollisionAvoidanceLayerC; -#else - components RandomCollisionLayerC as CollisionAvoidanceLayerC; -#endif - CollisionAvoidanceLayerC.Config -> RF230ActiveMessageP; - CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC; - CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC; - -// -------- SoftwareAcknowledgement - - components SoftwareAckLayerC; - SoftwareAckLayerC.Config -> RF230ActiveMessageP; - SoftwareAckLayerC.SubSend -> CsmaLayerC; - SoftwareAckLayerC.SubReceive -> RF230DriverLayerC; - PacketAcknowledgements = SoftwareAckLayerC; - -// -------- Carrier Sense + components RF230RadioC; - components new DummyLayerC() as CsmaLayerC; - CsmaLayerC.Config -> RF230ActiveMessageP; - CsmaLayerC -> RF230DriverLayerC.RadioSend; - CsmaLayerC -> RF230DriverLayerC.RadioCCA; + SplitControl = RF230RadioC; -// -------- TimeStamping + Ieee154Send = RF230RadioC.Ieee154Send; + Ieee154Receive = RF230RadioC.Ieee154Receive; + SendNotifier = RF230RadioC.Ieee154Notifier; - components TimeStampingLayerC; - TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC; - TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC; - PacketTimeStampRadio = TimeStampingLayerC; - PacketTimeStampMilli = TimeStampingLayerC; + Packet = RF230RadioC.PacketForIeee154Message; + Ieee154Packet = RF230RadioC; + RadioSendResource = RF230RadioC; -// -------- MetadataFlags + PacketAcknowledgements = RF230RadioC; + LowPowerListening = RF230RadioC; + PacketLink = RF230RadioC; - components MetadataFlagsLayerC; - MetadataFlagsLayerC.SubPacket -> RF230DriverLayerC; + RadioChannel = RF230RadioC; -// -------- RF230 Driver + PacketLinkQuality = RF230RadioC.PacketLinkQuality; + PacketTransmitPower = RF230RadioC.PacketTransmitPower; + PacketRSSI = RF230RadioC.PacketRSSI; - components RF230DriverLayerC; - RF230DriverLayerC.Config -> RF230ActiveMessageP; - RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC; - PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower; - PacketLinkQuality = RF230DriverLayerC.PacketLinkQuality; - PacketRSSI = RF230DriverLayerC.PacketRSSI; - LocalTimeRadio = RF230DriverLayerC; + LocalTimeRadio = RF230RadioC; + PacketTimeStampMilli = RF230RadioC; + PacketTimeStampRadio = RF230RadioC; } diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessage.h b/tos/chips/rf2xx/rf230/RF230Radio.h similarity index 90% rename from tos/chips/rf2xx/rf230/RF230ActiveMessage.h rename to tos/chips/rf2xx/rf230/RF230Radio.h index e91bf224..c6461d25 100644 --- a/tos/chips/rf2xx/rf230/RF230ActiveMessage.h +++ b/tos/chips/rf2xx/rf230/RF230Radio.h @@ -21,11 +21,11 @@ * Author: Miklos Maroti */ -#ifndef __RF230ACTIVEMESSAGE_H__ -#define __RF230ACTIVEMESSAGE_H__ +#ifndef __RF230RADIO_H__ +#define __RF230RADIO_H__ -#include -#include +#include +#include #include #include #include @@ -38,9 +38,11 @@ typedef nx_struct rf230packet_header_t rf230_header_t rf230; ieee154_header_t ieee154; #ifndef TFRAMES_ENABLED - lowpan_header_t lowpan; + network_header_t network; #endif +#ifndef IEEE154FRAMES_ENABLED activemessage_header_t am; +#endif } rf230packet_header_t; typedef nx_struct rf230packet_footer_t @@ -61,4 +63,4 @@ typedef struct rf230packet_metadata_t rf230_metadata_t rf230; } rf230packet_metadata_t; -#endif//__RF230ACTIVEMESSAGE_H__ +#endif//__RF230RADIO_H__ diff --git a/tos/chips/rf2xx/rf230/RF230RadioC.nc b/tos/chips/rf2xx/rf230/RF230RadioC.nc new file mode 100644 index 00000000..adee914d --- /dev/null +++ b/tos/chips/rf2xx/rf230/RF230RadioC.nc @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +#include + +#ifndef TFRAMES_ENABLED +#define PACKET_LINK +#endif + +configuration RF230RadioC +{ + provides + { + interface SplitControl; + +#ifndef IEEE154FRAMES_ENABLED + interface AMSend[am_id_t id]; + interface Receive[am_id_t id]; + interface Receive as Snoop[am_id_t id]; + interface SendNotifier[am_id_t id]; + + interface AMPacket; + interface Packet as PacketForActiveMessage; +#endif + +#ifndef TFRAMES_ENABLED + interface Ieee154Send; + interface Receive as Ieee154Receive; + interface SendNotifier as Ieee154Notifier; + + interface Resource as RadioSendResource[uint8_t clint]; + + interface Ieee154Packet; + interface Packet as PacketForIeee154Message; +#endif + + interface PacketAcknowledgements; + interface LowPowerListening; + +#ifdef PACKET_LINK + interface PacketLink; +#endif + + interface RadioChannel; + + interface PacketField as PacketLinkQuality; + interface PacketField as PacketTransmitPower; + interface PacketField as PacketRSSI; + + interface LocalTime as LocalTimeRadio; + interface PacketTimeStamp as PacketTimeStampRadio; + interface PacketTimeStamp as PacketTimeStampMilli; + } +} + +implementation +{ + components RF230RadioP, RadioAlarmC; + +#ifdef RADIO_DEBUG + components AssertC; +#endif + + RF230RadioP.Ieee154PacketLayer -> Ieee154PacketLayerC; + RF230RadioP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; + RF230RadioP.PacketTimeStamp -> TimeStampingLayerC; + RF230RadioP.RF230Packet -> RF230DriverLayerC; + +// -------- Active Message + +#ifndef IEEE154FRAMES_ENABLED + components ActiveMessageLayerC; + ActiveMessageLayerC.Config -> RF230RadioP; + ActiveMessageLayerC.SubSend -> AutoResourceAcquireLayerC; + ActiveMessageLayerC.SubReceive -> TinyosNetworkLayerC.TinyosReceive; + ActiveMessageLayerC.SubPacket -> TinyosNetworkLayerC.TinyosPacket; + + AMSend = ActiveMessageLayerC; + Receive = ActiveMessageLayerC.Receive; + Snoop = ActiveMessageLayerC.Snoop; + SendNotifier = ActiveMessageLayerC; + AMPacket = ActiveMessageLayerC; + PacketForActiveMessage = ActiveMessageLayerC; +#endif + +// -------- Automatic RadioSend Resource + +#ifndef IEEE154FRAMES_ENABLED +#ifndef TFRAMES_ENABLED + components new AutoResourceAcquireLayerC(); + AutoResourceAcquireLayerC.Resource -> RadioSendResourceC.Resource[unique("RADIO_SEND_RESOURCE")]; +#else + components new DummyLayerC() as AutoResourceAcquireLayerC; +#endif + AutoResourceAcquireLayerC.SubSend -> TinyosNetworkLayerC.TinyosSend; +#endif + +// -------- RadioSend Resource + +#ifndef TFRAMES_ENABLED + components new SimpleFcfsArbiterC("RADIO_SEND_RESOURCE") as RadioSendResourceC; + RadioSendResource = RadioSendResourceC; + +// -------- Ieee154 Message + + components Ieee154MessageLayerC; + Ieee154MessageLayerC.Ieee154PacketLayer -> Ieee154PacketLayerC; + Ieee154MessageLayerC.Ieee154Packet -> Ieee154PacketLayerC; + Ieee154MessageLayerC.SubSend -> TinyosNetworkLayerC.Ieee154Send; + Ieee154MessageLayerC.SubReceive -> TinyosNetworkLayerC.Ieee154Receive; + Ieee154MessageLayerC.RadioPacket -> TinyosNetworkLayerC.Ieee154Packet; + + Ieee154Send = Ieee154MessageLayerC; + Ieee154Receive = Ieee154MessageLayerC; + Ieee154Notifier = Ieee154MessageLayerC; + Ieee154Packet = Ieee154PacketLayerC; + PacketForIeee154Message = Ieee154MessageLayerC; +#endif + +// -------- Tinyos Network + + components TinyosNetworkLayerC; + + TinyosNetworkLayerC.SubSend -> UniqueLayerC; + TinyosNetworkLayerC.SubReceive -> LowPowerListeningLayerC; + TinyosNetworkLayerC.SubPacket -> Ieee154PacketLayerC; + +// -------- IEEE 802.15.4 Packet + + components Ieee154PacketLayerC; + Ieee154PacketLayerC.SubPacket -> LowPowerListeningLayerC; + +// -------- UniqueLayer Send part (wired twice) + + components UniqueLayerC; + UniqueLayerC.Config -> RF230RadioP; + UniqueLayerC.SubSend -> LowPowerListeningLayerC; + +// -------- Low Power Listening + +#ifdef LOW_POWER_LISTENING + #warning "*** USING LOW POWER LISTENING LAYER" + components LowPowerListeningLayerC; + LowPowerListeningLayerC.Config -> RF230RadioP; + LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC; +#else + components LowPowerListeningDummyC as LowPowerListeningLayerC; +#endif + LowPowerListeningLayerC.SubControl -> MessageBufferLayerC; + LowPowerListeningLayerC.SubSend -> PacketLinkLayerC; + LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC; + LowPowerListeningLayerC.SubPacket -> PacketLinkLayerC; + SplitControl = LowPowerListeningLayerC; + LowPowerListening = LowPowerListeningLayerC; + +// -------- Packet Link + +#ifdef PACKET_LINK + components PacketLinkLayerC; + PacketLink = PacketLinkLayerC; + PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC; +#else + components new DummyLayerC() as PacketLinkLayerC; +#endif + PacketLinkLayerC.SubSend -> MessageBufferLayerC; + PacketLinkLayerC.SubPacket -> TimeStampingLayerC; + +// -------- MessageBuffer + + components MessageBufferLayerC; + MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC; + MessageBufferLayerC.RadioReceive -> UniqueLayerC; + MessageBufferLayerC.RadioState -> TrafficMonitorLayerC; + RadioChannel = MessageBufferLayerC; + +// -------- UniqueLayer receive part (wired twice) + + UniqueLayerC.SubReceive -> TrafficMonitorLayerC; + +// -------- Traffic Monitor + +#ifdef TRAFFIC_MONITOR + components TrafficMonitorLayerC; +#else + components new DummyLayerC() as TrafficMonitorLayerC; +#endif + TrafficMonitorLayerC.Config -> RF230RadioP; + TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend; + TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive; + TrafficMonitorLayerC -> RF230DriverLayerC.RadioState; + +// -------- CollisionAvoidance + +#ifdef SLOTTED_MAC + components SlottedCollisionLayerC as CollisionAvoidanceLayerC; +#else + components RandomCollisionLayerC as CollisionAvoidanceLayerC; +#endif + CollisionAvoidanceLayerC.Config -> RF230RadioP; + CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC; + CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC; + +// -------- SoftwareAcknowledgement + + components SoftwareAckLayerC; + SoftwareAckLayerC.Config -> RF230RadioP; + SoftwareAckLayerC.SubSend -> CsmaLayerC; + SoftwareAckLayerC.SubReceive -> RF230DriverLayerC; + PacketAcknowledgements = SoftwareAckLayerC; + +// -------- Carrier Sense + + components new DummyLayerC() as CsmaLayerC; + CsmaLayerC.Config -> RF230RadioP; + CsmaLayerC -> RF230DriverLayerC.RadioSend; + CsmaLayerC -> RF230DriverLayerC.RadioCCA; + +// -------- TimeStamping + + components TimeStampingLayerC; + TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC; + TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC; + PacketTimeStampRadio = TimeStampingLayerC; + PacketTimeStampMilli = TimeStampingLayerC; + +// -------- MetadataFlags + + components MetadataFlagsLayerC; + MetadataFlagsLayerC.SubPacket -> RF230DriverLayerC; + +// -------- RF230 Driver + + components RF230DriverLayerC; + RF230DriverLayerC.Config -> RF230RadioP; + RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC; + PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower; + PacketLinkQuality = RF230DriverLayerC.PacketLinkQuality; + PacketRSSI = RF230DriverLayerC.PacketRSSI; + LocalTimeRadio = RF230DriverLayerC; +} diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc b/tos/chips/rf2xx/rf230/RF230RadioP.nc similarity index 85% rename from tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc rename to tos/chips/rf2xx/rf230/RF230RadioP.nc index 301a110a..57ad57a9 100644 --- a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc +++ b/tos/chips/rf2xx/rf230/RF230RadioP.nc @@ -21,11 +21,11 @@ * Author: Miklos Maroti */ -#include +#include #include #include -module RF230ActiveMessageP +module RF230RadioP { provides { @@ -46,9 +46,8 @@ module RF230ActiveMessageP uses { - interface IEEE154MessageLayer; + interface Ieee154PacketLayer; interface RadioAlarm; - interface RadioPacket as ActiveMessagePacket; interface RadioPacket as RF230Packet; interface PacketTimeStamp; @@ -83,39 +82,39 @@ implementation async command bool RF230DriverConfig.requiresRssiCca(message_t* msg) { - return call IEEE154MessageLayer.isDataFrame(msg); + return call Ieee154PacketLayer.isDataFrame(msg); } /*----------------- SoftwareAckConfig -----------------*/ async command bool SoftwareAckConfig.requiresAckWait(message_t* msg) { - return call IEEE154MessageLayer.requiresAckWait(msg); + return call Ieee154PacketLayer.requiresAckWait(msg); } async command bool SoftwareAckConfig.isAckPacket(message_t* msg) { - return call IEEE154MessageLayer.isAckFrame(msg); + return call Ieee154PacketLayer.isAckFrame(msg); } async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack) { - return call IEEE154MessageLayer.verifyAckReply(data, ack); + return call Ieee154PacketLayer.verifyAckReply(data, ack); } async command void SoftwareAckConfig.setAckRequired(message_t* msg, bool ack) { - call IEEE154MessageLayer.setAckRequired(msg, ack); + call Ieee154PacketLayer.setAckRequired(msg, ack); } async command bool SoftwareAckConfig.requiresAckReply(message_t* msg) { - return call IEEE154MessageLayer.requiresAckReply(msg); + return call Ieee154PacketLayer.requiresAckReply(msg); } async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack) { - call IEEE154MessageLayer.createAckReply(data, ack); + call Ieee154PacketLayer.createAckReply(data, ack); } #ifndef SOFTWAREACK_TIMEOUT @@ -138,17 +137,17 @@ implementation async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg) { - return call IEEE154MessageLayer.getDSN(msg); + return call Ieee154PacketLayer.getDSN(msg); } async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn) { - call IEEE154MessageLayer.setDSN(msg, dsn); + call Ieee154PacketLayer.setDSN(msg, dsn); } async command am_addr_t UniqueConfig.getSender(message_t* msg) { - return call IEEE154MessageLayer.getSrcAddr(msg); + return call Ieee154PacketLayer.getSrcAddr(msg); } tasklet_async command void UniqueConfig.reportChannelError() @@ -162,39 +161,39 @@ implementation command am_addr_t ActiveMessageConfig.destination(message_t* msg) { - return call IEEE154MessageLayer.getDestAddr(msg); + return call Ieee154PacketLayer.getDestAddr(msg); } command void ActiveMessageConfig.setDestination(message_t* msg, am_addr_t addr) { - call IEEE154MessageLayer.setDestAddr(msg, addr); + call Ieee154PacketLayer.setDestAddr(msg, addr); } command am_addr_t ActiveMessageConfig.source(message_t* msg) { - return call IEEE154MessageLayer.getSrcAddr(msg); + return call Ieee154PacketLayer.getSrcAddr(msg); } command void ActiveMessageConfig.setSource(message_t* msg, am_addr_t addr) { - call IEEE154MessageLayer.setSrcAddr(msg, addr); + call Ieee154PacketLayer.setSrcAddr(msg, addr); } command am_group_t ActiveMessageConfig.group(message_t* msg) { - return call IEEE154MessageLayer.getDestPan(msg); + return call Ieee154PacketLayer.getDestPan(msg); } command void ActiveMessageConfig.setGroup(message_t* msg, am_group_t grp) { - call IEEE154MessageLayer.setDestPan(msg, grp); + call Ieee154PacketLayer.setDestPan(msg, grp); } /*----------------- CsmaConfig -----------------*/ async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg) { - return call IEEE154MessageLayer.isDataFrame(msg); + return call Ieee154PacketLayer.isDataFrame(msg); } /*----------------- TrafficMonitorConfig -----------------*/ @@ -220,12 +219,12 @@ implementation */ uint8_t len = call RF230Packet.payloadLength(msg); - return call IEEE154MessageLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; + return call Ieee154PacketLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; } async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg) { - return call IEEE154MessageLayer.getSrcAddr(msg); + return call Ieee154PacketLayer.getSrcAddr(msg); } /*----------------- RandomCollisionConfig -----------------*/ @@ -262,7 +261,7 @@ implementation time = call RadioAlarm.getNow(); // estimated response time (download the message, etc) is 5-8 bytes - if( call IEEE154MessageLayer.requiresAckReply(msg) ) + if( call Ieee154PacketLayer.requiresAckReply(msg) ) time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RADIO_ALARM_MICROSEC); else time += (uint16_t)(32 * (-5 + 5) * RADIO_ALARM_MICROSEC); @@ -315,7 +314,7 @@ implementation async command bool LowPowerListeningConfig.getAckRequired(message_t* msg) { - return call IEEE154MessageLayer.getAckRequired(msg); + return call Ieee154PacketLayer.getAckRequired(msg); } #endif diff --git a/tos/platforms/iris/ActiveMessageC.nc b/tos/platforms/iris/ActiveMessageC.nc index b9273dac..a4c2ae77 100644 --- a/tos/platforms/iris/ActiveMessageC.nc +++ b/tos/platforms/iris/ActiveMessageC.nc @@ -48,24 +48,24 @@ configuration ActiveMessageC implementation { - components RF230ActiveMessageC as MAC; + components RF230ActiveMessageC as MessageC; - SplitControl = MAC; + SplitControl = MessageC; - AMSend = MAC; - Receive = MAC.Receive; - Snoop = MAC.Snoop; - SendNotifier = MAC; + AMSend = MessageC; + Receive = MessageC.Receive; + Snoop = MessageC.Snoop; + SendNotifier = MessageC; - Packet = MAC; - AMPacket = MAC; + Packet = MessageC; + AMPacket = MessageC; - PacketAcknowledgements = MAC; - LowPowerListening = MAC; + PacketAcknowledgements = MessageC; + LowPowerListening = MessageC; #ifdef PACKET_LINK - PacketLink = MAC; + PacketLink = MessageC; #endif - PacketTimeStampMilli = MAC; - PacketTimeStampMicro = MAC; + PacketTimeStampMilli = MessageC; + PacketTimeStampMicro = MessageC; } diff --git a/tos/platforms/iris/Ieee154MessageC.nc b/tos/platforms/iris/Ieee154MessageC.nc index 9e2de9e8..ce1d59bc 100644 --- a/tos/platforms/iris/Ieee154MessageC.nc +++ b/tos/platforms/iris/Ieee154MessageC.nc @@ -21,7 +21,7 @@ * Author: Miklos Maroti */ -configuration ActiveMessageC +configuration Ieee154MessageC { provides { @@ -33,6 +33,7 @@ configuration ActiveMessageC interface Packet; interface Ieee154Packet; + interface Resource as RadioSendResource[uint8_t clint]; interface PacketAcknowledgements; interface LowPowerListening; @@ -45,21 +46,22 @@ configuration ActiveMessageC implementation { - components RF230Ieee154MessageC as MAC; + components RF230Ieee154MessageC as MessageC; - SplitControl = MAC; + SplitControl = MessageC; - Ieee154Send = MAC; - Ieee154Receive = MAC.Receive; - SendNotifier = MAC; + Ieee154Send = MessageC; + Ieee154Receive = MessageC; + SendNotifier = MessageC; - Packet = MAC; - Ieee154Packet = MAC; + Packet = MessageC; + Ieee154Packet = MessageC; + RadioSendResource = MessageC; - PacketAcknowledgements = MAC; - LowPowerListening = MAC; - PacketLink = MAC; + PacketAcknowledgements = MessageC; + LowPowerListening = MessageC; + PacketLink = MessageC; - PacketTimeStampMilli = MAC; - PacketTimeStampMicro = MAC; + PacketTimeStampMilli = MessageC; + PacketTimeStampMicro = MessageC; } diff --git a/tos/platforms/iris/platform_message.h b/tos/platforms/iris/platform_message.h index 387d74fe..3b2ffb02 100644 --- a/tos/platforms/iris/platform_message.h +++ b/tos/platforms/iris/platform_message.h @@ -23,7 +23,7 @@ #ifndef PLATFORM_MESSAGE_H #define PLATFORM_MESSAGE_H -#include +#include #include typedef union message_header { -- 2.39.2