From fb06e38f2c4372980a983a3d79f584221d475a36 Mon Sep 17 00:00:00 2001 From: mmaroti Date: Thu, 2 Apr 2009 22:09:59 +0000 Subject: [PATCH] change metadata handling, remove the RF2xxPacket component, move functionality to RF2xxActiveMessage, prepare blip support (RF2xxMessageC) --- .../tests/rf230/RF230Sniffer/RF230SnifferC.nc | 15 +- tos/chips/rf2xx/layers/DummyLayerC.nc | 4 - .../rf2xx/layers/IEEE154NetworkLayerC.nc | 4 +- .../rf2xx/layers/IEEE154NetworkLayerP.nc | 6 +- .../IEEE154PacketLayer.h} | 6 +- .../IEEE154PacketLayer.nc} | 4 +- .../IEEE154PacketLayerC.nc} | 12 +- .../IEEE154PacketLayerP.nc} | 92 +++--- .../rf2xx/layers/LowPowerListeningDummyC.nc | 50 +++ ...myLayerP.nc => LowPowerListeningDummyP.nc} | 2 +- .../rf2xx/layers/LowPowerListeningLayer.h | 32 ++ .../rf2xx/layers/LowPowerListeningLayerC.nc | 10 +- .../rf2xx/layers/LowPowerListeningLayerP.nc | 43 +-- tos/chips/rf2xx/layers/MetadataFlagsLayer.h | 33 ++ tos/chips/rf2xx/layers/MetadataFlagsLayerC.nc | 73 +++++ tos/chips/rf2xx/layers/PacketLinkLayer.h | 8 +- tos/chips/rf2xx/layers/PacketLinkLayerC.nc | 10 +- tos/chips/rf2xx/layers/PacketLinkLayerP.nc | 14 +- tos/chips/rf2xx/layers/SoftwareAckConfig.nc | 11 +- tos/chips/rf2xx/layers/SoftwareAckLayerC.nc | 5 +- tos/chips/rf2xx/layers/SoftwareAckLayerP.nc | 29 +- tos/chips/rf2xx/layers/TimeStampingLayer.h | 32 ++ tos/chips/rf2xx/layers/TimeStampingLayerC.nc | 52 +++ tos/chips/rf2xx/layers/TimeStampingLayerP.nc | 96 ++++++ .../{RF212Packet.h => RF212ActiveMessage.h} | 37 +-- tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc | 145 +++++---- tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc | 158 +++++++-- .../rf212/{RF212.h => RF212DriverLayer.h} | 16 +- tos/chips/rf2xx/rf212/RF212DriverLayerC.nc | 46 ++- tos/chips/rf2xx/rf212/RF212DriverLayerP.nc | 132 +++++++- tos/chips/rf2xx/rf212/RF212PacketC.nc | 69 ---- tos/chips/rf2xx/rf212/RF212PacketP.nc | 305 ------------------ .../{RF230Packet.h => RF230ActiveMessage.h} | 37 +-- tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc | 145 +++++---- tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc | 158 +++++++-- .../rf230/{RF230.h => RF230DriverLayer.h} | 16 +- tos/chips/rf2xx/rf230/RF230DriverLayerC.nc | 44 ++- tos/chips/rf2xx/rf230/RF230DriverLayerP.nc | 128 +++++++- tos/chips/rf2xx/rf230/RF230PacketC.nc | 69 ---- tos/chips/rf2xx/rf230/RF230PacketP.nc | 305 ------------------ tos/chips/rf2xx/util/MetadataFlagC.nc | 37 +++ tos/chips/rf2xx/util/PacketData.nc | 4 +- tos/chips/rf2xx/util/PacketFlag.nc | 45 +++ tos/platforms/iris/TimeSyncMessageC.nc | 4 +- tos/platforms/iris/chips/rf230/HplRF230C.nc | 4 + tos/platforms/iris/chips/rf230/RadioConfig.h | 2 +- tos/platforms/iris/platform_message.h | 2 +- 47 files changed, 1409 insertions(+), 1142 deletions(-) rename tos/chips/rf2xx/{util/IEEE154Packet2.h => layers/IEEE154PacketLayer.h} (95%) rename tos/chips/rf2xx/{util/IEEE154Packet2.nc => layers/IEEE154PacketLayer.nc} (98%) rename tos/chips/rf2xx/{util/IEEE154Packet2C.nc => layers/IEEE154PacketLayerC.nc} (81%) rename tos/chips/rf2xx/{util/IEEE154Packet2P.nc => layers/IEEE154PacketLayerP.nc} (61%) create mode 100644 tos/chips/rf2xx/layers/LowPowerListeningDummyC.nc rename tos/chips/rf2xx/layers/{DummyLayerP.nc => LowPowerListeningDummyP.nc} (98%) create mode 100644 tos/chips/rf2xx/layers/LowPowerListeningLayer.h create mode 100644 tos/chips/rf2xx/layers/MetadataFlagsLayer.h create mode 100644 tos/chips/rf2xx/layers/MetadataFlagsLayerC.nc create mode 100644 tos/chips/rf2xx/layers/TimeStampingLayer.h create mode 100644 tos/chips/rf2xx/layers/TimeStampingLayerC.nc create mode 100644 tos/chips/rf2xx/layers/TimeStampingLayerP.nc rename tos/chips/rf2xx/rf212/{RF212Packet.h => RF212ActiveMessage.h} (67%) rename tos/chips/rf2xx/rf212/{RF212.h => RF212DriverLayer.h} (95%) delete mode 100644 tos/chips/rf2xx/rf212/RF212PacketC.nc delete mode 100644 tos/chips/rf2xx/rf212/RF212PacketP.nc rename tos/chips/rf2xx/rf230/{RF230Packet.h => RF230ActiveMessage.h} (67%) rename tos/chips/rf2xx/rf230/{RF230.h => RF230DriverLayer.h} (94%) delete mode 100644 tos/chips/rf2xx/rf230/RF230PacketC.nc delete mode 100644 tos/chips/rf2xx/rf230/RF230PacketP.nc create mode 100644 tos/chips/rf2xx/util/MetadataFlagC.nc create mode 100644 tos/chips/rf2xx/util/PacketFlag.nc diff --git a/apps/tests/rf230/RF230Sniffer/RF230SnifferC.nc b/apps/tests/rf230/RF230Sniffer/RF230SnifferC.nc index cf83fb44..ff5abc60 100644 --- a/apps/tests/rf230/RF230Sniffer/RF230SnifferC.nc +++ b/apps/tests/rf230/RF230Sniffer/RF230SnifferC.nc @@ -27,15 +27,26 @@ configuration RF230SnifferC implementation { - components RF230SnifferP, MainC, SerialActiveMessageC, RF230DriverLayerC, RF230ActiveMessageP, IEEE154Packet2C, AssertC; + components RF230SnifferP, MainC, SerialActiveMessageC, AssertC; RF230SnifferP.Boot -> MainC; RF230SnifferP.SplitControl -> SerialActiveMessageC; RF230SnifferP.RadioState -> RF230DriverLayerC; + components RF230DriverLayerC; + RF230DriverLayerC.PacketRF230Metadata -> RF230ActiveMessageP; RF230DriverLayerC.RF230DriverConfig -> RF230ActiveMessageP; + RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC; - RF230ActiveMessageP.IEEE154Packet2 -> IEEE154Packet2C; + components MetadataFlagsLayerC; + MetadataFlagsLayerC.PacketFlagsMetadata -> RF230ActiveMessageP; + + components RF230ActiveMessageP, IEEE154PacketLayerC; + RF230ActiveMessageP.IEEE154PacketLayer -> IEEE154PacketLayerC; + + components TimeStampingLayerC; + TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC; + TimeStampingLayerC.PacketTimeStampMetadata -> RF230ActiveMessageP; // just to avoid a timer compilation bug components new TimerMilliC(); diff --git a/tos/chips/rf2xx/layers/DummyLayerC.nc b/tos/chips/rf2xx/layers/DummyLayerC.nc index e3c55dea..3b76025d 100644 --- a/tos/chips/rf2xx/layers/DummyLayerC.nc +++ b/tos/chips/rf2xx/layers/DummyLayerC.nc @@ -28,7 +28,6 @@ generic configuration DummyLayerC() interface SplitControl; interface Send; interface Receive; - interface LowPowerListening; interface RadioState; interface RadioSend; @@ -64,7 +63,4 @@ implementation Receive = SubReceive; Config = UnconnectedConfig; - - components DummyLayerP; - LowPowerListening = DummyLayerP.LowPowerListening; } diff --git a/tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc b/tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc index 5069218d..64cb933b 100644 --- a/tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc +++ b/tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc @@ -39,7 +39,7 @@ configuration IEEE154NetworkLayerC implementation { - components IEEE154NetworkLayerP, IEEE154Packet2C; + components IEEE154NetworkLayerP, IEEE154PacketLayerC; SplitControl = SubControl; @@ -49,5 +49,5 @@ implementation SubSend = IEEE154NetworkLayerP; SubReceive = IEEE154NetworkLayerP; - IEEE154NetworkLayerP.IEEE154Packet2 -> IEEE154Packet2C; + IEEE154NetworkLayerP.IEEE154PacketLayer -> IEEE154PacketLayerC; } diff --git a/tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc b/tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc index 4771f688..d5b33bf7 100644 --- a/tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc +++ b/tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc @@ -35,7 +35,7 @@ module IEEE154NetworkLayerP interface Send as SubSend; interface Receive as SubReceive; - interface IEEE154Packet2; + interface IEEE154PacketLayer; } } @@ -47,7 +47,7 @@ implementation command error_t Send.send(message_t* msg, uint8_t len) { - call IEEE154Packet2.set6LowPan(msg, TINYOS_6LOWPAN_NETWORK_ID); + call IEEE154PacketLayer.set6LowPan(msg, TINYOS_6LOWPAN_NETWORK_ID); return call SubSend.send(msg, len); } @@ -73,7 +73,7 @@ implementation event message_t *SubReceive.receive(message_t *msg, void *payload, uint8_t len) { - uint8_t network = call IEEE154Packet2.get6LowPan(msg); + uint8_t network = call IEEE154PacketLayer.get6LowPan(msg); if( network == TINYOS_6LOWPAN_NETWORK_ID ) return signal Receive.receive(msg, payload, len); else diff --git a/tos/chips/rf2xx/util/IEEE154Packet2.h b/tos/chips/rf2xx/layers/IEEE154PacketLayer.h similarity index 95% rename from tos/chips/rf2xx/util/IEEE154Packet2.h rename to tos/chips/rf2xx/layers/IEEE154PacketLayer.h index 5c580071..721d96d8 100644 --- a/tos/chips/rf2xx/util/IEEE154Packet2.h +++ b/tos/chips/rf2xx/layers/IEEE154PacketLayer.h @@ -21,8 +21,8 @@ * Author: Miklos Maroti */ -#ifndef __IEEE154PACKET2_H__ -#define __IEEE154PACKET2_H__ +#ifndef __IEEE154PACKETLAYER_H__ +#define __IEEE154PACKETLAYER_H__ typedef nx_struct ieee154_header_t { @@ -72,4 +72,4 @@ enum iee154_fcf_addr_mode_enums { IEEE154_ADDR_MASK = 3, }; -#endif//__IEEE154PACKET2_H__ +#endif//__IEEE154PACKETLAYER_H__ diff --git a/tos/chips/rf2xx/util/IEEE154Packet2.nc b/tos/chips/rf2xx/layers/IEEE154PacketLayer.nc similarity index 98% rename from tos/chips/rf2xx/util/IEEE154Packet2.nc rename to tos/chips/rf2xx/layers/IEEE154PacketLayer.nc index 09579048..896b9cd9 100644 --- a/tos/chips/rf2xx/util/IEEE154Packet2.nc +++ b/tos/chips/rf2xx/layers/IEEE154PacketLayer.nc @@ -21,7 +21,7 @@ * Author: Miklos Maroti */ -#include +#include #include /** @@ -31,7 +31,7 @@ * Note, that this interface does not support the CRC-16 value, which * should be verified before the data can be trusted. */ -interface IEEE154Packet2 +interface IEEE154PacketLayer { /** * Returns the IEEE 802.15.4 header including the length field. diff --git a/tos/chips/rf2xx/util/IEEE154Packet2C.nc b/tos/chips/rf2xx/layers/IEEE154PacketLayerC.nc similarity index 81% rename from tos/chips/rf2xx/util/IEEE154Packet2C.nc rename to tos/chips/rf2xx/layers/IEEE154PacketLayerC.nc index c2fa14b5..a0768a9e 100644 --- a/tos/chips/rf2xx/util/IEEE154Packet2C.nc +++ b/tos/chips/rf2xx/layers/IEEE154PacketLayerC.nc @@ -21,20 +21,20 @@ * Author: Miklos Maroti */ -configuration IEEE154Packet2C +configuration IEEE154PacketLayerC { provides { - interface IEEE154Packet2; + interface IEEE154PacketLayer; interface AMPacket; } } implementation { - components IEEE154Packet2P, ActiveMessageAddressC; - IEEE154Packet2P.ActiveMessageAddress -> ActiveMessageAddressC; + components IEEE154PacketLayerP, ActiveMessageAddressC; + IEEE154PacketLayerP.ActiveMessageAddress -> ActiveMessageAddressC; - IEEE154Packet2 = IEEE154Packet2P; - AMPacket = IEEE154Packet2P; + IEEE154PacketLayer = IEEE154PacketLayerP; + AMPacket = IEEE154PacketLayerP; } diff --git a/tos/chips/rf2xx/util/IEEE154Packet2P.nc b/tos/chips/rf2xx/layers/IEEE154PacketLayerP.nc similarity index 61% rename from tos/chips/rf2xx/util/IEEE154Packet2P.nc rename to tos/chips/rf2xx/layers/IEEE154PacketLayerP.nc index cb4ca8c1..58573657 100644 --- a/tos/chips/rf2xx/util/IEEE154Packet2P.nc +++ b/tos/chips/rf2xx/layers/IEEE154PacketLayerP.nc @@ -21,13 +21,13 @@ * Author: Miklos Maroti */ -#include +#include -module IEEE154Packet2P +module IEEE154PacketLayerP { provides { - interface IEEE154Packet2; + interface IEEE154PacketLayer; interface AMPacket; } @@ -60,47 +60,47 @@ implementation return (ieee154_header_t*)(msg->data - sizeof(ieee154_header_t)); } - inline async command ieee154_header_t* IEEE154Packet2.getHeader(message_t* msg) + inline async command ieee154_header_t* IEEE154PacketLayer.getHeader(message_t* msg) { return getHeader(msg); } - inline async command uint8_t IEEE154Packet2.getLength(message_t* msg) + inline async command uint8_t IEEE154PacketLayer.getLength(message_t* msg) { return getHeader(msg)->length; } - inline async command void IEEE154Packet2.setLength(message_t* msg, uint8_t length) + inline async command void IEEE154PacketLayer.setLength(message_t* msg, uint8_t length) { getHeader(msg)->length = length; } - inline async command uint16_t IEEE154Packet2.getFCF(message_t* msg) + inline async command uint16_t IEEE154PacketLayer.getFCF(message_t* msg) { return getHeader(msg)->fcf; } - inline async command void IEEE154Packet2.setFCF(message_t* msg, uint16_t fcf) + inline async command void IEEE154PacketLayer.setFCF(message_t* msg, uint16_t fcf) { getHeader(msg)->fcf = fcf; } - inline async command bool IEEE154Packet2.isDataFrame(message_t* msg) + 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 IEEE154Packet2.createDataFrame(message_t* msg) + inline async command void IEEE154PacketLayer.createDataFrame(message_t* msg) { getHeader(msg)->fcf = IEEE154_DATA_FRAME_VALUE; } - inline async command bool IEEE154Packet2.isAckFrame(message_t* msg) + 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 IEEE154Packet2.createAckFrame(message_t* msg) + inline async command void IEEE154PacketLayer.createAckFrame(message_t* msg) { ieee154_header_t* header = getHeader(msg); @@ -108,7 +108,7 @@ implementation header->fcf = IEEE154_ACK_FRAME_VALUE; } - inline async command void IEEE154Packet2.createAckReply(message_t* data, message_t* ack) + inline async command void IEEE154PacketLayer.createAckReply(message_t* data, message_t* ack) { ieee154_header_t* header = getHeader(ack); @@ -117,7 +117,7 @@ implementation header->dsn = getHeader(data)->dsn; } - inline async command bool IEEE154Packet2.verifyAckReply(message_t* data, message_t* ack) + inline async command bool IEEE154PacketLayer.verifyAckReply(message_t* data, message_t* ack) { ieee154_header_t* header = getHeader(ack); @@ -125,12 +125,12 @@ implementation && (header->fcf & IEEE154_ACK_FRAME_MASK) == IEEE154_ACK_FRAME_VALUE; } - inline async command bool IEEE154Packet2.getAckRequired(message_t* msg) + inline async command bool IEEE154PacketLayer.getAckRequired(message_t* msg) { return getHeader(msg)->fcf & (1 << IEEE154_FCF_ACK_REQ); } - inline async command void IEEE154Packet2.setAckRequired(message_t* msg, bool ack) + inline async command void IEEE154PacketLayer.setAckRequired(message_t* msg, bool ack) { if( ack ) getHeader(msg)->fcf |= (1 << IEEE154_FCF_ACK_REQ); @@ -138,12 +138,12 @@ implementation getHeader(msg)->fcf &= ~(uint16_t)(1 << IEEE154_FCF_ACK_REQ); } - inline async command bool IEEE154Packet2.getFramePending(message_t* msg) + inline async command bool IEEE154PacketLayer.getFramePending(message_t* msg) { return getHeader(msg)->fcf & (1 << IEEE154_FCF_FRAME_PENDING); } - inline async command void IEEE154Packet2.setFramePending(message_t* msg, bool pending) + inline async command void IEEE154PacketLayer.setFramePending(message_t* msg, bool pending) { if( pending ) getHeader(msg)->fcf |= (1 << IEEE154_FCF_FRAME_PENDING); @@ -151,82 +151,82 @@ implementation getHeader(msg)->fcf &= ~(uint16_t)(1 << IEEE154_FCF_FRAME_PENDING); } - inline async command uint8_t IEEE154Packet2.getDSN(message_t* msg) + inline async command uint8_t IEEE154PacketLayer.getDSN(message_t* msg) { return getHeader(msg)->dsn; } - inline async command void IEEE154Packet2.setDSN(message_t* msg, uint8_t dsn) + inline async command void IEEE154PacketLayer.setDSN(message_t* msg, uint8_t dsn) { getHeader(msg)->dsn = dsn; } - inline async command uint16_t IEEE154Packet2.getDestPan(message_t* msg) + inline async command uint16_t IEEE154PacketLayer.getDestPan(message_t* msg) { return getHeader(msg)->destpan; } - inline async command void IEEE154Packet2.setDestPan(message_t* msg, uint16_t pan) + inline async command void IEEE154PacketLayer.setDestPan(message_t* msg, uint16_t pan) { getHeader(msg)->destpan = pan; } - inline async command uint16_t IEEE154Packet2.getDestAddr(message_t* msg) + inline async command uint16_t IEEE154PacketLayer.getDestAddr(message_t* msg) { return getHeader(msg)->dest; } - inline async command void IEEE154Packet2.setDestAddr(message_t* msg, uint16_t addr) + inline async command void IEEE154PacketLayer.setDestAddr(message_t* msg, uint16_t addr) { getHeader(msg)->dest = addr; } - inline async command uint16_t IEEE154Packet2.getSrcAddr(message_t* msg) + inline async command uint16_t IEEE154PacketLayer.getSrcAddr(message_t* msg) { return getHeader(msg)->src; } - inline async command void IEEE154Packet2.setSrcAddr(message_t* msg, uint16_t addr) + inline async command void IEEE154PacketLayer.setSrcAddr(message_t* msg, uint16_t addr) { getHeader(msg)->src = addr; } #ifndef TFRAMES_ENABLED - inline async command uint8_t IEEE154Packet2.get6LowPan(message_t* msg) + inline async command uint8_t IEEE154PacketLayer.get6LowPan(message_t* msg) { return getHeader(msg)->network; } - inline async command void IEEE154Packet2.set6LowPan(message_t* msg, uint8_t network) + inline async command void IEEE154PacketLayer.set6LowPan(message_t* msg, uint8_t network) { getHeader(msg)->network = network; } #endif - inline async command am_id_t IEEE154Packet2.getType(message_t* msg) + inline async command am_id_t IEEE154PacketLayer.getType(message_t* msg) { return getHeader(msg)->type; } - inline async command void IEEE154Packet2.setType(message_t* msg, am_id_t type) + inline async command void IEEE154PacketLayer.setType(message_t* msg, am_id_t type) { getHeader(msg)->type = type; } - async command bool IEEE154Packet2.requiresAckWait(message_t* msg) + async command bool IEEE154PacketLayer.requiresAckWait(message_t* msg) { - return call IEEE154Packet2.getAckRequired(msg) - && call IEEE154Packet2.isDataFrame(msg) - && call IEEE154Packet2.getDestAddr(msg) != 0xFFFF; + return call IEEE154PacketLayer.getAckRequired(msg) + && call IEEE154PacketLayer.isDataFrame(msg) + && call IEEE154PacketLayer.getDestAddr(msg) != 0xFFFF; } - async command bool IEEE154Packet2.requiresAckReply(message_t* msg) + async command bool IEEE154PacketLayer.requiresAckReply(message_t* msg) { - return call IEEE154Packet2.getAckRequired(msg) - && call IEEE154Packet2.isDataFrame(msg) - && call IEEE154Packet2.getDestAddr(msg) == call ActiveMessageAddress.amAddress(); + return call IEEE154PacketLayer.getAckRequired(msg) + && call IEEE154PacketLayer.isDataFrame(msg) + && call IEEE154PacketLayer.getDestAddr(msg) == call ActiveMessageAddress.amAddress(); } inline async event void ActiveMessageAddress.changed() @@ -248,22 +248,22 @@ implementation inline command am_addr_t AMPacket.destination(message_t* msg) { - return call IEEE154Packet2.getDestAddr(msg); + return call IEEE154PacketLayer.getDestAddr(msg); } inline command am_addr_t AMPacket.source(message_t* msg) { - return call IEEE154Packet2.getSrcAddr(msg); + return call IEEE154PacketLayer.getSrcAddr(msg); } inline command void AMPacket.setDestination(message_t* msg, am_addr_t addr) { - call IEEE154Packet2.setDestAddr(msg, addr); + call IEEE154PacketLayer.setDestAddr(msg, addr); } inline command void AMPacket.setSource(message_t* msg, am_addr_t addr) { - call IEEE154Packet2.setSrcAddr(msg, addr); + call IEEE154PacketLayer.setSrcAddr(msg, addr); } inline command bool AMPacket.isForMe(message_t* msg) @@ -274,21 +274,21 @@ implementation inline command am_id_t AMPacket.type(message_t* msg) { - return call IEEE154Packet2.getType(msg); + return call IEEE154PacketLayer.getType(msg); } inline command void AMPacket.setType(message_t* msg, am_id_t type) { - call IEEE154Packet2.setType(msg, type); + call IEEE154PacketLayer.setType(msg, type); } inline command am_group_t AMPacket.group(message_t* msg) { - return call IEEE154Packet2.getDestPan(msg); + return call IEEE154PacketLayer.getDestPan(msg); } inline command void AMPacket.setGroup(message_t* msg, am_group_t grp) { - call IEEE154Packet2.setDestPan(msg, grp); + call IEEE154PacketLayer.setDestPan(msg, grp); } } diff --git a/tos/chips/rf2xx/layers/LowPowerListeningDummyC.nc b/tos/chips/rf2xx/layers/LowPowerListeningDummyC.nc new file mode 100644 index 00000000..fab03147 --- /dev/null +++ b/tos/chips/rf2xx/layers/LowPowerListeningDummyC.nc @@ -0,0 +1,50 @@ +/* + * 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 + */ + +configuration LowPowerListeningDummyC +{ + provides + { + interface SplitControl; + interface Send; + interface Receive; + + interface LowPowerListening; + } + uses + { + interface SplitControl as SubControl; + interface Send as SubSend; + interface Receive as SubReceive; + } +} + +implementation +{ + SplitControl = SubControl; + Send = SubSend; + Receive = SubReceive; + + components LowPowerListeningDummyP; + LowPowerListening = LowPowerListeningDummyP; +} diff --git a/tos/chips/rf2xx/layers/DummyLayerP.nc b/tos/chips/rf2xx/layers/LowPowerListeningDummyP.nc similarity index 98% rename from tos/chips/rf2xx/layers/DummyLayerP.nc rename to tos/chips/rf2xx/layers/LowPowerListeningDummyP.nc index 8ce32610..953fc280 100644 --- a/tos/chips/rf2xx/layers/DummyLayerP.nc +++ b/tos/chips/rf2xx/layers/LowPowerListeningDummyP.nc @@ -21,7 +21,7 @@ * Author: Miklos Maroti */ -module DummyLayerP +module LowPowerListeningDummyP { provides interface LowPowerListening; } diff --git a/tos/chips/rf2xx/layers/LowPowerListeningLayer.h b/tos/chips/rf2xx/layers/LowPowerListeningLayer.h new file mode 100644 index 00000000..51ee4ddc --- /dev/null +++ b/tos/chips/rf2xx/layers/LowPowerListeningLayer.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +#ifndef __LOWPOWERLISTENINGLAYER_H__ +#define __LOWPOWERLISTENINGLAYER_H__ + +typedef struct lpl_metadata_t +{ + uint16_t sleepint; +} lpl_metadata_t; + +#endif//__LOWPOWERLISTENINGLAYER_H__ diff --git a/tos/chips/rf2xx/layers/LowPowerListeningLayerC.nc b/tos/chips/rf2xx/layers/LowPowerListeningLayerC.nc index 5cc93f00..0c6898bf 100644 --- a/tos/chips/rf2xx/layers/LowPowerListeningLayerC.nc +++ b/tos/chips/rf2xx/layers/LowPowerListeningLayerC.nc @@ -21,6 +21,8 @@ * Author: Miklos Maroti */ +#include + #warning "*** USING LOW POWER LISTENING LAYER" configuration LowPowerListeningLayerC @@ -39,8 +41,8 @@ configuration LowPowerListeningLayerC interface Send as SubSend; interface Receive as SubReceive; - interface PacketField as PacketSleepInterval; - interface IEEE154Packet2; + interface PacketData as PacketLplMetadata; + interface IEEE154PacketLayer; interface PacketAcknowledgements; } } @@ -57,8 +59,8 @@ implementation SubControl = LowPowerListeningLayerP; SubSend = LowPowerListeningLayerP; SubReceive = LowPowerListeningLayerP; - PacketSleepInterval = LowPowerListeningLayerP; - IEEE154Packet2 = LowPowerListeningLayerP; + PacketLplMetadata = LowPowerListeningLayerP; + IEEE154PacketLayer = LowPowerListeningLayerP; PacketAcknowledgements = LowPowerListeningLayerP; LowPowerListeningLayerP.Timer -> TimerMilliC; diff --git a/tos/chips/rf2xx/layers/LowPowerListeningLayerP.nc b/tos/chips/rf2xx/layers/LowPowerListeningLayerP.nc index fc02621b..22619223 100644 --- a/tos/chips/rf2xx/layers/LowPowerListeningLayerP.nc +++ b/tos/chips/rf2xx/layers/LowPowerListeningLayerP.nc @@ -22,6 +22,7 @@ */ #include +#include module LowPowerListeningLayerP { @@ -40,8 +41,8 @@ module LowPowerListeningLayerP interface Send as SubSend; interface Receive as SubReceive; - interface PacketField as PacketSleepInterval; - interface IEEE154Packet2; + interface PacketData as PacketLplMetadata; + interface IEEE154PacketLayer; interface PacketAcknowledgements; interface Timer; } @@ -77,22 +78,22 @@ implementation { OFF = 0, OFF_SUBSTOP = 1, // must have consecutive indices - OFF_SUBSTOP_DONE = 2, // must have consecutive indices + OFF_SUBSTOP_DONE = 2, // must have consecutive indices OFF_STOP_END = 3, // must have consecutive indices OFF_START_END = 4, - LISTEN_SUBSTART = 5, // must have consecutive indices - LISTEN_SUBSTART_DONE = 6, // must have consecutive indices + LISTEN_SUBSTART = 5, // must have consecutive indices + LISTEN_SUBSTART_DONE = 6, // must have consecutive indices LISTEN_TIMER = 7, // must have consecutive indices - LISTEN = 8, // must have consecutive indices + LISTEN = 8, // must have consecutive indices SLEEP_SUBSTOP = 9, // must have consecutive indices - SLEEP_SUBSTOP_DONE = 10, // must have consecutive indices + SLEEP_SUBSTOP_DONE = 10, // must have consecutive indices SLEEP_TIMER = 11, // must have consecutive indices - SLEEP = 12, // must have consecutive indices + SLEEP = 12, // must have consecutive indices SEND_SUBSTART = 13, // must have consecutive indices - SEND_SUBSTART_DONE = 14, // must have consecutive indices + SEND_SUBSTART_DONE = 14, // must have consecutive indices SEND_TIMER = 15, // must have consecutive indices SEND_SUBSEND= 16, SEND_SUBSEND_DONE = 17, @@ -335,7 +336,7 @@ implementation if( error != SUCCESS || call LowPowerListening.getRxSleepInterval(msg) == 0 || state == SEND_SUBSEND_DONE_LAST - || (call IEEE154Packet2.getAckRequired(msg) && call PacketAcknowledgements.wasAcked(msg)) ) + || (call IEEE154PacketLayer.getAckRequired(msg) && call PacketAcknowledgements.wasAcked(msg)) ) { call Timer.stop(); state = SEND_DONE; @@ -379,7 +380,7 @@ implementation } command void LowPowerListening.setLocalSleepInterval(uint16_t interval) - { + { if( interval < MIN_SLEEP ) interval = 0; else if( interval > MAX_SLEEP ) @@ -396,7 +397,7 @@ implementation } command uint16_t LowPowerListening.getLocalSleepInterval() - { + { return sleepInterval; } @@ -418,26 +419,30 @@ implementation else if( interval > MAX_SLEEP ) interval = MAX_SLEEP; - call PacketSleepInterval.set(msg, interval); + (call PacketLplMetadata.get(msg))->sleepint = interval; } command uint16_t LowPowerListening.getRxSleepInterval(message_t *msg) - { - if( ! call PacketSleepInterval.isSet(msg) ) - return sleepInterval; + { + uint16_t sleepint = (call PacketLplMetadata.get(msg))->sleepint; - return call PacketSleepInterval.get(msg); + return sleepint != 0 ? sleepint : sleepInterval; } command void LowPowerListening.setRxDutyCycle(message_t *msg, uint16_t dutyCycle) - { + { call LowPowerListening.setRxSleepInterval(msg, call LowPowerListening.dutyCycleToSleepInterval(dutyCycle)); } command uint16_t LowPowerListening.getRxDutyCycle(message_t *msg) - { + { return call LowPowerListening.sleepIntervalToDutyCycle( call LowPowerListening.getRxSleepInterval(msg)); } + + async event void PacketLplMetadata.clear(message_t* msg) + { + (call PacketLplMetadata.get(msg))->sleepint = 0; + } } diff --git a/tos/chips/rf2xx/layers/MetadataFlagsLayer.h b/tos/chips/rf2xx/layers/MetadataFlagsLayer.h new file mode 100644 index 00000000..5694d071 --- /dev/null +++ b/tos/chips/rf2xx/layers/MetadataFlagsLayer.h @@ -0,0 +1,33 @@ +/* + * 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 + */ + +#ifndef __METADATAFLAGSLAYER_H__ +#define __METADATAFLAGSLAYER_H__ + +typedef struct flags_metadata_t +{ + // TODO: make sure that we have no more than 8 flags + uint8_t flags; +} flags_metadata_t; + +#endif//__METADATAFLAGSLAYER_H__ diff --git a/tos/chips/rf2xx/layers/MetadataFlagsLayerC.nc b/tos/chips/rf2xx/layers/MetadataFlagsLayerC.nc new file mode 100644 index 00000000..dffafb0b --- /dev/null +++ b/tos/chips/rf2xx/layers/MetadataFlagsLayerC.nc @@ -0,0 +1,73 @@ +/* + * 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 + +module MetadataFlagsLayerC +{ + provides + { + interface PacketFlag[uint8_t bit]; + } + + uses + { + interface PacketData as PacketFlagsMetadata; + } +} + +implementation +{ + async command bool PacketFlag.get[uint8_t bit](message_t* msg) + { + return (call PacketFlagsMetadata.get(msg))->flags & (1<flags |= (1<flags &= ~(1<flags = 0; + } +} diff --git a/tos/chips/rf2xx/layers/PacketLinkLayer.h b/tos/chips/rf2xx/layers/PacketLinkLayer.h index 785e61ec..df518ce1 100644 --- a/tos/chips/rf2xx/layers/PacketLinkLayer.h +++ b/tos/chips/rf2xx/layers/PacketLinkLayer.h @@ -24,10 +24,10 @@ #ifndef __PACKETLINKLAYER_H__ #define __PACKETLINKLAYER_H__ -typedef struct packet_link_metadata_t +typedef struct link_metadata_t { - nx_uint16_t maxRetries; - nx_uint16_t retryDelay; -} packet_link_metadata_t; + uint16_t maxRetries; + uint16_t retryDelay; +} link_metadata_t; #endif//__PACKETLINKLAYER_H__ diff --git a/tos/chips/rf2xx/layers/PacketLinkLayerC.nc b/tos/chips/rf2xx/layers/PacketLinkLayerC.nc index 34ea8911..5701af73 100644 --- a/tos/chips/rf2xx/layers/PacketLinkLayerC.nc +++ b/tos/chips/rf2xx/layers/PacketLinkLayerC.nc @@ -69,21 +69,19 @@ configuration PacketLinkLayerC { uses { interface Send as SubSend; - interface PacketData; + interface PacketData as PacketLinkMetadata; interface PacketAcknowledgements; } } implementation { - components PacketLinkLayerP, - RF230PacketC, - new TimerMilliC() as DelayTimerC; + components PacketLinkLayerP, new TimerMilliC() as DelayTimerC; PacketLink = PacketLinkLayerP; Send = PacketLinkLayerP.Send; SubSend = PacketLinkLayerP.SubSend; PacketAcknowledgements = PacketLinkLayerP; - PacketData = PacketLinkLayerP; - + PacketLinkMetadata = PacketLinkLayerP; + PacketLinkLayerP.DelayTimer -> DelayTimerC; } diff --git a/tos/chips/rf2xx/layers/PacketLinkLayerP.nc b/tos/chips/rf2xx/layers/PacketLinkLayerP.nc index a54e135f..9418770d 100644 --- a/tos/chips/rf2xx/layers/PacketLinkLayerP.nc +++ b/tos/chips/rf2xx/layers/PacketLinkLayerP.nc @@ -69,7 +69,7 @@ module PacketLinkLayerP { interface Send as SubSend; interface PacketAcknowledgements; interface Timer as DelayTimer; - interface PacketData; + interface PacketData as PacketLinkMetadata; } } @@ -99,7 +99,7 @@ implementation { * the message */ command void PacketLink.setRetries(message_t *msg, uint16_t maxRetries) { - (call PacketData.getData(msg))->maxRetries = maxRetries; + (call PacketLinkMetadata.get(msg))->maxRetries = maxRetries; } /** @@ -108,21 +108,21 @@ implementation { * @param retryDelay the delay betweeen retry attempts, in milliseconds */ command void PacketLink.setRetryDelay(message_t *msg, uint16_t retryDelay) { - (call PacketData.getData(msg))->retryDelay = retryDelay; + (call PacketLinkMetadata.get(msg))->retryDelay = retryDelay; } /** * @return the maximum number of retry attempts for this message */ command uint16_t PacketLink.getRetries(message_t *msg) { - return (call PacketData.getData(msg))->maxRetries; + return (call PacketLinkMetadata.get(msg))->maxRetries; } /** * @return the delay between retry attempts in ms for this message */ command uint16_t PacketLink.getRetryDelay(message_t *msg) { - return (call PacketData.getData(msg))->retryDelay; + return (call PacketLinkMetadata.get(msg))->retryDelay; } /** @@ -132,8 +132,8 @@ implementation { return call PacketAcknowledgements.wasAcked(msg); } - async event void PacketData.clear(packet_link_metadata_t* data) { - data->maxRetries = 0; + async event void PacketLinkMetadata.clear(message_t* msg) { + (call PacketLinkMetadata.get(msg))->maxRetries = 0; } /***************** Send Commands ***************/ diff --git a/tos/chips/rf2xx/layers/SoftwareAckConfig.nc b/tos/chips/rf2xx/layers/SoftwareAckConfig.nc index b3c87c73..5f7b8a3f 100755 --- a/tos/chips/rf2xx/layers/SoftwareAckConfig.nc +++ b/tos/chips/rf2xx/layers/SoftwareAckConfig.nc @@ -31,17 +31,18 @@ interface SoftwareAckConfig */ async command uint16_t getAckTimeout(); + /** + * Sets the flag in the message indicating to the receiver whether + * the message should be acknowledged. + */ + async command void setAckRequired(message_t* msg, bool ack); + /** * Returns TRUE if the layer should wait for a software acknowledgement * to be received after this packet was transmitted. */ async command bool requiresAckWait(message_t* msg); - /** - * Sets for the transmitted message whether it was acknowledged or not. - */ - async command void setAckReceived(message_t* msg, bool acked); - /** * Returns TRUE if the received packet is an acknowledgement packet. * The AckedSend layer will filter out all received acknowledgement diff --git a/tos/chips/rf2xx/layers/SoftwareAckLayerC.nc b/tos/chips/rf2xx/layers/SoftwareAckLayerC.nc index 97703e1f..44e2cf06 100755 --- a/tos/chips/rf2xx/layers/SoftwareAckLayerC.nc +++ b/tos/chips/rf2xx/layers/SoftwareAckLayerC.nc @@ -27,6 +27,7 @@ configuration SoftwareAckLayerC { interface RadioSend; interface RadioReceive; + interface PacketAcknowledgements; } uses { @@ -39,13 +40,15 @@ configuration SoftwareAckLayerC implementation { - components SoftwareAckLayerP, RadioAlarmC; + components SoftwareAckLayerP, RadioAlarmC, new MetadataFlagC(); RadioSend = SoftwareAckLayerP; RadioReceive = SoftwareAckLayerP; SubSend = SoftwareAckLayerP; SubReceive = SoftwareAckLayerP; Config = SoftwareAckLayerP; + PacketAcknowledgements = SoftwareAckLayerP; SoftwareAckLayerP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; + SoftwareAckLayerP.AckReceivedFlag -> MetadataFlagC; } diff --git a/tos/chips/rf2xx/layers/SoftwareAckLayerP.nc b/tos/chips/rf2xx/layers/SoftwareAckLayerP.nc index 02ca70de..64324817 100644 --- a/tos/chips/rf2xx/layers/SoftwareAckLayerP.nc +++ b/tos/chips/rf2xx/layers/SoftwareAckLayerP.nc @@ -30,6 +30,7 @@ module SoftwareAckLayerP { interface RadioSend; interface RadioReceive; + interface PacketAcknowledgements; } uses { @@ -38,6 +39,7 @@ module SoftwareAckLayerP interface RadioAlarm; interface SoftwareAckConfig; + interface PacketFlag as AckReceivedFlag; } } @@ -69,7 +71,7 @@ implementation { if( (error = call SubSend.send(msg)) == SUCCESS ) { - call SoftwareAckConfig.setAckReceived(msg, FALSE); + call AckReceivedFlag.clear(msg); state = STATE_DATA_SEND; txMsg = msg; } @@ -136,7 +138,7 @@ implementation ASSERT( !ack || call SoftwareAckConfig.verifyAckPacket(txMsg, msg) ); call RadioAlarm.cancel(); - call SoftwareAckConfig.setAckReceived(txMsg, ack); + call AckReceivedFlag.setValue(txMsg, ack); state = STATE_READY; signal RadioSend.sendDone(SUCCESS); @@ -158,4 +160,27 @@ implementation return signal RadioReceive.receive(msg); } + +/*----------------- PacketAcknowledgements -----------------*/ + + async command error_t PacketAcknowledgements.requestAck(message_t* msg) + { + call SoftwareAckConfig.setAckRequired(msg, TRUE); + + return SUCCESS; + } + + async command error_t PacketAcknowledgements.noAck(message_t* msg) + { + call SoftwareAckConfig.setAckRequired(msg, FALSE); + + return SUCCESS; + } + + async command bool PacketAcknowledgements.wasAcked(message_t* msg) + { + return call AckReceivedFlag.get(msg); + } + + } diff --git a/tos/chips/rf2xx/layers/TimeStampingLayer.h b/tos/chips/rf2xx/layers/TimeStampingLayer.h new file mode 100644 index 00000000..dc0a43c8 --- /dev/null +++ b/tos/chips/rf2xx/layers/TimeStampingLayer.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +#ifndef __TIMESTAMPINGLAYER_H__ +#define __TIMESTAMPINGLAYER_H__ + +typedef struct timestamp_metadata_t +{ + uint32_t timestamp; +} timestamp_metadata_t; + +#endif//__TIMESTAMPINGLAYER_H__ diff --git a/tos/chips/rf2xx/layers/TimeStampingLayerC.nc b/tos/chips/rf2xx/layers/TimeStampingLayerC.nc new file mode 100644 index 00000000..a8aadeac --- /dev/null +++ b/tos/chips/rf2xx/layers/TimeStampingLayerC.nc @@ -0,0 +1,52 @@ +/* + * 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 TimeStampingLayerC +{ + provides + { + interface PacketTimeStamp as PacketTimeStampMilli; + interface PacketTimeStamp as PacketTimeStampRadio; + } + + uses + { + interface LocalTime as LocalTimeRadio; + interface PacketData as PacketTimeStampMetadata; + } +} + +implementation +{ + components TimeStampingLayerP, LocalTimeMilliC; + + PacketTimeStampMilli = TimeStampingLayerP; + PacketTimeStampRadio = TimeStampingLayerP; + PacketTimeStampMetadata = TimeStampingLayerP.PacketTimeStampMetadata; + + LocalTimeRadio = TimeStampingLayerP; + TimeStampingLayerP.LocalTimeMilli -> LocalTimeMilliC; + + components new MetadataFlagC() as TimeStampFlagC; + TimeStampingLayerP.TimeStampFlag -> TimeStampFlagC; +} diff --git a/tos/chips/rf2xx/layers/TimeStampingLayerP.nc b/tos/chips/rf2xx/layers/TimeStampingLayerP.nc new file mode 100644 index 00000000..33b14b8e --- /dev/null +++ b/tos/chips/rf2xx/layers/TimeStampingLayerP.nc @@ -0,0 +1,96 @@ +/* + * 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 + +module TimeStampingLayerP +{ + provides + { + interface PacketTimeStamp as PacketTimeStampMilli; + interface PacketTimeStamp as PacketTimeStampRadio; + } + + uses + { + interface PacketFlag as TimeStampFlag; + + interface LocalTime as LocalTimeRadio; + interface LocalTime as LocalTimeMilli; + + interface PacketData as PacketTimeStampMetadata; + } +} + +implementation +{ + async command bool PacketTimeStampRadio.isValid(message_t* msg) + { + return call TimeStampFlag.get(msg); + } + + async command uint32_t PacketTimeStampRadio.timestamp(message_t* msg) + { + return (call PacketTimeStampMetadata.get(msg))->timestamp; + } + + async command void PacketTimeStampRadio.clear(message_t* msg) + { + call TimeStampFlag.clear(msg); + } + + async command void PacketTimeStampRadio.set(message_t* msg, uint32_t value) + { + call TimeStampFlag.set(msg); + (call PacketTimeStampMetadata.get(msg))->timestamp = value; + } + + async event void PacketTimeStampMetadata.clear(message_t* msg) + { + } + + async command bool PacketTimeStampMilli.isValid(message_t* msg) + { + return call PacketTimeStampRadio.isValid(msg); + } + + async command uint32_t PacketTimeStampMilli.timestamp(message_t* msg) + { + int32_t offset = call PacketTimeStampRadio.timestamp(msg) - call LocalTimeRadio.get(); + + return (offset >> RADIO_ALARM_MILLI_EXP) + call LocalTimeMilli.get(); + } + + async command void PacketTimeStampMilli.clear(message_t* msg) + { + call PacketTimeStampRadio.clear(msg); + } + + async command void PacketTimeStampMilli.set(message_t* msg, uint32_t value) + { + int32_t offset = (value - call LocalTimeMilli.get()) << RADIO_ALARM_MILLI_EXP; + + call PacketTimeStampRadio.set(msg, offset + call LocalTimeRadio.get()); + } +} diff --git a/tos/chips/rf2xx/rf212/RF212Packet.h b/tos/chips/rf2xx/rf212/RF212ActiveMessage.h similarity index 67% rename from tos/chips/rf2xx/rf212/RF212Packet.h rename to tos/chips/rf2xx/rf212/RF212ActiveMessage.h index ed378759..e13bba98 100644 --- a/tos/chips/rf2xx/rf212/RF212Packet.h +++ b/tos/chips/rf2xx/rf212/RF212ActiveMessage.h @@ -21,10 +21,14 @@ * Author: Miklos Maroti */ -#ifndef __RF212PACKET_H__ -#define __RF212PACKET_H__ - -#include +#ifndef __RF212ACTIVEMESSAGE_H__ +#define __RF212ACTIVEMESSAGE_H__ + +#include +#include +#include +#include +#include #include typedef ieee154_header_t rf212packet_header_t; @@ -36,28 +40,15 @@ typedef nx_struct rf212packet_footer_t typedef struct rf212packet_metadata_t { - uint8_t flags; - uint8_t lqi; - uint8_t power; // shared between TXPOWER and RSSI + flags_metadata_t flags; + rf212_metadata_t rf212; + timestamp_metadata_t timestamp; #ifdef LOW_POWER_LISTENING - uint16_t lpl_sleepint; + lpl_metadata_t lpl; #endif #ifdef PACKET_LINK - packet_link_metadata_t packet_link; + link_metadata_t link; #endif - uint32_t timestamp; } rf212packet_metadata_t; -enum rf212packet_metadata_flags -{ - RF212PACKET_WAS_ACKED = 0x01, // PacketAcknowledgements - RF212PACKET_TIMESTAMP = 0x02, // PacketTimeStamp - RF212PACKET_TXPOWER = 0x04, // PacketTransmitPower - RF212PACKET_RSSI = 0x08, // PacketRSSI - RF212PACKET_TIMESYNC = 0x10, // PacketTimeSync (update timesync_footer) - RF212PACKET_LPL_SLEEPINT = 0x20, // LowPowerListening - - RF212PACKET_CLEAR_METADATA = 0x00, -}; - -#endif//__RF212PACKET_H__ +#endif//__RF212ACTIVEMESSAGE_H__ diff --git a/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc b/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc index 65eba63c..bd5fe3c0 100644 --- a/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc +++ b/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc @@ -36,8 +36,6 @@ configuration RF212ActiveMessageC interface Packet; interface AMPacket; interface PacketAcknowledgements; - - // we provide a dummy LowPowerListening interface if LOW_POWER_LISTENING is not defined interface LowPowerListening; #ifdef PACKET_LINK @@ -50,6 +48,7 @@ configuration RF212ActiveMessageC interface PacketField as PacketTransmitPower; interface PacketField as PacketRSSI; + interface LocalTime as LocalTimeRadio; interface PacketTimeStamp as PacketTimeStampRadio; interface PacketTimeStamp as PacketTimeStampMilli; } @@ -57,112 +56,142 @@ configuration RF212ActiveMessageC implementation { - components RF212ActiveMessageP, RF212PacketC, IEEE154Packet2C, RadioAlarmC; + components RF212ActiveMessageP, IEEE154PacketLayerC, RadioAlarmC; #ifdef RADIO_DEBUG components AssertC; #endif - RF212ActiveMessageP.IEEE154Packet2 -> IEEE154Packet2C; - RF212ActiveMessageP.Packet -> RF212PacketC; + RF212ActiveMessageP.IEEE154PacketLayer -> IEEE154PacketLayerC; RF212ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; + RF212ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC; - Packet = RF212PacketC; - AMPacket = RF212PacketC; - PacketAcknowledgements = RF212PacketC; - PacketLinkQuality = RF212PacketC.PacketLinkQuality; - PacketTransmitPower = RF212PacketC.PacketTransmitPower; - PacketRSSI = RF212PacketC.PacketRSSI; - PacketTimeStampRadio = RF212PacketC; - PacketTimeStampMilli = RF212PacketC; - LowPowerListening = LowPowerListeningLayerC; - RadioChannel = MessageBufferLayerC; + Packet = RF212ActiveMessageP; + +// -------- ActiveMessage components ActiveMessageLayerC; + ActiveMessageLayerC.Config -> RF212ActiveMessageP; + ActiveMessageLayerC.AMPacket -> IEEE154PacketLayerC; + ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC; + ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC; + AMSend = ActiveMessageLayerC; + Receive = ActiveMessageLayerC.Receive; + Snoop = ActiveMessageLayerC.Snoop; + AMPacket = IEEE154PacketLayerC; + +// -------- IEEE154Network + #ifdef TFRAMES_ENABLED components new DummyLayerC() as IEEE154NetworkLayerC; #else components IEEE154NetworkLayerC; #endif + IEEE154NetworkLayerC.SubSend -> UniqueLayerC; + IEEE154NetworkLayerC.SubReceive -> LowPowerListeningLayerC; + +// -------- UniqueLayer Send part (wired twice) + + components UniqueLayerC; + UniqueLayerC.Config -> RF212ActiveMessageP; + UniqueLayerC.SubSend -> LowPowerListeningLayerC; + +// -------- Low Power Listening #ifdef LOW_POWER_LISTENING components LowPowerListeningLayerC; - LowPowerListeningLayerC.PacketSleepInterval -> RF230PacketC; - LowPowerListeningLayerC.IEEE154Packet2 -> IEEE154Packet2C; - LowPowerListeningLayerC.PacketAcknowledgements -> RF230PacketC; + LowPowerListeningLayerC.PacketLplMetadata -> RF212ActiveMessageP; + LowPowerListeningLayerC.IEEE154PacketLayer -> IEEE154PacketLayerC; + LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC; #else - components new DummyLayerC() as LowPowerListeningLayerC; + components LowPowerListeningDummyC as LowPowerListeningLayerC; #endif + LowPowerListeningLayerC.SubControl -> MessageBufferLayerC; + LowPowerListeningLayerC.SubSend -> PacketLinkLayerC; + LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC; + SplitControl = LowPowerListeningLayerC; + LowPowerListening = LowPowerListeningLayerC; + +// -------- Packet Link #ifdef PACKET_LINK components PacketLinkLayerC; PacketLink = PacketLinkLayerC; - PacketLinkLayerC.PacketData -> RF230PacketC; - PacketLinkLayerC.PacketAcknowledgements -> RF230PacketC; + PacketLinkLayerC.PacketLinkMetadata -> RF212ActiveMessageP; + PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC; #else components new DummyLayerC() as PacketLinkLayerC; #endif - - components MessageBufferLayerC; - components UniqueLayerC; - components TrafficMonitorLayerC; - -#ifdef SLOTTED_MAC - components SlottedCollisionLayerC as CollisionAvoidanceLayerC; -#else - components RandomCollisionLayerC as CollisionAvoidanceLayerC; -#endif - - components SoftwareAckLayerC; - components new DummyLayerC() as CsmaLayerC; - components RF212DriverLayerC; - - SplitControl = LowPowerListeningLayerC; - AMSend = ActiveMessageLayerC; - Receive = ActiveMessageLayerC.Receive; - Snoop = ActiveMessageLayerC.Snoop; - - ActiveMessageLayerC.Config -> RF212ActiveMessageP; - ActiveMessageLayerC.AMPacket -> IEEE154Packet2C; - ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC; - ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC; - - IEEE154NetworkLayerC.SubSend -> UniqueLayerC; - IEEE154NetworkLayerC.SubReceive -> LowPowerListeningLayerC; - - // the UniqueLayer is wired at two points - UniqueLayerC.Config -> RF212ActiveMessageP; - UniqueLayerC.SubSend -> LowPowerListeningLayerC; - - LowPowerListeningLayerC.SubControl -> MessageBufferLayerC; - LowPowerListeningLayerC.SubSend -> PacketLinkLayerC; - LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC; - PacketLinkLayerC.SubSend -> MessageBufferLayerC; - MessageBufferLayerC.Packet -> RF212PacketC; +// -------- MessageBuffer + + components MessageBufferLayerC; + MessageBufferLayerC.Packet -> RF212ActiveMessageP; MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC; MessageBufferLayerC.RadioReceive -> UniqueLayerC; MessageBufferLayerC.RadioState -> TrafficMonitorLayerC; + RadioChannel = MessageBufferLayerC; + +// -------- UniqueLayer receive part (wired twice) UniqueLayerC.SubReceive -> TrafficMonitorLayerC; +// -------- Traffic Monitor + + components TrafficMonitorLayerC; TrafficMonitorLayerC.Config -> RF212ActiveMessageP; TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC; TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC; TrafficMonitorLayerC.SubState -> RF212DriverLayerC; +// -------- CollisionAvoidance + +#ifdef SLOTTED_MAC + components SlottedCollisionLayerC as CollisionAvoidanceLayerC; +#else + components RandomCollisionLayerC as CollisionAvoidanceLayerC; +#endif CollisionAvoidanceLayerC.Config -> RF212ActiveMessageP; CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC; CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC; +// -------- SoftwareAcknowledgement + + components SoftwareAckLayerC; SoftwareAckLayerC.Config -> RF212ActiveMessageP; SoftwareAckLayerC.SubSend -> CsmaLayerC; SoftwareAckLayerC.SubReceive -> RF212DriverLayerC; + PacketAcknowledgements = SoftwareAckLayerC; + +// -------- Carrier Sense + components new DummyLayerC() as CsmaLayerC; CsmaLayerC.Config -> RF212ActiveMessageP; CsmaLayerC -> RF212DriverLayerC.RadioSend; CsmaLayerC -> RF212DriverLayerC.RadioCCA; +// -------- RF212 Driver + + components RF212DriverLayerC; + RF212DriverLayerC.PacketRF212Metadata -> RF212ActiveMessageP; RF212DriverLayerC.RF212DriverConfig -> RF212ActiveMessageP; + RF212DriverLayerC.PacketTimeStamp -> TimeStampingLayerC; + PacketTransmitPower = RF212DriverLayerC.PacketTransmitPower; + PacketLinkQuality = RF212DriverLayerC.PacketLinkQuality; + PacketRSSI = RF212DriverLayerC.PacketRSSI; + LocalTimeRadio = RF212DriverLayerC; + +// -------- MetadataFlags + + components MetadataFlagsLayerC; + MetadataFlagsLayerC.PacketFlagsMetadata -> RF212ActiveMessageP; + +// -------- TimeStamping + + components TimeStampingLayerC; + TimeStampingLayerC.LocalTimeRadio -> RF212DriverLayerC; + TimeStampingLayerC.PacketTimeStampMetadata -> RF212ActiveMessageP; + PacketTimeStampRadio = TimeStampingLayerC; + PacketTimeStampMilli = TimeStampingLayerC; } diff --git a/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc b/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc index f7332b29..e9f4cfcb 100644 --- a/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc +++ b/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc @@ -21,7 +21,7 @@ * Author: Miklos Maroti */ -#include +#include #include #include @@ -38,13 +38,27 @@ module RF212ActiveMessageP interface SlottedCollisionConfig; interface ActiveMessageConfig; interface DummyConfig; + + interface Packet; + + interface PacketData as PacketFlagsMetadata; + interface PacketData as PacketRF212Metadata; + interface PacketData as PacketTimeStampMetadata; + +#ifdef LOW_POWER_LISTENING + interface PacketData as PacketLplMetadata; +#endif +#ifdef PACKET_LINK + interface PacketData as PacketLinkMetadata; +#endif } uses { - interface IEEE154Packet2; - interface Packet; + interface IEEE154PacketLayer; interface RadioAlarm; + + interface PacketTimeStamp; } } @@ -54,22 +68,17 @@ implementation async command uint8_t RF212DriverConfig.getLength(message_t* msg) { - return call IEEE154Packet2.getLength(msg); + return call IEEE154PacketLayer.getLength(msg); } async command void RF212DriverConfig.setLength(message_t* msg, uint8_t len) { - call IEEE154Packet2.setLength(msg, len); + call IEEE154PacketLayer.setLength(msg, len); } async command uint8_t* RF212DriverConfig.getPayload(message_t* msg) { - return ((uint8_t*)(call IEEE154Packet2.getHeader(msg))) + 1; - } - - inline rf212packet_metadata_t* getMeta(message_t* msg) - { - return (rf212packet_metadata_t*)(msg->metadata); + return ((uint8_t*)(call IEEE154PacketLayer.getHeader(msg))) + 1; } async command uint8_t RF212DriverConfig.getHeaderLength() @@ -86,42 +95,39 @@ implementation async command bool RF212DriverConfig.requiresRssiCca(message_t* msg) { - return call IEEE154Packet2.isDataFrame(msg); + return call IEEE154PacketLayer.isDataFrame(msg); } /*----------------- SoftwareAckConfig -----------------*/ async command bool SoftwareAckConfig.requiresAckWait(message_t* msg) { - return call IEEE154Packet2.requiresAckWait(msg); + return call IEEE154PacketLayer.requiresAckWait(msg); } async command bool SoftwareAckConfig.isAckPacket(message_t* msg) { - return call IEEE154Packet2.isAckFrame(msg); + return call IEEE154PacketLayer.isAckFrame(msg); } async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack) { - return call IEEE154Packet2.verifyAckReply(data, ack); + return call IEEE154PacketLayer.verifyAckReply(data, ack); } - async command bool SoftwareAckConfig.requiresAckReply(message_t* msg) + async command void SoftwareAckConfig.setAckRequired(message_t* msg, bool ack) { - return call IEEE154Packet2.requiresAckReply(msg); + call IEEE154PacketLayer.setAckRequired(msg, ack); } - async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack) + async command bool SoftwareAckConfig.requiresAckReply(message_t* msg) { - call IEEE154Packet2.createAckReply(data, ack); + return call IEEE154PacketLayer.requiresAckReply(msg); } - async command void SoftwareAckConfig.setAckReceived(message_t* msg, bool acked) + async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack) { - if( acked ) - getMeta(msg)->flags |= RF212PACKET_WAS_ACKED; - else - getMeta(msg)->flags &= ~RF212PACKET_WAS_ACKED; + call IEEE154PacketLayer.createAckReply(data, ack); } async command uint16_t SoftwareAckConfig.getAckTimeout() @@ -138,17 +144,17 @@ implementation async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg) { - return call IEEE154Packet2.getDSN(msg); + return call IEEE154PacketLayer.getDSN(msg); } async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn) { - call IEEE154Packet2.setDSN(msg, dsn); + call IEEE154PacketLayer.setDSN(msg, dsn); } async command am_addr_t UniqueConfig.getSender(message_t* msg) { - return call IEEE154Packet2.getSrcAddr(msg); + return call IEEE154PacketLayer.getSrcAddr(msg); } tasklet_async command void UniqueConfig.reportChannelError() @@ -161,7 +167,7 @@ implementation command error_t ActiveMessageConfig.checkPacket(message_t* msg) { // the user forgot to call clear, we should return EINVAL - if( ! call IEEE154Packet2.isDataFrame(msg) ) + if( ! call IEEE154PacketLayer.isDataFrame(msg) ) call Packet.clear(msg); return SUCCESS; @@ -171,7 +177,7 @@ implementation async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg) { - return call IEEE154Packet2.isDataFrame(msg); + return call IEEE154PacketLayer.isDataFrame(msg); } /*----------------- TrafficMonitorConfig -----------------*/ @@ -196,13 +202,13 @@ implementation * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation */ - uint8_t len = call IEEE154Packet2.getLength(msg); - return call IEEE154Packet2.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; + uint8_t len = call IEEE154PacketLayer.getLength(msg); + return call IEEE154PacketLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; } async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg) { - return call IEEE154Packet2.getSrcAddr(msg); + return call IEEE154PacketLayer.getSrcAddr(msg); } tasklet_async command void TrafficMonitorConfig.timerTick() @@ -244,7 +250,7 @@ implementation time = call RadioAlarm.getNow(); // estimated response time (download the message, etc) is 5-8 bytes - if( call IEEE154Packet2.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); @@ -269,13 +275,13 @@ implementation async command uint16_t SlottedCollisionConfig.getTransmitTime(message_t* msg) { // TODO: check if the timestamp is correct - return getMeta(msg)->timestamp; + return call PacketTimeStamp.timestamp(msg); } async command uint16_t SlottedCollisionConfig.getCollisionWindowStart(message_t* msg) { // the preamble (4 bytes), SFD (1 byte), plus two extra for safety - return getMeta(msg)->timestamp - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC); + return (call PacketTimeStamp.timestamp(msg)) - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC); } async command uint16_t SlottedCollisionConfig.getCollisionWindowLength(message_t* msg) @@ -290,4 +296,86 @@ implementation async command void DummyConfig.nothing() { } + +/*----------------- Metadata -----------------*/ + + inline rf212packet_metadata_t* getMeta(message_t* msg) + { + return (rf212packet_metadata_t*)(msg->metadata); + } + + async command flags_metadata_t* PacketFlagsMetadata.get(message_t* msg) + { + return &(getMeta(msg)->flags); + } + + async command rf212_metadata_t* PacketRF212Metadata.get(message_t* msg) + { + return &(getMeta(msg)->rf212); + } + + async command timestamp_metadata_t* PacketTimeStampMetadata.get(message_t* msg) + { + return &(getMeta(msg)->timestamp); + } + +#ifdef LOW_POWER_LISTENING + async command lpl_metadata_t* PacketLplMetadata.get(message_t* msg) + { + return &(getMeta(msg)->lpl); + } +#endif + +#ifdef PACKET_LINK + async command link_metadata_t* PacketLinkMetadata.get(message_t* msg) + { + return &(getMeta(msg)->link); + } +#endif + +/*----------------- Packet -----------------*/ + + enum + { + PACKET_LENGTH_INCREASE = + sizeof(rf212packet_header_t) - 1 // the 8-bit length field is not counted + + sizeof(ieee154_footer_t), // the CRC is not stored in memory + }; + + command void Packet.clear(message_t* msg) + { + signal PacketFlagsMetadata.clear(msg); + signal PacketRF212Metadata.clear(msg); + signal PacketTimeStampMetadata.clear(msg); +#ifdef LOW_POWER_LISTENING + signal PacketLplMetadata.clear(msg); +#endif +#ifdef PACKET_LINK + signal PacketLinkMetadata.clear(msg); +#endif + call IEEE154PacketLayer.createDataFrame(msg); + } + + inline command void Packet.setPayloadLength(message_t* msg, uint8_t len) + { + call IEEE154PacketLayer.setLength(msg, len + PACKET_LENGTH_INCREASE); + } + + inline command uint8_t Packet.payloadLength(message_t* msg) + { + return call IEEE154PacketLayer.getLength(msg) - PACKET_LENGTH_INCREASE; + } + + inline command uint8_t Packet.maxPayloadLength() + { + return TOSH_DATA_LENGTH; + } + + command void* Packet.getPayload(message_t* msg, uint8_t len) + { + if( len > TOSH_DATA_LENGTH ) + return NULL; + + return msg->data; + } } diff --git a/tos/chips/rf2xx/rf212/RF212.h b/tos/chips/rf2xx/rf212/RF212DriverLayer.h similarity index 95% rename from tos/chips/rf2xx/rf212/RF212.h rename to tos/chips/rf2xx/rf212/RF212DriverLayer.h index 7afb78f6..0224247f 100644 --- a/tos/chips/rf2xx/rf212/RF212.h +++ b/tos/chips/rf2xx/rf212/RF212DriverLayer.h @@ -21,8 +21,18 @@ * Author: Miklos Maroti */ -#ifndef __RF212_H__ -#define __RF212_H__ +#ifndef __RF212DRIVERLAYER_H__ +#define __RF212DRIVERLAYER_H__ + +typedef struct rf212_metadata_t +{ + uint8_t lqi; + union + { + uint8_t power; + uint8_t rssi; + }; +} rf212_metadata_t; enum rf212_registers_enum { @@ -159,4 +169,4 @@ enum rf212_spi_command_enums RF212_CMD_SRAM_WRITE = 0x40, }; -#endif//__RF212_H__ +#endif//__RF212DRIVERLAYER_H__ diff --git a/tos/chips/rf2xx/rf212/RF212DriverLayerC.nc b/tos/chips/rf2xx/rf212/RF212DriverLayerC.nc index d847e6fe..5197b694 100644 --- a/tos/chips/rf2xx/rf212/RF212DriverLayerC.nc +++ b/tos/chips/rf2xx/rf212/RF212DriverLayerC.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,6 +21,9 @@ * Author: Miklos Maroti */ +#include +#include + configuration RF212DriverLayerC { provides @@ -29,28 +32,53 @@ configuration RF212DriverLayerC interface RadioSend; interface RadioReceive; interface RadioCCA; + + interface PacketField as PacketTransmitPower; + interface PacketField as PacketRSSI; + interface PacketField as PacketTimeSyncOffset; + interface PacketField as PacketLinkQuality; + + interface LocalTime as LocalTimeRadio; } - uses interface RF212DriverConfig; + uses + { + interface RF212DriverConfig; + interface PacketTimeStamp; + interface PacketData as PacketRF212Metadata; + } } implementation { - components RF212DriverLayerP, HplRF212C, BusyWaitMicroC, TaskletC, MainC, RadioAlarmC, RF212PacketC, LocalTimeMicroC as LocalTimeRadioC; + components RF212DriverLayerP, HplRF212C, BusyWaitMicroC, TaskletC, MainC, RadioAlarmC; RadioState = RF212DriverLayerP; RadioSend = RF212DriverLayerP; RadioReceive = RF212DriverLayerP; RadioCCA = RF212DriverLayerP; + LocalTimeRadio = HplRF212C; + RF212DriverConfig = RF212DriverLayerP; + PacketRF212Metadata = RF212DriverLayerP; + + PacketTransmitPower = RF212DriverLayerP.PacketTransmitPower; + components new MetadataFlagC() as TransmitPowerFlagC; + RF212DriverLayerP.TransmitPowerFlag -> TransmitPowerFlagC; + + PacketRSSI = RF212DriverLayerP.PacketRSSI; + components new MetadataFlagC() as RSSIFlagC; + RF212DriverLayerP.RSSIFlag -> RSSIFlagC; + + PacketTimeSyncOffset = RF212DriverLayerP.PacketTimeSyncOffset; + components new MetadataFlagC() as TimeSyncFlagC; + RF212DriverLayerP.TimeSyncFlag -> TimeSyncFlagC; + + PacketLinkQuality = RF212DriverLayerP.PacketLinkQuality; + PacketTimeStamp = RF212DriverLayerP.PacketTimeStamp; - RF212DriverLayerP.PacketLinkQuality -> RF212PacketC.PacketLinkQuality; - RF212DriverLayerP.PacketTransmitPower -> RF212PacketC.PacketTransmitPower; - RF212DriverLayerP.PacketRSSI -> RF212PacketC.PacketRSSI; - RF212DriverLayerP.PacketTimeSyncOffset -> RF212PacketC.PacketTimeSyncOffset; - RF212DriverLayerP.PacketTimeStamp -> RF212PacketC; - RF212DriverLayerP.LocalTime -> LocalTimeRadioC; + RF212DriverLayerP.LocalTime -> HplRF212C; RF212DriverLayerP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; RadioAlarmC.Alarm -> HplRF212C.Alarm; diff --git a/tos/chips/rf2xx/rf212/RF212DriverLayerP.nc b/tos/chips/rf2xx/rf212/RF212DriverLayerP.nc index 2a9d35a3..6950dd6f 100644 --- a/tos/chips/rf2xx/rf212/RF212DriverLayerP.nc +++ b/tos/chips/rf2xx/rf212/RF212DriverLayerP.nc @@ -21,7 +21,7 @@ * Author: Miklos Maroti */ -#include +#include #include #include #include @@ -38,6 +38,11 @@ module RF212DriverLayerP interface RadioSend; interface RadioReceive; interface RadioCCA; + + interface PacketField as PacketTransmitPower; + interface PacketField as PacketRSSI; + interface PacketField as PacketTimeSyncOffset; + interface PacketField as PacketLinkQuality; } uses @@ -53,16 +58,17 @@ module RF212DriverLayerP interface GpioCapture as IRQ; interface BusyWait; + interface LocalTime; - interface PacketField as PacketLinkQuality; - interface PacketField as PacketTransmitPower; - interface PacketField as PacketRSSI; - interface PacketField as PacketTimeSyncOffset; + interface RF212DriverConfig; + + interface PacketData as PacketRF212Metadata; + interface PacketFlag as TransmitPowerFlag; + interface PacketFlag as RSSIFlag; + interface PacketFlag as TimeSyncFlag; interface PacketTimeStamp; - interface LocalTime; - interface RF212DriverConfig; interface Tasklet; interface RadioAlarm; @@ -548,7 +554,7 @@ implementation inline void downloadMessage() { uint8_t length; - uint8_t crc; + uint8_t crc = 0; call SELN.clr(); call FastSpiByte.write(RF212_CMD_FRAME_READ); @@ -608,7 +614,7 @@ implementation call DiagMsg.str("rx"); call DiagMsg.uint32(call PacketTimeStamp.isValid(rxMsg) ? call PacketTimeStamp.timestamp(rxMsg) : 0); call DiagMsg.uint16(call RadioAlarm.getNow()); - call DiagMsg.uint8(crc != 0); + call DiagMsg.uint8(crc == 0); call DiagMsg.uint8(length); call DiagMsg.hex8s(call RF212DriverConfig.getPayload(rxMsg), length - 2); call DiagMsg.send(); @@ -816,4 +822,112 @@ implementation if( cmd == CMD_NONE ) call SpiResource.release(); } + +/*----------------- PACKET -----------------*/ + + async event void PacketRF212Metadata.clear(message_t* msg) + { + } + +// --- TransmitPower + + async command bool PacketTransmitPower.isSet(message_t* msg) + { + return call TransmitPowerFlag.get(msg); + } + + async command uint8_t PacketTransmitPower.get(message_t* msg) + { + return (call PacketRF212Metadata.get(msg))->power; + } + + async command void PacketTransmitPower.clear(message_t* msg) + { + call TransmitPowerFlag.clear(msg); + } + + async command void PacketTransmitPower.set(message_t* msg, uint8_t value) + { + call TransmitPowerFlag.set(msg); + (call PacketRF212Metadata.get(msg))->power = value; + } + +// --- RSSI + + async command bool PacketRSSI.isSet(message_t* msg) + { + return call RSSIFlag.get(msg); + } + + async command uint8_t PacketRSSI.get(message_t* msg) + { + return (call PacketRF212Metadata.get(msg))->rssi; + } + + async command void PacketRSSI.clear(message_t* msg) + { + call RSSIFlag.clear(msg); + } + + async command void PacketRSSI.set(message_t* msg, uint8_t value) + { + // just to be safe if the user fails to clear the packet + call TransmitPowerFlag.clear(msg); + + call RSSIFlag.set(msg); + (call PacketRF212Metadata.get(msg))->rssi = value; + } + +// --- TimeSyncOffset + + enum + { + PACKET_LENGTH_INCREASE = + sizeof(rf212packet_header_t) - 1 // the 8-bit length field is not counted + + sizeof(ieee154_footer_t), // the CRC is not stored in memory + }; + + async command bool PacketTimeSyncOffset.isSet(message_t* msg) + { + return call TimeSyncFlag.get(msg); + } + + async command uint8_t PacketTimeSyncOffset.get(message_t* msg) + { + return call RF212DriverConfig.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t); + } + + async command void PacketTimeSyncOffset.clear(message_t* msg) + { + call TimeSyncFlag.clear(msg); + } + + async command void PacketTimeSyncOffset.set(message_t* msg, uint8_t value) + { + // we do not store the value, the time sync field is always the last 4 bytes + ASSERT( call RF212DriverConfig.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t) == value ); + + call TimeSyncFlag.set(msg); + } + +// --- LinkQuality + + async command bool PacketLinkQuality.isSet(message_t* msg) + { + return TRUE; + } + + async command uint8_t PacketLinkQuality.get(message_t* msg) + { + return (call PacketRF212Metadata.get(msg))->lqi; + } + + async command void PacketLinkQuality.clear(message_t* msg) + { + } + + async command void PacketLinkQuality.set(message_t* msg, uint8_t value) + { + (call PacketRF212Metadata.get(msg))->lqi = value; + } } diff --git a/tos/chips/rf2xx/rf212/RF212PacketC.nc b/tos/chips/rf2xx/rf212/RF212PacketC.nc deleted file mode 100644 index 89f82459..00000000 --- a/tos/chips/rf2xx/rf212/RF212PacketC.nc +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2007, Vanderbilt University - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT - * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Author: Miklos Maroti - */ - -configuration RF212PacketC -{ - provides - { - interface Packet; - interface AMPacket; - interface PacketAcknowledgements; - interface PacketField as PacketLinkQuality; - interface PacketField as PacketTransmitPower; - interface PacketField as PacketRSSI; - interface PacketField as PacketSleepInterval; - interface PacketField as PacketTimeSyncOffset; - - interface PacketTimeStamp as PacketTimeStampRadio; - interface PacketTimeStamp as PacketTimeStampMilli; -#ifdef PACKET_LINK - interface PacketData as PaketLinkMetadata; -#endif - } -} - -implementation -{ - components RF212PacketP, IEEE154Packet2C, LocalTimeMicroC, LocalTimeMilliC; - - RF212PacketP.IEEE154Packet2 -> IEEE154Packet2C; - RF212PacketP.LocalTimeRadio -> LocalTimeMicroC; - RF212PacketP.LocalTimeMilli -> LocalTimeMilliC; - - Packet = RF212PacketP; - AMPacket = IEEE154Packet2C; - - PacketAcknowledgements = RF212PacketP; - PacketLinkQuality = RF212PacketP.PacketLinkQuality; - PacketTransmitPower = RF212PacketP.PacketTransmitPower; - PacketRSSI = RF212PacketP.PacketRSSI; - PacketSleepInterval = RF212PacketP.PacketSleepInterval; - PacketTimeSyncOffset = RF212PacketP.PacketTimeSyncOffset; - - PacketTimeStampRadio = RF212PacketP; - PacketTimeStampMilli = RF212PacketP; - -#ifdef PACKET_LINK - PaketLinkMetadata = RF212PacketP; -#endif -} diff --git a/tos/chips/rf2xx/rf212/RF212PacketP.nc b/tos/chips/rf2xx/rf212/RF212PacketP.nc deleted file mode 100644 index 16581682..00000000 --- a/tos/chips/rf2xx/rf212/RF212PacketP.nc +++ /dev/null @@ -1,305 +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 -#include -#include - -module RF212PacketP -{ - provides - { - interface PacketAcknowledgements; - interface Packet; - interface PacketField as PacketLinkQuality; - interface PacketField as PacketTransmitPower; - interface PacketField as PacketRSSI; - interface PacketField as PacketSleepInterval; - interface PacketField as PacketTimeSyncOffset; - - interface PacketTimeStamp as PacketTimeStampRadio; - interface PacketTimeStamp as PacketTimeStampMilli; - -#ifdef PACKET_LINK - interface PacketData as PacketLinkMetadata; -#endif - } - - uses - { - interface IEEE154Packet2; - - interface LocalTime as LocalTimeRadio; - interface LocalTime as LocalTimeMilli; - } -} - -implementation -{ - enum - { - PACKET_LENGTH_INCREASE = - sizeof(rf212packet_header_t) - 1 // the 8-bit length field is not counted - + sizeof(ieee154_footer_t), // the CRC is not stored in memory - }; - - inline rf212packet_metadata_t* getMeta(message_t* msg) - { - return (rf212packet_metadata_t*)(msg->metadata); - } - -/*----------------- Packet -----------------*/ - - command void Packet.clear(message_t* msg) - { - call IEEE154Packet2.createDataFrame(msg); - - getMeta(msg)->flags = RF212PACKET_CLEAR_METADATA; - } - - inline command void Packet.setPayloadLength(message_t* msg, uint8_t len) - { - call IEEE154Packet2.setLength(msg, len + PACKET_LENGTH_INCREASE); - } - - inline command uint8_t Packet.payloadLength(message_t* msg) - { - return call IEEE154Packet2.getLength(msg) - PACKET_LENGTH_INCREASE; - } - - inline command uint8_t Packet.maxPayloadLength() - { - return TOSH_DATA_LENGTH; - } - - command void* Packet.getPayload(message_t* msg, uint8_t len) - { - if( len > TOSH_DATA_LENGTH ) - return NULL; - - return msg->data; - } - -/*----------------- PacketAcknowledgements -----------------*/ - - async command error_t PacketAcknowledgements.requestAck(message_t* msg) - { - call IEEE154Packet2.setAckRequired(msg, TRUE); - - return SUCCESS; - } - - async command error_t PacketAcknowledgements.noAck(message_t* msg) - { - call IEEE154Packet2.setAckRequired(msg, FALSE); - - return SUCCESS; - } - - async command bool PacketAcknowledgements.wasAcked(message_t* msg) - { - return getMeta(msg)->flags & RF212PACKET_WAS_ACKED; - } - -/*----------------- PacketLinkQuality -----------------*/ - - async command bool PacketLinkQuality.isSet(message_t* msg) - { - return TRUE; - } - - async command uint8_t PacketLinkQuality.get(message_t* msg) - { - return getMeta(msg)->lqi; - } - - async command void PacketLinkQuality.clear(message_t* msg) - { - } - - async command void PacketLinkQuality.set(message_t* msg, uint8_t value) - { - getMeta(msg)->lqi = value; - } - -/*----------------- PacketTimeStampRadio -----------------*/ - - async command bool PacketTimeStampRadio.isValid(message_t* msg) - { - return getMeta(msg)->flags & RF212PACKET_TIMESTAMP; - } - - async command uint32_t PacketTimeStampRadio.timestamp(message_t* msg) - { - return getMeta(msg)->timestamp; - } - - async command void PacketTimeStampRadio.clear(message_t* msg) - { - getMeta(msg)->flags &= ~RF212PACKET_TIMESTAMP; - } - - async command void PacketTimeStampRadio.set(message_t* msg, uint32_t value) - { - getMeta(msg)->flags |= RF212PACKET_TIMESTAMP; - getMeta(msg)->timestamp = value; - } - -/*----------------- PacketTimeStampMilli -----------------*/ - - async command bool PacketTimeStampMilli.isValid(message_t* msg) - { - return call PacketTimeStampRadio.isValid(msg); - } - - async command uint32_t PacketTimeStampMilli.timestamp(message_t* msg) - { - int32_t offset = call PacketTimeStampRadio.timestamp(msg) - call LocalTimeRadio.get(); - - return (offset >> RADIO_ALARM_MILLI_EXP) + call LocalTimeMilli.get(); - } - - async command void PacketTimeStampMilli.clear(message_t* msg) - { - call PacketTimeStampRadio.clear(msg); - } - - async command void PacketTimeStampMilli.set(message_t* msg, uint32_t value) - { - int32_t offset = (value - call LocalTimeMilli.get()) << RADIO_ALARM_MILLI_EXP; - - call PacketTimeStampRadio.set(msg, offset + call LocalTimeRadio.get()); - } - -/*----------------- PacketTransmitPower -----------------*/ - - async command bool PacketTransmitPower.isSet(message_t* msg) - { - return getMeta(msg)->flags & RF212PACKET_TXPOWER; - } - - async command uint8_t PacketTransmitPower.get(message_t* msg) - { - return getMeta(msg)->power; - } - - async command void PacketTransmitPower.clear(message_t* msg) - { - getMeta(msg)->flags &= ~RF212PACKET_TXPOWER; - } - - async command void PacketTransmitPower.set(message_t* msg, uint8_t value) - { - getMeta(msg)->flags &= ~RF212PACKET_RSSI; - getMeta(msg)->flags |= RF212PACKET_TXPOWER; - getMeta(msg)->power = value; - } - -/*----------------- PacketRSSI -----------------*/ - - async command bool PacketRSSI.isSet(message_t* msg) - { - return getMeta(msg)->flags & RF212PACKET_RSSI; - } - - async command uint8_t PacketRSSI.get(message_t* msg) - { - return getMeta(msg)->power; - } - - async command void PacketRSSI.clear(message_t* msg) - { - getMeta(msg)->flags &= ~RF212PACKET_RSSI; - } - - async command void PacketRSSI.set(message_t* msg, uint8_t value) - { - getMeta(msg)->flags &= ~RF212PACKET_TXPOWER; - getMeta(msg)->flags |= RF212PACKET_RSSI; - getMeta(msg)->power = value; - } - -/*----------------- PacketTimeSyncOffset -----------------*/ - - async command bool PacketTimeSyncOffset.isSet(message_t* msg) - { - return getMeta(msg)->flags & RF212PACKET_TIMESYNC; - } - - async command uint8_t PacketTimeSyncOffset.get(message_t* msg) - { - return call IEEE154Packet2.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t); - } - - async command void PacketTimeSyncOffset.clear(message_t* msg) - { - getMeta(msg)->flags &= ~RF212PACKET_TIMESYNC; - } - - async command void PacketTimeSyncOffset.set(message_t* msg, uint8_t value) - { - // the value is ignored, the offset always points to the timesync footer at the end of the payload - getMeta(msg)->flags |= RF212PACKET_TIMESYNC; - } - -/*----------------- PacketSleepInterval -----------------*/ - - async command bool PacketSleepInterval.isSet(message_t* msg) - { - return getMeta(msg)->flags & RF212PACKET_LPL_SLEEPINT; - } - - async command uint16_t PacketSleepInterval.get(message_t* msg) - { -#ifdef LOW_POWER_LISTENING - return getMeta(msg)->lpl_sleepint; -#else - return 0; -#endif - } - - async command void PacketSleepInterval.clear(message_t* msg) - { - getMeta(msg)->flags &= ~RF212PACKET_LPL_SLEEPINT; - } - - async command void PacketSleepInterval.set(message_t* msg, uint16_t value) - { - getMeta(msg)->flags |= RF212PACKET_LPL_SLEEPINT; - -#ifdef LOW_POWER_LISTENING - getMeta(msg)->lpl_sleepint = value; -#endif - } - -/*----------------- PacketLinkMetadata -----------------*/ -#ifdef PACKET_LINK - - async command packet_link_metadata_t* PacketLinkMetadata.getData(message_t* msg) - { - return &(getMeta(msg)->packet_link); - } - -#endif -} diff --git a/tos/chips/rf2xx/rf230/RF230Packet.h b/tos/chips/rf2xx/rf230/RF230ActiveMessage.h similarity index 67% rename from tos/chips/rf2xx/rf230/RF230Packet.h rename to tos/chips/rf2xx/rf230/RF230ActiveMessage.h index 802aa51c..e219b7cf 100644 --- a/tos/chips/rf2xx/rf230/RF230Packet.h +++ b/tos/chips/rf2xx/rf230/RF230ActiveMessage.h @@ -21,10 +21,14 @@ * Author: Miklos Maroti */ -#ifndef __RF230PACKET_H__ -#define __RF230PACKET_H__ - -#include +#ifndef __RF230ACTIVEMESSAGE_H__ +#define __RF230ACTIVEMESSAGE_H__ + +#include +#include +#include +#include +#include #include typedef ieee154_header_t rf230packet_header_t; @@ -36,28 +40,15 @@ typedef nx_struct rf230packet_footer_t typedef struct rf230packet_metadata_t { - uint8_t flags; - uint8_t lqi; - uint8_t power; // shared between TXPOWER and RSSI + flags_metadata_t flags; + rf230_metadata_t rf230; + timestamp_metadata_t timestamp; #ifdef LOW_POWER_LISTENING - uint16_t lpl_sleepint; + lpl_metadata_t lpl; #endif #ifdef PACKET_LINK - packet_link_metadata_t packet_link; + link_metadata_t link; #endif - uint32_t timestamp; } rf230packet_metadata_t; -enum rf230packet_metadata_flags -{ - RF230PACKET_WAS_ACKED = 0x01, // PacketAcknowledgements - RF230PACKET_TIMESTAMP = 0x02, // PacketTimeStamp - RF230PACKET_TXPOWER = 0x04, // PacketTransmitPower - RF230PACKET_RSSI = 0x08, // PacketRSSI - RF230PACKET_TIMESYNC = 0x10, // PacketTimeSync (update timesync_footer) - RF230PACKET_LPL_SLEEPINT = 0x20, // LowPowerListening - - RF230PACKET_CLEAR_METADATA = 0x00, -}; - -#endif//__RF230PACKET_H__ +#endif//__RF230ACTIVEMESSAGE_H__ diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc b/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc index af6e816e..b11d0e23 100644 --- a/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc +++ b/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc @@ -36,8 +36,6 @@ configuration RF230ActiveMessageC interface Packet; interface AMPacket; interface PacketAcknowledgements; - - // we provide a dummy LowPowerListening interface if LOW_POWER_LISTENING is not defined interface LowPowerListening; #ifdef PACKET_LINK @@ -50,6 +48,7 @@ configuration RF230ActiveMessageC interface PacketField as PacketTransmitPower; interface PacketField as PacketRSSI; + interface LocalTime as LocalTimeRadio; interface PacketTimeStamp as PacketTimeStampRadio; interface PacketTimeStamp as PacketTimeStampMilli; } @@ -57,112 +56,142 @@ configuration RF230ActiveMessageC implementation { - components RF230ActiveMessageP, RF230PacketC, IEEE154Packet2C, RadioAlarmC; + components RF230ActiveMessageP, IEEE154PacketLayerC, RadioAlarmC; #ifdef RADIO_DEBUG components AssertC; #endif - RF230ActiveMessageP.IEEE154Packet2 -> IEEE154Packet2C; - RF230ActiveMessageP.Packet -> RF230PacketC; + RF230ActiveMessageP.IEEE154PacketLayer -> IEEE154PacketLayerC; RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; + RF230ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC; - Packet = RF230PacketC; - AMPacket = RF230PacketC; - PacketAcknowledgements = RF230PacketC; - PacketLinkQuality = RF230PacketC.PacketLinkQuality; - PacketTransmitPower = RF230PacketC.PacketTransmitPower; - PacketRSSI = RF230PacketC.PacketRSSI; - PacketTimeStampRadio = RF230PacketC; - PacketTimeStampMilli = RF230PacketC; - LowPowerListening = LowPowerListeningLayerC; - RadioChannel = MessageBufferLayerC; + Packet = RF230ActiveMessageP; + +// -------- ActiveMessage components ActiveMessageLayerC; + ActiveMessageLayerC.Config -> RF230ActiveMessageP; + ActiveMessageLayerC.AMPacket -> IEEE154PacketLayerC; + ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC; + ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC; + AMSend = ActiveMessageLayerC; + Receive = ActiveMessageLayerC.Receive; + Snoop = ActiveMessageLayerC.Snoop; + AMPacket = IEEE154PacketLayerC; + +// -------- IEEE154Network + #ifdef TFRAMES_ENABLED components new DummyLayerC() as IEEE154NetworkLayerC; #else components IEEE154NetworkLayerC; #endif + IEEE154NetworkLayerC.SubSend -> UniqueLayerC; + IEEE154NetworkLayerC.SubReceive -> LowPowerListeningLayerC; + +// -------- UniqueLayer Send part (wired twice) + + components UniqueLayerC; + UniqueLayerC.Config -> RF230ActiveMessageP; + UniqueLayerC.SubSend -> LowPowerListeningLayerC; + +// -------- Low Power Listening #ifdef LOW_POWER_LISTENING components LowPowerListeningLayerC; - LowPowerListeningLayerC.PacketSleepInterval -> RF230PacketC; - LowPowerListeningLayerC.IEEE154Packet2 -> IEEE154Packet2C; - LowPowerListeningLayerC.PacketAcknowledgements -> RF230PacketC; + LowPowerListeningLayerC.PacketLplMetadata -> RF230ActiveMessageP; + LowPowerListeningLayerC.IEEE154PacketLayer -> IEEE154PacketLayerC; + LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC; #else - components new DummyLayerC() as LowPowerListeningLayerC; + components LowPowerListeningDummyC as LowPowerListeningLayerC; #endif + LowPowerListeningLayerC.SubControl -> MessageBufferLayerC; + LowPowerListeningLayerC.SubSend -> PacketLinkLayerC; + LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC; + SplitControl = LowPowerListeningLayerC; + LowPowerListening = LowPowerListeningLayerC; + +// -------- Packet Link #ifdef PACKET_LINK components PacketLinkLayerC; PacketLink = PacketLinkLayerC; - PacketLinkLayerC.PacketData -> RF230PacketC; - PacketLinkLayerC.PacketAcknowledgements -> RF230PacketC; + PacketLinkLayerC.PacketLinkMetadata -> RF230ActiveMessageP; + PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC; #else components new DummyLayerC() as PacketLinkLayerC; #endif - - components MessageBufferLayerC; - components UniqueLayerC; - components TrafficMonitorLayerC; - -#ifdef SLOTTED_MAC - components SlottedCollisionLayerC as CollisionAvoidanceLayerC; -#else - components RandomCollisionLayerC as CollisionAvoidanceLayerC; -#endif - - components SoftwareAckLayerC; - components new DummyLayerC() as CsmaLayerC; - components RF230DriverLayerC; - - SplitControl = LowPowerListeningLayerC; - AMSend = ActiveMessageLayerC; - Receive = ActiveMessageLayerC.Receive; - Snoop = ActiveMessageLayerC.Snoop; - - ActiveMessageLayerC.Config -> RF230ActiveMessageP; - ActiveMessageLayerC.AMPacket -> IEEE154Packet2C; - ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC; - ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC; - - IEEE154NetworkLayerC.SubSend -> UniqueLayerC; - IEEE154NetworkLayerC.SubReceive -> LowPowerListeningLayerC; - - // the UniqueLayer is wired at two points - UniqueLayerC.Config -> RF230ActiveMessageP; - UniqueLayerC.SubSend -> LowPowerListeningLayerC; - - LowPowerListeningLayerC.SubControl -> MessageBufferLayerC; - LowPowerListeningLayerC.SubSend -> PacketLinkLayerC; - LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC; - PacketLinkLayerC.SubSend -> MessageBufferLayerC; - MessageBufferLayerC.Packet -> RF230PacketC; +// -------- MessageBuffer + + components MessageBufferLayerC; + MessageBufferLayerC.Packet -> RF230ActiveMessageP; MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC; MessageBufferLayerC.RadioReceive -> UniqueLayerC; MessageBufferLayerC.RadioState -> TrafficMonitorLayerC; + RadioChannel = MessageBufferLayerC; + +// -------- UniqueLayer receive part (wired twice) UniqueLayerC.SubReceive -> TrafficMonitorLayerC; +// -------- Traffic Monitor + + components TrafficMonitorLayerC; TrafficMonitorLayerC.Config -> RF230ActiveMessageP; TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC; TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC; TrafficMonitorLayerC.SubState -> RF230DriverLayerC; +// -------- CollisionAvoidance + +#ifdef SLOTTED_MAC + components SlottedCollisionLayerC as CollisionAvoidanceLayerC; +#else + components RandomCollisionLayerC as CollisionAvoidanceLayerC; +#endif CollisionAvoidanceLayerC.Config -> RF230ActiveMessageP; CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC; CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC; +// -------- SoftwareAcknowledgement + + components SoftwareAckLayerC; SoftwareAckLayerC.Config -> RF230ActiveMessageP; SoftwareAckLayerC.SubSend -> CsmaLayerC; SoftwareAckLayerC.SubReceive -> RF230DriverLayerC; + PacketAcknowledgements = SoftwareAckLayerC; + +// -------- Carrier Sense + components new DummyLayerC() as CsmaLayerC; CsmaLayerC.Config -> RF230ActiveMessageP; CsmaLayerC -> RF230DriverLayerC.RadioSend; CsmaLayerC -> RF230DriverLayerC.RadioCCA; +// -------- RF230 Driver + + components RF230DriverLayerC; + RF230DriverLayerC.PacketRF230Metadata -> RF230ActiveMessageP; RF230DriverLayerC.RF230DriverConfig -> RF230ActiveMessageP; + RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC; + PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower; + PacketLinkQuality = RF230DriverLayerC.PacketLinkQuality; + PacketRSSI = RF230DriverLayerC.PacketRSSI; + LocalTimeRadio = RF230DriverLayerC; + +// -------- MetadataFlags + + components MetadataFlagsLayerC; + MetadataFlagsLayerC.PacketFlagsMetadata -> RF230ActiveMessageP; + +// -------- TimeStamping + + components TimeStampingLayerC; + TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC; + TimeStampingLayerC.PacketTimeStampMetadata -> RF230ActiveMessageP; + PacketTimeStampRadio = TimeStampingLayerC; + PacketTimeStampMilli = TimeStampingLayerC; } diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc b/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc index 9c8044cd..0842b5af 100644 --- a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc +++ b/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc @@ -21,7 +21,7 @@ * Author: Miklos Maroti */ -#include +#include #include #include @@ -38,13 +38,27 @@ module RF230ActiveMessageP interface SlottedCollisionConfig; interface ActiveMessageConfig; interface DummyConfig; + + interface Packet; + + interface PacketData as PacketFlagsMetadata; + interface PacketData as PacketRF230Metadata; + interface PacketData as PacketTimeStampMetadata; + +#ifdef LOW_POWER_LISTENING + interface PacketData as PacketLplMetadata; +#endif +#ifdef PACKET_LINK + interface PacketData as PacketLinkMetadata; +#endif } uses { - interface IEEE154Packet2; - interface Packet; + interface IEEE154PacketLayer; interface RadioAlarm; + + interface PacketTimeStamp; } } @@ -54,22 +68,17 @@ implementation async command uint8_t RF230DriverConfig.getLength(message_t* msg) { - return call IEEE154Packet2.getLength(msg); + return call IEEE154PacketLayer.getLength(msg); } async command void RF230DriverConfig.setLength(message_t* msg, uint8_t len) { - call IEEE154Packet2.setLength(msg, len); + call IEEE154PacketLayer.setLength(msg, len); } async command uint8_t* RF230DriverConfig.getPayload(message_t* msg) { - return ((uint8_t*)(call IEEE154Packet2.getHeader(msg))) + 1; - } - - inline rf230packet_metadata_t* getMeta(message_t* msg) - { - return (rf230packet_metadata_t*)(msg->metadata); + return ((uint8_t*)(call IEEE154PacketLayer.getHeader(msg))) + 1; } async command uint8_t RF230DriverConfig.getHeaderLength() @@ -86,42 +95,39 @@ implementation async command bool RF230DriverConfig.requiresRssiCca(message_t* msg) { - return call IEEE154Packet2.isDataFrame(msg); + return call IEEE154PacketLayer.isDataFrame(msg); } /*----------------- SoftwareAckConfig -----------------*/ async command bool SoftwareAckConfig.requiresAckWait(message_t* msg) { - return call IEEE154Packet2.requiresAckWait(msg); + return call IEEE154PacketLayer.requiresAckWait(msg); } async command bool SoftwareAckConfig.isAckPacket(message_t* msg) { - return call IEEE154Packet2.isAckFrame(msg); + return call IEEE154PacketLayer.isAckFrame(msg); } async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack) { - return call IEEE154Packet2.verifyAckReply(data, ack); + return call IEEE154PacketLayer.verifyAckReply(data, ack); } - async command bool SoftwareAckConfig.requiresAckReply(message_t* msg) + async command void SoftwareAckConfig.setAckRequired(message_t* msg, bool ack) { - return call IEEE154Packet2.requiresAckReply(msg); + call IEEE154PacketLayer.setAckRequired(msg, ack); } - async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack) + async command bool SoftwareAckConfig.requiresAckReply(message_t* msg) { - call IEEE154Packet2.createAckReply(data, ack); + return call IEEE154PacketLayer.requiresAckReply(msg); } - async command void SoftwareAckConfig.setAckReceived(message_t* msg, bool acked) + async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack) { - if( acked ) - getMeta(msg)->flags |= RF230PACKET_WAS_ACKED; - else - getMeta(msg)->flags &= ~RF230PACKET_WAS_ACKED; + call IEEE154PacketLayer.createAckReply(data, ack); } async command uint16_t SoftwareAckConfig.getAckTimeout() @@ -138,17 +144,17 @@ implementation async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg) { - return call IEEE154Packet2.getDSN(msg); + return call IEEE154PacketLayer.getDSN(msg); } async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn) { - call IEEE154Packet2.setDSN(msg, dsn); + call IEEE154PacketLayer.setDSN(msg, dsn); } async command am_addr_t UniqueConfig.getSender(message_t* msg) { - return call IEEE154Packet2.getSrcAddr(msg); + return call IEEE154PacketLayer.getSrcAddr(msg); } tasklet_async command void UniqueConfig.reportChannelError() @@ -161,7 +167,7 @@ implementation command error_t ActiveMessageConfig.checkPacket(message_t* msg) { // the user forgot to call clear, we should return EINVAL - if( ! call IEEE154Packet2.isDataFrame(msg) ) + if( ! call IEEE154PacketLayer.isDataFrame(msg) ) call Packet.clear(msg); return SUCCESS; @@ -171,7 +177,7 @@ implementation async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg) { - return call IEEE154Packet2.isDataFrame(msg); + return call IEEE154PacketLayer.isDataFrame(msg); } /*----------------- TrafficMonitorConfig -----------------*/ @@ -196,13 +202,13 @@ implementation * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation */ - uint8_t len = call IEEE154Packet2.getLength(msg); - return call IEEE154Packet2.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; + uint8_t len = call IEEE154PacketLayer.getLength(msg); + return call IEEE154PacketLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; } async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg) { - return call IEEE154Packet2.getSrcAddr(msg); + return call IEEE154PacketLayer.getSrcAddr(msg); } tasklet_async command void TrafficMonitorConfig.timerTick() @@ -244,7 +250,7 @@ implementation time = call RadioAlarm.getNow(); // estimated response time (download the message, etc) is 5-8 bytes - if( call IEEE154Packet2.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); @@ -269,13 +275,13 @@ implementation async command uint16_t SlottedCollisionConfig.getTransmitTime(message_t* msg) { // TODO: check if the timestamp is correct - return getMeta(msg)->timestamp; + return call PacketTimeStamp.timestamp(msg); } async command uint16_t SlottedCollisionConfig.getCollisionWindowStart(message_t* msg) { // the preamble (4 bytes), SFD (1 byte), plus two extra for safety - return getMeta(msg)->timestamp - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC); + return (call PacketTimeStamp.timestamp(msg)) - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC); } async command uint16_t SlottedCollisionConfig.getCollisionWindowLength(message_t* msg) @@ -290,4 +296,86 @@ implementation async command void DummyConfig.nothing() { } + +/*----------------- Metadata -----------------*/ + + inline rf230packet_metadata_t* getMeta(message_t* msg) + { + return (rf230packet_metadata_t*)(msg->metadata); + } + + async command flags_metadata_t* PacketFlagsMetadata.get(message_t* msg) + { + return &(getMeta(msg)->flags); + } + + async command rf230_metadata_t* PacketRF230Metadata.get(message_t* msg) + { + return &(getMeta(msg)->rf230); + } + + async command timestamp_metadata_t* PacketTimeStampMetadata.get(message_t* msg) + { + return &(getMeta(msg)->timestamp); + } + +#ifdef LOW_POWER_LISTENING + async command lpl_metadata_t* PacketLplMetadata.get(message_t* msg) + { + return &(getMeta(msg)->lpl); + } +#endif + +#ifdef PACKET_LINK + async command link_metadata_t* PacketLinkMetadata.get(message_t* msg) + { + return &(getMeta(msg)->link); + } +#endif + +/*----------------- Packet -----------------*/ + + enum + { + PACKET_LENGTH_INCREASE = + sizeof(rf230packet_header_t) - 1 // the 8-bit length field is not counted + + sizeof(ieee154_footer_t), // the CRC is not stored in memory + }; + + command void Packet.clear(message_t* msg) + { + signal PacketFlagsMetadata.clear(msg); + signal PacketRF230Metadata.clear(msg); + signal PacketTimeStampMetadata.clear(msg); +#ifdef LOW_POWER_LISTENING + signal PacketLplMetadata.clear(msg); +#endif +#ifdef PACKET_LINK + signal PacketLinkMetadata.clear(msg); +#endif + call IEEE154PacketLayer.createDataFrame(msg); + } + + inline command void Packet.setPayloadLength(message_t* msg, uint8_t len) + { + call IEEE154PacketLayer.setLength(msg, len + PACKET_LENGTH_INCREASE); + } + + inline command uint8_t Packet.payloadLength(message_t* msg) + { + return call IEEE154PacketLayer.getLength(msg) - PACKET_LENGTH_INCREASE; + } + + inline command uint8_t Packet.maxPayloadLength() + { + return TOSH_DATA_LENGTH; + } + + command void* Packet.getPayload(message_t* msg, uint8_t len) + { + if( len > TOSH_DATA_LENGTH ) + return NULL; + + return msg->data; + } } diff --git a/tos/chips/rf2xx/rf230/RF230.h b/tos/chips/rf2xx/rf230/RF230DriverLayer.h similarity index 94% rename from tos/chips/rf2xx/rf230/RF230.h rename to tos/chips/rf2xx/rf230/RF230DriverLayer.h index dd386a1d..c57969f8 100644 --- a/tos/chips/rf2xx/rf230/RF230.h +++ b/tos/chips/rf2xx/rf230/RF230DriverLayer.h @@ -21,8 +21,18 @@ * Author: Miklos Maroti */ -#ifndef __RF230_H__ -#define __RF230_H__ +#ifndef __RF230DRIVERLAYER_H__ +#define __RF230DRIVERLAYER_H__ + +typedef struct rf230_metadata_t +{ + uint8_t lqi; + union + { + uint8_t power; + uint8_t rssi; + }; +} rf230_metadata_t; enum rf230_registers_enum { @@ -149,4 +159,4 @@ enum rf230_spi_command_enums RF230_CMD_SRAM_WRITE = 0x40, }; -#endif//__RF230_H__ +#endif//__RF230DRIVERLAYER_H__ diff --git a/tos/chips/rf2xx/rf230/RF230DriverLayerC.nc b/tos/chips/rf2xx/rf230/RF230DriverLayerC.nc index 021e0982..8b58211d 100644 --- a/tos/chips/rf2xx/rf230/RF230DriverLayerC.nc +++ b/tos/chips/rf2xx/rf230/RF230DriverLayerC.nc @@ -21,6 +21,9 @@ * Author: Miklos Maroti */ +#include +#include + configuration RF230DriverLayerC { provides @@ -29,28 +32,53 @@ configuration RF230DriverLayerC interface RadioSend; interface RadioReceive; interface RadioCCA; + + interface PacketField as PacketTransmitPower; + interface PacketField as PacketRSSI; + interface PacketField as PacketTimeSyncOffset; + interface PacketField as PacketLinkQuality; + + interface LocalTime as LocalTimeRadio; } - uses interface RF230DriverConfig; + uses + { + interface RF230DriverConfig; + interface PacketTimeStamp; + interface PacketData as PacketRF230Metadata; + } } implementation { - components RF230DriverLayerP, HplRF230C, BusyWaitMicroC, TaskletC, MainC, RadioAlarmC, RF230PacketC, LocalTimeMicroC as LocalTimeRadioC; + components RF230DriverLayerP, HplRF230C, BusyWaitMicroC, TaskletC, MainC, RadioAlarmC; RadioState = RF230DriverLayerP; RadioSend = RF230DriverLayerP; RadioReceive = RF230DriverLayerP; RadioCCA = RF230DriverLayerP; + LocalTimeRadio = HplRF230C; + RF230DriverConfig = RF230DriverLayerP; + PacketRF230Metadata = RF230DriverLayerP; + + PacketTransmitPower = RF230DriverLayerP.PacketTransmitPower; + components new MetadataFlagC() as TransmitPowerFlagC; + RF230DriverLayerP.TransmitPowerFlag -> TransmitPowerFlagC; + + PacketRSSI = RF230DriverLayerP.PacketRSSI; + components new MetadataFlagC() as RSSIFlagC; + RF230DriverLayerP.RSSIFlag -> RSSIFlagC; + + PacketTimeSyncOffset = RF230DriverLayerP.PacketTimeSyncOffset; + components new MetadataFlagC() as TimeSyncFlagC; + RF230DriverLayerP.TimeSyncFlag -> TimeSyncFlagC; + + PacketLinkQuality = RF230DriverLayerP.PacketLinkQuality; + PacketTimeStamp = RF230DriverLayerP.PacketTimeStamp; - RF230DriverLayerP.PacketLinkQuality -> RF230PacketC.PacketLinkQuality; - RF230DriverLayerP.PacketTransmitPower -> RF230PacketC.PacketTransmitPower; - RF230DriverLayerP.PacketRSSI -> RF230PacketC.PacketRSSI; - RF230DriverLayerP.PacketTimeSyncOffset -> RF230PacketC.PacketTimeSyncOffset; - RF230DriverLayerP.PacketTimeStamp -> RF230PacketC; - RF230DriverLayerP.LocalTime -> LocalTimeRadioC; + RF230DriverLayerP.LocalTime -> HplRF230C; RF230DriverLayerP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; RadioAlarmC.Alarm -> HplRF230C.Alarm; diff --git a/tos/chips/rf2xx/rf230/RF230DriverLayerP.nc b/tos/chips/rf2xx/rf230/RF230DriverLayerP.nc index 17ea8ffa..77e94ad2 100644 --- a/tos/chips/rf2xx/rf230/RF230DriverLayerP.nc +++ b/tos/chips/rf2xx/rf230/RF230DriverLayerP.nc @@ -21,7 +21,7 @@ * Author: Miklos Maroti */ -#include +#include #include #include #include @@ -38,6 +38,11 @@ module RF230DriverLayerP interface RadioSend; interface RadioReceive; interface RadioCCA; + + interface PacketField as PacketTransmitPower; + interface PacketField as PacketRSSI; + interface PacketField as PacketTimeSyncOffset; + interface PacketField as PacketLinkQuality; } uses @@ -53,16 +58,17 @@ module RF230DriverLayerP interface GpioCapture as IRQ; interface BusyWait; + interface LocalTime; - interface PacketField as PacketLinkQuality; - interface PacketField as PacketTransmitPower; - interface PacketField as PacketRSSI; - interface PacketField as PacketTimeSyncOffset; + interface RF230DriverConfig; + + interface PacketData as PacketRF230Metadata; + interface PacketFlag as TransmitPowerFlag; + interface PacketFlag as RSSIFlag; + interface PacketFlag as TimeSyncFlag; interface PacketTimeStamp; - interface LocalTime; - interface RF230DriverConfig; interface Tasklet; interface RadioAlarm; @@ -829,4 +835,112 @@ implementation if( cmd == CMD_NONE ) call SpiResource.release(); } + +/*----------------- PACKET -----------------*/ + + async event void PacketRF230Metadata.clear(message_t* msg) + { + } + +// --- TransmitPower + + async command bool PacketTransmitPower.isSet(message_t* msg) + { + return call TransmitPowerFlag.get(msg); + } + + async command uint8_t PacketTransmitPower.get(message_t* msg) + { + return (call PacketRF230Metadata.get(msg))->power; + } + + async command void PacketTransmitPower.clear(message_t* msg) + { + call TransmitPowerFlag.clear(msg); + } + + async command void PacketTransmitPower.set(message_t* msg, uint8_t value) + { + call TransmitPowerFlag.set(msg); + (call PacketRF230Metadata.get(msg))->power = value; + } + +// --- RSSI + + async command bool PacketRSSI.isSet(message_t* msg) + { + return call RSSIFlag.get(msg); + } + + async command uint8_t PacketRSSI.get(message_t* msg) + { + return (call PacketRF230Metadata.get(msg))->rssi; + } + + async command void PacketRSSI.clear(message_t* msg) + { + call RSSIFlag.clear(msg); + } + + async command void PacketRSSI.set(message_t* msg, uint8_t value) + { + // just to be safe if the user fails to clear the packet + call TransmitPowerFlag.clear(msg); + + call RSSIFlag.set(msg); + (call PacketRF230Metadata.get(msg))->rssi = value; + } + +// --- TimeSyncOffset + + enum + { + PACKET_LENGTH_INCREASE = + sizeof(rf230packet_header_t) - 1 // the 8-bit length field is not counted + + sizeof(ieee154_footer_t), // the CRC is not stored in memory + }; + + async command bool PacketTimeSyncOffset.isSet(message_t* msg) + { + return call TimeSyncFlag.get(msg); + } + + async command uint8_t PacketTimeSyncOffset.get(message_t* msg) + { + return call RF230DriverConfig.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t); + } + + async command void PacketTimeSyncOffset.clear(message_t* msg) + { + call TimeSyncFlag.clear(msg); + } + + async command void PacketTimeSyncOffset.set(message_t* msg, uint8_t value) + { + // we do not store the value, the time sync field is always the last 4 bytes + ASSERT( call RF230DriverConfig.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t) == value ); + + call TimeSyncFlag.set(msg); + } + +// --- LinkQuality + + async command bool PacketLinkQuality.isSet(message_t* msg) + { + return TRUE; + } + + async command uint8_t PacketLinkQuality.get(message_t* msg) + { + return (call PacketRF230Metadata.get(msg))->lqi; + } + + async command void PacketLinkQuality.clear(message_t* msg) + { + } + + async command void PacketLinkQuality.set(message_t* msg, uint8_t value) + { + (call PacketRF230Metadata.get(msg))->lqi = value; + } } diff --git a/tos/chips/rf2xx/rf230/RF230PacketC.nc b/tos/chips/rf2xx/rf230/RF230PacketC.nc deleted file mode 100644 index 31e82699..00000000 --- a/tos/chips/rf2xx/rf230/RF230PacketC.nc +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2007, Vanderbilt University - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT - * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Author: Miklos Maroti - */ - -configuration RF230PacketC -{ - provides - { - interface Packet; - interface AMPacket; - interface PacketAcknowledgements; - interface PacketField as PacketLinkQuality; - interface PacketField as PacketTransmitPower; - interface PacketField as PacketRSSI; - interface PacketField as PacketSleepInterval; - interface PacketField as PacketTimeSyncOffset; - - interface PacketTimeStamp as PacketTimeStampRadio; - interface PacketTimeStamp as PacketTimeStampMilli; -#ifdef PACKET_LINK - interface PacketData as PaketLinkMetadata; -#endif - } -} - -implementation -{ - components RF230PacketP, IEEE154Packet2C, LocalTimeMicroC, LocalTimeMilliC; - - RF230PacketP.IEEE154Packet2 -> IEEE154Packet2C; - RF230PacketP.LocalTimeRadio -> LocalTimeMicroC; - RF230PacketP.LocalTimeMilli -> LocalTimeMilliC; - - Packet = RF230PacketP; - AMPacket = IEEE154Packet2C; - - PacketAcknowledgements = RF230PacketP; - PacketLinkQuality = RF230PacketP.PacketLinkQuality; - PacketTransmitPower = RF230PacketP.PacketTransmitPower; - PacketRSSI = RF230PacketP.PacketRSSI; - PacketSleepInterval = RF230PacketP.PacketSleepInterval; - PacketTimeSyncOffset = RF230PacketP.PacketTimeSyncOffset; - - PacketTimeStampRadio = RF230PacketP; - PacketTimeStampMilli = RF230PacketP; - -#ifdef PACKET_LINK - PaketLinkMetadata = RF230PacketP; -#endif -} diff --git a/tos/chips/rf2xx/rf230/RF230PacketP.nc b/tos/chips/rf2xx/rf230/RF230PacketP.nc deleted file mode 100644 index de875b02..00000000 --- a/tos/chips/rf2xx/rf230/RF230PacketP.nc +++ /dev/null @@ -1,305 +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 -#include -#include - -module RF230PacketP -{ - provides - { - interface PacketAcknowledgements; - interface Packet; - interface PacketField as PacketLinkQuality; - interface PacketField as PacketTransmitPower; - interface PacketField as PacketRSSI; - interface PacketField as PacketSleepInterval; - interface PacketField as PacketTimeSyncOffset; - - interface PacketTimeStamp as PacketTimeStampRadio; - interface PacketTimeStamp as PacketTimeStampMilli; - -#ifdef PACKET_LINK - interface PacketData as PacketLinkMetadata; -#endif - } - - uses - { - interface IEEE154Packet2; - - interface LocalTime as LocalTimeRadio; - interface LocalTime as LocalTimeMilli; - } -} - -implementation -{ - enum - { - PACKET_LENGTH_INCREASE = - sizeof(rf230packet_header_t) - 1 // the 8-bit length field is not counted - + sizeof(ieee154_footer_t), // the CRC is not stored in memory - }; - - inline rf230packet_metadata_t* getMeta(message_t* msg) - { - return (rf230packet_metadata_t*)(msg->metadata); - } - -/*----------------- Packet -----------------*/ - - command void Packet.clear(message_t* msg) - { - call IEEE154Packet2.createDataFrame(msg); - - getMeta(msg)->flags = RF230PACKET_CLEAR_METADATA; - } - - inline command void Packet.setPayloadLength(message_t* msg, uint8_t len) - { - call IEEE154Packet2.setLength(msg, len + PACKET_LENGTH_INCREASE); - } - - inline command uint8_t Packet.payloadLength(message_t* msg) - { - return call IEEE154Packet2.getLength(msg) - PACKET_LENGTH_INCREASE; - } - - inline command uint8_t Packet.maxPayloadLength() - { - return TOSH_DATA_LENGTH; - } - - command void* Packet.getPayload(message_t* msg, uint8_t len) - { - if( len > TOSH_DATA_LENGTH ) - return NULL; - - return msg->data; - } - -/*----------------- PacketAcknowledgements -----------------*/ - - async command error_t PacketAcknowledgements.requestAck(message_t* msg) - { - call IEEE154Packet2.setAckRequired(msg, TRUE); - - return SUCCESS; - } - - async command error_t PacketAcknowledgements.noAck(message_t* msg) - { - call IEEE154Packet2.setAckRequired(msg, FALSE); - - return SUCCESS; - } - - async command bool PacketAcknowledgements.wasAcked(message_t* msg) - { - return getMeta(msg)->flags & RF230PACKET_WAS_ACKED; - } - -/*----------------- PacketLinkQuality -----------------*/ - - async command bool PacketLinkQuality.isSet(message_t* msg) - { - return TRUE; - } - - async command uint8_t PacketLinkQuality.get(message_t* msg) - { - return getMeta(msg)->lqi; - } - - async command void PacketLinkQuality.clear(message_t* msg) - { - } - - async command void PacketLinkQuality.set(message_t* msg, uint8_t value) - { - getMeta(msg)->lqi = value; - } - -/*----------------- PacketTimeStampRadio -----------------*/ - - async command bool PacketTimeStampRadio.isValid(message_t* msg) - { - return getMeta(msg)->flags & RF230PACKET_TIMESTAMP; - } - - async command uint32_t PacketTimeStampRadio.timestamp(message_t* msg) - { - return getMeta(msg)->timestamp; - } - - async command void PacketTimeStampRadio.clear(message_t* msg) - { - getMeta(msg)->flags &= ~RF230PACKET_TIMESTAMP; - } - - async command void PacketTimeStampRadio.set(message_t* msg, uint32_t value) - { - getMeta(msg)->flags |= RF230PACKET_TIMESTAMP; - getMeta(msg)->timestamp = value; - } - -/*----------------- PacketTimeStampMilli -----------------*/ - - async command bool PacketTimeStampMilli.isValid(message_t* msg) - { - return call PacketTimeStampRadio.isValid(msg); - } - - async command uint32_t PacketTimeStampMilli.timestamp(message_t* msg) - { - int32_t offset = call PacketTimeStampRadio.timestamp(msg) - call LocalTimeRadio.get(); - - return (offset >> RADIO_ALARM_MILLI_EXP) + call LocalTimeMilli.get(); - } - - async command void PacketTimeStampMilli.clear(message_t* msg) - { - call PacketTimeStampRadio.clear(msg); - } - - async command void PacketTimeStampMilli.set(message_t* msg, uint32_t value) - { - int32_t offset = (value - call LocalTimeMilli.get()) << RADIO_ALARM_MILLI_EXP; - - call PacketTimeStampRadio.set(msg, offset + call LocalTimeRadio.get()); - } - -/*----------------- PacketTransmitPower -----------------*/ - - async command bool PacketTransmitPower.isSet(message_t* msg) - { - return getMeta(msg)->flags & RF230PACKET_TXPOWER; - } - - async command uint8_t PacketTransmitPower.get(message_t* msg) - { - return getMeta(msg)->power; - } - - async command void PacketTransmitPower.clear(message_t* msg) - { - getMeta(msg)->flags &= ~RF230PACKET_TXPOWER; - } - - async command void PacketTransmitPower.set(message_t* msg, uint8_t value) - { - getMeta(msg)->flags &= ~RF230PACKET_RSSI; - getMeta(msg)->flags |= RF230PACKET_TXPOWER; - getMeta(msg)->power = value; - } - -/*----------------- PacketRSSI -----------------*/ - - async command bool PacketRSSI.isSet(message_t* msg) - { - return getMeta(msg)->flags & RF230PACKET_RSSI; - } - - async command uint8_t PacketRSSI.get(message_t* msg) - { - return getMeta(msg)->power; - } - - async command void PacketRSSI.clear(message_t* msg) - { - getMeta(msg)->flags &= ~RF230PACKET_RSSI; - } - - async command void PacketRSSI.set(message_t* msg, uint8_t value) - { - getMeta(msg)->flags &= ~RF230PACKET_TXPOWER; - getMeta(msg)->flags |= RF230PACKET_RSSI; - getMeta(msg)->power = value; - } - -/*----------------- PacketTimeSyncOffset -----------------*/ - - async command bool PacketTimeSyncOffset.isSet(message_t* msg) - { - return getMeta(msg)->flags & RF230PACKET_TIMESYNC; - } - - async command uint8_t PacketTimeSyncOffset.get(message_t* msg) - { - return call IEEE154Packet2.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t); - } - - async command void PacketTimeSyncOffset.clear(message_t* msg) - { - getMeta(msg)->flags &= ~RF230PACKET_TIMESYNC; - } - - async command void PacketTimeSyncOffset.set(message_t* msg, uint8_t value) - { - // the value is ignored, the offset always points to the timesync footer at the end of the payload - getMeta(msg)->flags |= RF230PACKET_TIMESYNC; - } - -/*----------------- PacketSleepInterval -----------------*/ - - async command bool PacketSleepInterval.isSet(message_t* msg) - { - return getMeta(msg)->flags & RF230PACKET_LPL_SLEEPINT; - } - - async command uint16_t PacketSleepInterval.get(message_t* msg) - { -#ifdef LOW_POWER_LISTENING - return getMeta(msg)->lpl_sleepint; -#else - return 0; -#endif - } - - async command void PacketSleepInterval.clear(message_t* msg) - { - getMeta(msg)->flags &= ~RF230PACKET_LPL_SLEEPINT; - } - - async command void PacketSleepInterval.set(message_t* msg, uint16_t value) - { - getMeta(msg)->flags |= RF230PACKET_LPL_SLEEPINT; - -#ifdef LOW_POWER_LISTENING - getMeta(msg)->lpl_sleepint = value; -#endif - } - -/*----------------- PacketLinkMetadata -----------------*/ -#ifdef PACKET_LINK - - async command packet_link_metadata_t* PacketLinkMetadata.getData(message_t* msg) - { - return &(getMeta(msg)->packet_link); - } - -#endif -} diff --git a/tos/chips/rf2xx/util/MetadataFlagC.nc b/tos/chips/rf2xx/util/MetadataFlagC.nc new file mode 100644 index 00000000..1091eb50 --- /dev/null +++ b/tos/chips/rf2xx/util/MetadataFlagC.nc @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2009, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author: Miklos Maroti + */ + +generic configuration MetadataFlagC() +{ + provides + { + interface PacketFlag; + } +} + +implementation +{ + components MetadataFlagsLayerC; + + PacketFlag = MetadataFlagsLayerC.PacketFlag[unique("PacketFlags")]; +} diff --git a/tos/chips/rf2xx/util/PacketData.nc b/tos/chips/rf2xx/util/PacketData.nc index ea425951..b3338280 100644 --- a/tos/chips/rf2xx/util/PacketData.nc +++ b/tos/chips/rf2xx/util/PacketData.nc @@ -27,11 +27,11 @@ interface PacketData * This command returns a pointer to a set of packet fields (in the header, footer * or metadata) with the given data type. */ - async command data_t* getData(message_t* msg); + async command data_t* get(message_t* msg); /** * This event is signalled, when the these fields should be reset to their default * value (usually called from Packet.clear) */ - async event void clear(data_t* data); + async event void clear(message_t* msg); } diff --git a/tos/chips/rf2xx/util/PacketFlag.nc b/tos/chips/rf2xx/util/PacketFlag.nc new file mode 100644 index 00000000..3efabdb2 --- /dev/null +++ b/tos/chips/rf2xx/util/PacketFlag.nc @@ -0,0 +1,45 @@ +/* + * 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 + */ + +interface PacketFlag +{ + /** + * Returns if the flag is set for this message. + */ + async command bool get(message_t* msg); + + /** + * Sets the flag in this message to the specified value. + */ + async command void setValue(message_t* msg, bool value); + + /** + * Sets the flag in this message to TRUE + */ + async command void set(message_t* msg); + + /** + * Sets the flag in this message to FALSE + */ + async command void clear(message_t* msg); +} diff --git a/tos/platforms/iris/TimeSyncMessageC.nc b/tos/platforms/iris/TimeSyncMessageC.nc index 2acab4c0..04a764e8 100644 --- a/tos/platforms/iris/TimeSyncMessageC.nc +++ b/tos/platforms/iris/TimeSyncMessageC.nc @@ -44,7 +44,7 @@ configuration TimeSyncMessageC implementation { - components GenericTimeSyncMessageC as MAC, LocalTimeMicroC, RF230PacketC; + components GenericTimeSyncMessageC as MAC, LocalTimeMicroC, RF230DriverLayerC; SplitControl = MAC; Receive = MAC.Receive; @@ -57,6 +57,6 @@ implementation TimeSyncAMSendMilli = MAC; TimeSyncPacketMilli = MAC; - MAC.PacketTimeSyncOffset -> RF230PacketC.PacketTimeSyncOffset; + MAC.PacketTimeSyncOffset -> RF230DriverLayerC.PacketTimeSyncOffset; MAC.LocalTimeRadio -> LocalTimeMicroC; } diff --git a/tos/platforms/iris/chips/rf230/HplRF230C.nc b/tos/platforms/iris/chips/rf230/HplRF230C.nc index 3753b483..dd4285a4 100644 --- a/tos/platforms/iris/chips/rf230/HplRF230C.nc +++ b/tos/platforms/iris/chips/rf230/HplRF230C.nc @@ -36,6 +36,7 @@ configuration HplRF230C interface GpioCapture as IRQ; interface Alarm as Alarm; + interface LocalTime as LocalTimeRadio; } } @@ -64,4 +65,7 @@ implementation components RealMainP; RealMainP.PlatformInit -> HplRF230P.PlatformInit; + + components LocalTimeMicroC; + LocalTimeRadio = LocalTimeMicroC; } diff --git a/tos/platforms/iris/chips/rf230/RadioConfig.h b/tos/platforms/iris/chips/rf230/RadioConfig.h index 6f598905..f3896a0f 100644 --- a/tos/platforms/iris/chips/rf230/RadioConfig.h +++ b/tos/platforms/iris/chips/rf230/RadioConfig.h @@ -25,7 +25,7 @@ #define __RADIOCONFIG_H__ #include -#include +#include #include enum diff --git a/tos/platforms/iris/platform_message.h b/tos/platforms/iris/platform_message.h index e3245c96..387d74fe 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