]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
rename RF230 specific files to conform the TEP naming conventions
authormmaroti <mmaroti>
Fri, 16 May 2008 17:43:48 +0000 (17:43 +0000)
committermmaroti <mmaroti>
Fri, 16 May 2008 17:43:48 +0000 (17:43 +0000)
15 files changed:
apps/tests/rf230/RF230Sniffer/RF230SnifferC.nc
apps/tests/rf230/RF230Sniffer/RF230SnifferP.nc
apps/tests/rf230/RF230Test/RF230TestC.nc
tos/chips/rf230/DefaultMacC.nc [deleted file]
tos/chips/rf230/DefaultMacP.nc [deleted file]
tos/chips/rf230/DefaultPacket.h [deleted file]
tos/chips/rf230/DefaultPacketC.nc [deleted file]
tos/chips/rf230/DefaultPacketP.nc [deleted file]
tos/chips/rf230/RF230ActiveMessageC.nc [new file with mode: 0644]
tos/chips/rf230/RF230ActiveMessageP.nc [new file with mode: 0644]
tos/chips/rf230/RF230Packet.h [new file with mode: 0644]
tos/chips/rf230/RF230PacketC.nc [new file with mode: 0644]
tos/chips/rf230/RF230PacketP.nc [new file with mode: 0644]
tos/platforms/iris/ActiveMessageC.nc
tos/platforms/iris/platform_message.h

index d5ad506c0aa176b4e4782482b0e9869af579b462..43d495a733c86e783b24fb1da34e200150b86d4d 100644 (file)
@@ -27,17 +27,18 @@ configuration RF230SnifferC
 
 implementation
 {
-       components RF230SnifferP, MainC, SerialActiveMessageC, RF230LayerC, DefaultMacP, DefaultPacketC, IEEE154PacketC, AssertC;
+       components RF230SnifferP, MainC, SerialActiveMessageC, RF230LayerC, RF230ActiveMessageP, RF230PacketC, IEEE154PacketC, AssertC;
 
        RF230SnifferP.Boot -> MainC;
        RF230SnifferP.SplitControl -> SerialActiveMessageC;
 
        RF230SnifferP.RadioState -> RF230LayerC;
 
-       RF230LayerC.RF230Config -> DefaultMacP;
-       RF230LayerC.PacketLinkQuality -> DefaultPacketC.PacketLinkQuality;
-       RF230LayerC.PacketTransmitPower -> DefaultPacketC.PacketTransmitPower;
-       RF230LayerC.PacketTimeStamp -> DefaultPacketC.PacketTimeStamp;
+       RF230LayerC.RF230Config -> RF230ActiveMessageP;
+       RF230LayerC.PacketLinkQuality -> RF230PacketC.PacketLinkQuality;
+       RF230LayerC.PacketRSSI -> RF230PacketC.PacketRSSI;
+       RF230LayerC.PacketTransmitPower -> RF230PacketC.PacketTransmitPower;
+       RF230LayerC.PacketTimeStamp -> RF230PacketC.PacketTimeStamp;
 
-       DefaultMacP.IEEE154Packet -> IEEE154PacketC;
+       RF230ActiveMessageP.IEEE154Packet -> IEEE154PacketC;
 }
index 96187bd9733d052591a24cdf1df6e7c99b607196..98bd7f7c75d9fccead680269d382bb7fe9cd7e72 100644 (file)
@@ -21,7 +21,7 @@
  * Author: Miklos Maroti
  */
 
-#include <DefaultPacket.h>
+#include <RF230Packet.h>
 #include <Tasklet.h>
 #include <message.h>
 
index 9bdc578f555bcb740f90604d80aecf470b23a0c6..27463abf23659bfe72807e123abc09c3edeeda00 100644 (file)
@@ -37,8 +37,8 @@ implementation
        RF230TestM.SplitControl -> SerialActiveMessageC;
        RF230TestM.Timer -> TimerMilliC;
 
-       components RF230LayerC, DefaultMacC;
+       components RF230LayerC, RF230ActiveMessageC;
 
        RF230TestM.RadioState -> RF230LayerC;
-       RF230TestM.AMSend -> DefaultMacC;
+       RF230TestM.AMSend -> RF230ActiveMessageC;
 }
diff --git a/tos/chips/rf230/DefaultMacC.nc b/tos/chips/rf230/DefaultMacC.nc
deleted file mode 100644 (file)
index 105100e..0000000
+++ /dev/null
@@ -1,143 +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 <HplRF230.h>
-
-configuration DefaultMacC
-{
-       provides 
-       {
-               interface SplitControl;
-
-               interface AMSend[am_id_t id];
-               interface Receive[am_id_t id];
-               interface Receive as Snoop[am_id_t id];
-
-               interface Packet;
-               interface AMPacket;
-               interface PacketAcknowledgements;
-               interface LowPowerListening;
-
-               interface PacketField<uint8_t> as PacketLinkQuality;
-               interface PacketField<uint8_t> as PacketTransmitPower;
-               interface PacketField<uint8_t> as PacketRSSI;
-               interface PacketTimeStamp<TRF230, uint16_t>;
-
-               interface PacketLastTouch;
-       }
-}
-
-implementation
-{
-       components DefaultMacP, DefaultPacketC, IEEE154PacketC, RadioAlarmC;
-
-#ifdef RF230_DEBUG
-       components AssertC;
-#endif
-
-       DefaultMacP.IEEE154Packet -> IEEE154PacketC;
-       DefaultMacP.Packet -> DefaultPacketC;
-       DefaultMacP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
-
-       Packet = DefaultPacketC;
-       AMPacket = DefaultPacketC;
-       PacketAcknowledgements = DefaultPacketC;
-       PacketLinkQuality = DefaultPacketC.PacketLinkQuality;
-       PacketTransmitPower = DefaultPacketC.PacketTransmitPower;
-       PacketRSSI = DefaultPacketC.PacketRSSI;
-       PacketTimeStamp = DefaultPacketC.PacketTimeStamp;
-       LowPowerListening = LowPowerListeningLayerC;
-
-       PacketLastTouch = DefaultPacketC;
-       RF230LayerC.lastTouch -> DefaultPacketC.lastTouch;
-
-       components ActiveMessageLayerC;
-#ifdef LOW_POWER_LISTENING
-       components LowPowerListeningLayerC;
-#else  
-       components new DummyLayerC() as LowPowerListeningLayerC;
-#endif
-       components MessageBufferLayerC;
-       components UniqueLayerC;
-       components TrafficMonitorLayerC;
-#ifdef RF230_SLOTTED_MAC
-       components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
-#else
-       components RandomCollisionLayerC as CollisionAvoidanceLayerC;
-#endif
-       components SoftwareAckLayerC;
-       components new DummyLayerC() as CsmaLayerC;
-       components RF230LayerC;
-
-       SplitControl = LowPowerListeningLayerC;
-       AMSend = ActiveMessageLayerC;
-       Receive = ActiveMessageLayerC.Receive;
-       Snoop = ActiveMessageLayerC.Snoop;
-
-       ActiveMessageLayerC.Config -> DefaultMacP;
-       ActiveMessageLayerC.AMPacket -> IEEE154PacketC;
-       ActiveMessageLayerC.SubSend -> UniqueLayerC;
-       ActiveMessageLayerC.SubReceive -> LowPowerListeningLayerC;
-
-       UniqueLayerC.Config -> DefaultMacP;
-       UniqueLayerC.SubSend -> LowPowerListeningLayerC;
-
-       LowPowerListeningLayerC.SubControl -> MessageBufferLayerC;
-       LowPowerListeningLayerC.SubSend -> MessageBufferLayerC;
-       LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
-#ifdef LOW_POWER_LISTENING
-       LowPowerListeningLayerC.PacketSleepInterval -> DefaultPacketC;
-       LowPowerListeningLayerC.IEEE154Packet -> IEEE154PacketC;
-       LowPowerListeningLayerC.PacketAcknowledgements -> DefaultPacketC;
-#endif
-
-       MessageBufferLayerC.Packet -> DefaultPacketC;
-       MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
-       MessageBufferLayerC.RadioReceive -> UniqueLayerC;
-       MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
-
-       UniqueLayerC.SubReceive -> TrafficMonitorLayerC;
-
-       TrafficMonitorLayerC.Config -> DefaultMacP;
-       TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
-       TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC;
-       TrafficMonitorLayerC.SubState -> RF230LayerC;
-
-       CollisionAvoidanceLayerC.Config -> DefaultMacP;
-       CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC;
-       CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC;
-
-       SoftwareAckLayerC.Config -> DefaultMacP;
-       SoftwareAckLayerC.SubSend -> CsmaLayerC;
-       SoftwareAckLayerC.SubReceive -> RF230LayerC;
-
-       CsmaLayerC.Config -> DefaultMacP;
-       CsmaLayerC -> RF230LayerC.RadioSend;
-       CsmaLayerC -> RF230LayerC.RadioCCA;
-
-       RF230LayerC.RF230Config -> DefaultMacP;
-       RF230LayerC.PacketLinkQuality -> DefaultPacketC.PacketLinkQuality;
-       RF230LayerC.PacketTransmitPower -> DefaultPacketC.PacketTransmitPower;
-       RF230LayerC.PacketRSSI -> DefaultPacketC.PacketRSSI;
-       RF230LayerC.PacketTimeStamp -> DefaultPacketC.PacketTimeStamp;
-}
diff --git a/tos/chips/rf230/DefaultMacP.nc b/tos/chips/rf230/DefaultMacP.nc
deleted file mode 100644 (file)
index ddd131f..0000000
+++ /dev/null
@@ -1,298 +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 <DefaultPacket.h>
-#include <HplRF230.h>
-#include <Tasklet.h>
-
-module DefaultMacP
-{
-       provides
-       {
-               interface RF230Config;
-               interface SoftwareAckConfig;
-               interface UniqueConfig;
-               interface CsmaConfig;
-               interface TrafficMonitorConfig;
-               interface RandomCollisionConfig;
-               interface SlottedCollisionConfig;
-               interface ActiveMessageConfig;
-               interface DummyConfig;
-       }
-
-       uses
-       {
-               interface IEEE154Packet;
-               interface Packet;
-               interface RadioAlarm;
-       }
-}
-
-implementation
-{
-/*----------------- RF230Config -----------------*/
-
-       async command uint8_t RF230Config.getLength(message_t* msg)
-       {
-               return call IEEE154Packet.getLength(msg);
-       }
-
-       async command void RF230Config.setLength(message_t* msg, uint8_t len)
-       {
-               call IEEE154Packet.setLength(msg, len);
-       }
-
-       async command uint8_t* RF230Config.getPayload(message_t* msg)
-       {
-               return ((uint8_t*)(call IEEE154Packet.getHeader(msg))) + 1;
-       }
-
-       inline defpacket_metadata_t* getMeta(message_t* msg)
-       {
-               return (defpacket_metadata_t*)(msg->metadata);
-       }
-
-       async command uint8_t RF230Config.getHeaderLength()
-       {
-               // we need the fcf, dsn, destpan and dest
-               return 7;
-       }
-
-       async command uint8_t RF230Config.getMaxLength()
-       {
-               // note, that the ieee154_footer_t is not stored, but we should include it here
-               return sizeof(defpacket_header_t) - 1 + TOSH_DATA_LENGTH + sizeof(ieee154_footer_t);
-       }
-
-       async command uint8_t RF230Config.getDefaultChannel()
-       {
-               return RF230_DEF_CHANNEL;
-       }
-
-       async command bool RF230Config.requiresRssiCca(message_t* msg)
-       {
-               return call IEEE154Packet.isDataFrame(msg);
-       }
-
-/*----------------- SoftwareAckConfig -----------------*/
-
-       async command bool SoftwareAckConfig.requiresAckWait(message_t* msg)
-       {
-               return call IEEE154Packet.requiresAckWait(msg);
-       }
-
-       async command bool SoftwareAckConfig.isAckPacket(message_t* msg)
-       {
-               return call IEEE154Packet.isAckFrame(msg);
-       }
-
-       async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack)
-       {
-               return call IEEE154Packet.verifyAckReply(data, ack);
-       }
-
-       async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
-       {
-               return call IEEE154Packet.requiresAckReply(msg);
-       }
-
-       async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
-       {
-               call IEEE154Packet.createAckReply(data, ack);
-       }
-
-       async command void SoftwareAckConfig.setAckReceived(message_t* msg, bool acked)
-       {
-               if( acked )
-                       getMeta(msg)->flags |= DEFPACKET_WAS_ACKED;
-               else
-                       getMeta(msg)->flags &= ~DEFPACKET_WAS_ACKED;
-       }
-
-       async command uint16_t SoftwareAckConfig.getAckTimeout()
-       {
-               return (uint16_t)(800 * RF230_ALARM_MICROSEC);
-       }
-
-       tasklet_async command void SoftwareAckConfig.reportChannelError()
-       {
-               signal TrafficMonitorConfig.channelError();
-       }
-
-/*----------------- UniqueConfig -----------------*/
-
-       async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg)
-       {
-               return call IEEE154Packet.getDSN(msg);
-       }
-
-       async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn)
-       {
-               call IEEE154Packet.setDSN(msg, dsn);
-       }
-
-       async command am_addr_t UniqueConfig.getSender(message_t* msg)
-       {
-               return call IEEE154Packet.getSrcAddr(msg);
-       }
-
-       tasklet_async command void UniqueConfig.reportChannelError()
-       {
-               signal TrafficMonitorConfig.channelError();
-       }
-
-/*----------------- ActiveMessageConfig -----------------*/
-
-       command error_t ActiveMessageConfig.checkPacket(message_t* msg)
-       {
-               // the user forgot to call clear, we should return EINVAL
-               if( ! call IEEE154Packet.isDataFrame(msg) )
-                       call Packet.clear(msg);
-
-               return SUCCESS;
-       }
-
-/*----------------- CsmaConfig -----------------*/
-
-       async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg)
-       {
-               return call IEEE154Packet.isDataFrame(msg);
-       }
-
-/*----------------- TrafficMonitorConfig -----------------*/
-
-       enum
-       {
-               TRAFFIC_UPDATE_PERIOD = 100,    // in milliseconds
-               TRAFFIC_MAX_BYTES = (uint16_t)(TRAFFIC_UPDATE_PERIOD * 1000.0 / 32),    // 3125
-       };
-
-       async command uint16_t TrafficMonitorConfig.getUpdatePeriod()
-       {
-               return TRAFFIC_UPDATE_PERIOD;
-       }
-
-       async command uint16_t TrafficMonitorConfig.getChannelTime(message_t* msg)
-       {
-               /* We count in bytes, one byte is 32 microsecond. We are conservative here.
-                *
-                * pure airtime: preable (4 bytes), SFD (1 byte), length (1 byte), payload + CRC (len bytes)
-                * frame separation: 5-10 bytes
-                * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation
-                */
-
-               uint8_t len = call IEEE154Packet.getLength(msg);
-               return call IEEE154Packet.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
-       }
-
-       async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg)
-       {
-               return call IEEE154Packet.getSrcAddr(msg);
-       }
-
-       tasklet_async command void TrafficMonitorConfig.timerTick()
-       {
-               signal SlottedCollisionConfig.timerTick();
-       }
-
-/*----------------- RandomCollisionConfig -----------------*/
-
-       /*
-        * We try to use the same values as in CC2420
-        *
-        * CC2420_MIN_BACKOFF = 10 jiffies = 320 microsec
-        * CC2420_BACKOFF_PERIOD = 10 jiffies
-        * initial backoff = 0x1F * CC2420_BACKOFF_PERIOD = 310 jiffies = 9920 microsec
-        * congestion backoff = 0x7 * CC2420_BACKOFF_PERIOD = 70 jiffies = 2240 microsec
-        */
-
-       async command uint16_t RandomCollisionConfig.getMinimumBackoff()
-       {
-               return (uint16_t)(320 * RF230_ALARM_MICROSEC);
-       }
-
-       async command uint16_t RandomCollisionConfig.getInitialBackoff(message_t* msg)
-       {
-               return (uint16_t)(9920 * RF230_ALARM_MICROSEC);
-       }
-
-       async command uint16_t RandomCollisionConfig.getCongestionBackoff(message_t* msg)
-       {
-               return (uint16_t)(2240 * RF230_ALARM_MICROSEC);
-       }
-
-       async command uint16_t RandomCollisionConfig.getTransmitBarrier(message_t* msg)
-       {
-               uint16_t time;
-
-               // TODO: maybe we should use the embedded timestamp of the message
-               time = call RadioAlarm.getNow();
-
-               // estimated response time (download the message, etc) is 5-8 bytes
-               if( call IEEE154Packet.requiresAckReply(msg) )
-                       time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RF230_ALARM_MICROSEC);
-               else
-                       time += (uint16_t)(32 * (-5 + 5) * RF230_ALARM_MICROSEC);
-
-               return time;
-       }
-
-       tasklet_async event void RadioAlarm.fired()     { }
-
-/*----------------- SlottedCollisionConfig -----------------*/
-
-       async command uint16_t SlottedCollisionConfig.getInitialDelay()
-       {
-               return 300;
-       }
-
-       async command uint8_t SlottedCollisionConfig.getScheduleExponent()
-       {
-               return 11;
-       }
-
-       async command uint16_t SlottedCollisionConfig.getTransmitTime(message_t* msg)
-       {
-               // TODO: check if the timestamp is correct
-               return getMeta(msg)->timestamp;
-       }
-
-       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 * RF230_ALARM_MICROSEC);
-       }
-
-       async command uint16_t SlottedCollisionConfig.getCollisionWindowLength(message_t* msg)
-       {
-               return (uint16_t)(2 * 7 * 32 * RF230_ALARM_MICROSEC);
-       }
-
-       default tasklet_async event void SlottedCollisionConfig.timerTick() { }
-
-/*----------------- Dummy -----------------*/
-
-       async command void DummyConfig.nothing()
-       {
-       }
-}
diff --git a/tos/chips/rf230/DefaultPacket.h b/tos/chips/rf230/DefaultPacket.h
deleted file mode 100644 (file)
index 98cc340..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2007, Vanderbilt University
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
- * 
- * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
- * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
- * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Author: Miklos Maroti
- */
-
-#ifndef __DEFAULTPACKET_H__
-#define __DEFAULTPACKET_H__
-
-#include <IEEE154Packet.h>
-#include <TimeSyncMessage.h>
-
-typedef ieee154_header_t defpacket_header_t;
-
-typedef nx_struct defpacket_footer_t
-{
-       timesync_footer_t timesync;
-} defpacket_footer_t;
-
-typedef nx_struct defpacket_metadata_t
-{
-       nx_uint8_t flags;
-       nx_uint8_t lqi;
-       nx_uint8_t power;                               // shared between TXPOWER and RSSI
-       nx_uint16_t timestamp;
-} defpacket_metadata_t;
-
-enum defpacket_metadata_flags
-{
-       DEFPACKET_WAS_ACKED = 0x01,             // PacketAcknowledgements
-       DEFPACKET_TIMESTAMP = 0x02,             // PacketTimeStamp
-       DEFPACKET_LAST_TOUCH = 0x04,    // PacketLastTouch.touch
-       DEFPACKET_TXPOWER = 0x10,               // PacketTransmitPower
-       DEFPACKET_RSSI = 0x20,                  // PacketRSSI
-
-       DEFPACKET_CLEAR_METADATA = 0x00,
-};
-
-#endif//__DEFAULTPACKET_H__
diff --git a/tos/chips/rf230/DefaultPacketC.nc b/tos/chips/rf230/DefaultPacketC.nc
deleted file mode 100644 (file)
index f101b32..0000000
+++ /dev/null
@@ -1,62 +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 <HplRF230.h>
-
-configuration DefaultPacketC
-{
-       provides
-       {
-               interface Packet;
-               interface AMPacket;
-               interface PacketAcknowledgements;
-               interface PacketField<uint8_t> as PacketLinkQuality;
-               interface PacketField<uint8_t> as PacketTransmitPower;
-               interface PacketField<uint8_t> as PacketRSSI;
-               interface PacketField<uint16_t> as PacketSleepInterval;
-
-               interface PacketTimeStamp<TRF230, uint16_t>;
-               interface PacketLastTouch;
-
-               async event void lastTouch(message_t* msg);
-       }
-}
-
-implementation
-{
-       components DefaultPacketP, IEEE154PacketC;
-
-       DefaultPacketP.IEEE154Packet -> IEEE154PacketC;
-
-       Packet = DefaultPacketP;
-       AMPacket = IEEE154PacketC;
-       PacketAcknowledgements = DefaultPacketP;
-       PacketLinkQuality = DefaultPacketP.PacketLinkQuality;
-       PacketTransmitPower = DefaultPacketP.PacketTransmitPower;
-       PacketRSSI = DefaultPacketP.PacketRSSI;
-       PacketSleepInterval = DefaultPacketP.PacketSleepInterval;
-       PacketTimeStamp = DefaultPacketP;
-
-       PacketLastTouch = DefaultPacketP;
-       lastTouch = DefaultPacketP;
-}
diff --git a/tos/chips/rf230/DefaultPacketP.nc b/tos/chips/rf230/DefaultPacketP.nc
deleted file mode 100644 (file)
index bdc9964..0000000
+++ /dev/null
@@ -1,274 +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 <DefaultPacket.h>
-
-module DefaultPacketP
-{
-       provides
-       {
-               interface PacketAcknowledgements;
-               interface Packet;
-               interface PacketField<uint8_t> as PacketLinkQuality;
-               interface PacketField<uint8_t> as PacketTransmitPower;
-               interface PacketField<uint8_t> as PacketRSSI;
-               interface PacketField<uint16_t> as PacketSleepInterval;
-
-               interface PacketTimeStamp<TRF230, uint16_t>;
-               interface PacketLastTouch;
-
-               async event void lastTouch(message_t* msg);
-       }
-
-       uses
-       {
-               interface IEEE154Packet;
-       }
-}
-
-implementation
-{
-       enum
-       {
-               PACKET_LENGTH_INCREASE = 
-                       sizeof(defpacket_header_t) - 1  // the 8-bit length field is not counted
-                       + sizeof(ieee154_footer_t),             // the CRC is not stored in memory
-       };
-
-       inline defpacket_metadata_t* getMeta(message_t* msg)
-       {
-               return (defpacket_metadata_t*)(msg->metadata);
-       }
-
-/*----------------- Packet -----------------*/
-
-       command void Packet.clear(message_t* msg) 
-       {
-               call IEEE154Packet.createDataFrame(msg);
-
-#ifdef IEEE154_6LOWPAN
-               call IEEE154Packet.set6LowPan(msg, TINYOS_6LOWPAN_NETWORK_ID);
-#endif
-
-               getMeta(msg)->flags = DEFPACKET_CLEAR_METADATA;
-       }
-
-       inline command void Packet.setPayloadLength(message_t* msg, uint8_t len) 
-       {
-               call IEEE154Packet.setLength(msg, len + PACKET_LENGTH_INCREASE);
-       }
-
-       // TODO: make Packet.payloadLength async
-       inline command uint8_t Packet.payloadLength(message_t* msg) 
-       {
-               return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE;
-       }
-
-       // TODO: make Packet.maxPayloadLength async
-       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 IEEE154Packet.setAckRequired(msg, TRUE);
-
-               return SUCCESS;
-       }
-
-       async command error_t PacketAcknowledgements.noAck(message_t* msg)
-       {
-               call IEEE154Packet.setAckRequired(msg, FALSE);
-
-               return SUCCESS;
-       }
-
-       async command bool PacketAcknowledgements.wasAcked(message_t* msg)
-       {
-               return getMeta(msg)->flags & DEFPACKET_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;
-       }
-
-/*----------------- PacketTimeStamp -----------------*/
-
-       async command bool PacketTimeStamp.isSet(message_t* msg)
-       {
-               return getMeta(msg)->flags & DEFPACKET_TIMESTAMP;
-       }
-
-       async command uint16_t PacketTimeStamp.get(message_t* msg)
-       {
-               return getMeta(msg)->timestamp;
-       }
-
-       async command void PacketTimeStamp.clear(message_t* msg)
-       {
-               getMeta(msg)->flags &= ~DEFPACKET_TIMESTAMP;
-       }
-
-       async command void PacketTimeStamp.set(message_t* msg, uint16_t value)
-       {
-               getMeta(msg)->flags |= DEFPACKET_TIMESTAMP;
-               getMeta(msg)->timestamp = value;
-       }
-
-/*----------------- PacketTransmitPower -----------------*/
-
-       async command bool PacketTransmitPower.isSet(message_t* msg)
-       {
-               return getMeta(msg)->flags & DEFPACKET_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 &= ~DEFPACKET_TXPOWER;
-       }
-
-       async command void PacketTransmitPower.set(message_t* msg, uint8_t value)
-       {
-               getMeta(msg)->flags &= ~DEFPACKET_RSSI;
-               getMeta(msg)->flags |= DEFPACKET_TXPOWER;
-               getMeta(msg)->power = value;
-       }
-
-/*----------------- PacketRSSI -----------------*/
-
-       async command bool PacketRSSI.isSet(message_t* msg)
-       {
-               return getMeta(msg)->flags & DEFPACKET_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 &= ~DEFPACKET_RSSI;
-       }
-
-       async command void PacketRSSI.set(message_t* msg, uint8_t value)
-       {
-               getMeta(msg)->flags &= ~DEFPACKET_TXPOWER;
-               getMeta(msg)->flags |= DEFPACKET_RSSI;
-               getMeta(msg)->power = value;
-       }
-
-/*----------------- Global fields -----------------*/
-
-       norace uint8_t flags;
-       enum
-       {
-               FLAG_SLEEPINT = 0x01,
-       };
-
-       // TODO: Move sleepInterval into the metadata
-       norace uint16_t sleepInterval;
-
-/*----------------- PacketSleepInterval -----------------*/
-
-       async command bool PacketSleepInterval.isSet(message_t* msg)
-       {
-               return flags & FLAG_SLEEPINT;
-       }
-
-       async command uint16_t PacketSleepInterval.get(message_t* msg)
-       {
-               return sleepInterval;
-       }
-
-       async command void PacketSleepInterval.clear(message_t* msg)
-       {
-               flags &= ~FLAG_SLEEPINT;
-       }
-
-       async command void PacketSleepInterval.set(message_t* msg, uint16_t value)
-       {
-               flags |= FLAG_SLEEPINT;
-               sleepInterval = value;
-       }
-
-/*----------------- PacketLastTouch -----------------*/
-       
-       async command void PacketLastTouch.request(message_t* msg)
-       {
-               getMeta(msg)->flags |= DEFPACKET_LAST_TOUCH;
-       }
-
-       async command void PacketLastTouch.cancel(message_t* msg)
-       {
-               getMeta(msg)->flags &= ~DEFPACKET_LAST_TOUCH;
-       }
-
-       async command bool PacketLastTouch.isPending(message_t* msg)
-       {
-               return getMeta(msg)->flags & DEFPACKET_LAST_TOUCH;
-       }
-
-       async event void lastTouch(message_t* msg)
-       {
-               if( getMeta(msg)->flags & DEFPACKET_LAST_TOUCH )
-                       signal PacketLastTouch.touch(msg);
-       }
-
-       default async event void PacketLastTouch.touch(message_t* msg)
-       {
-       }
-}
diff --git a/tos/chips/rf230/RF230ActiveMessageC.nc b/tos/chips/rf230/RF230ActiveMessageC.nc
new file mode 100644 (file)
index 0000000..f5b676e
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * 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 <HplRF230.h>
+
+configuration RF230ActiveMessageC
+{
+       provides 
+       {
+               interface SplitControl;
+
+               interface AMSend[am_id_t id];
+               interface Receive[am_id_t id];
+               interface Receive as Snoop[am_id_t id];
+
+               interface Packet;
+               interface AMPacket;
+               interface PacketAcknowledgements;
+               interface LowPowerListening;
+
+               interface PacketField<uint8_t> as PacketLinkQuality;
+               interface PacketField<uint8_t> as PacketTransmitPower;
+               interface PacketField<uint8_t> as PacketRSSI;
+               interface PacketTimeStamp<TRF230, uint16_t>;
+
+               interface PacketLastTouch;
+       }
+}
+
+implementation
+{
+       components RF230ActiveMessageP, RF230PacketC, IEEE154PacketC, RadioAlarmC;
+
+#ifdef RF230_DEBUG
+       components AssertC;
+#endif
+
+       RF230ActiveMessageP.IEEE154Packet -> IEEE154PacketC;
+       RF230ActiveMessageP.Packet -> RF230PacketC;
+       RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
+
+       Packet = RF230PacketC;
+       AMPacket = RF230PacketC;
+       PacketAcknowledgements = RF230PacketC;
+       PacketLinkQuality = RF230PacketC.PacketLinkQuality;
+       PacketTransmitPower = RF230PacketC.PacketTransmitPower;
+       PacketRSSI = RF230PacketC.PacketRSSI;
+       PacketTimeStamp = RF230PacketC.PacketTimeStamp;
+       LowPowerListening = LowPowerListeningLayerC;
+
+       PacketLastTouch = RF230PacketC;
+       RF230LayerC.lastTouch -> RF230PacketC.lastTouch;
+
+       components ActiveMessageLayerC;
+#ifdef LOW_POWER_LISTENING
+       components LowPowerListeningLayerC;
+#else  
+       components new DummyLayerC() as LowPowerListeningLayerC;
+#endif
+       components MessageBufferLayerC;
+       components UniqueLayerC;
+       components TrafficMonitorLayerC;
+#ifdef RF230_SLOTTED_MAC
+       components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
+#else
+       components RandomCollisionLayerC as CollisionAvoidanceLayerC;
+#endif
+       components SoftwareAckLayerC;
+       components new DummyLayerC() as CsmaLayerC;
+       components RF230LayerC;
+
+       SplitControl = LowPowerListeningLayerC;
+       AMSend = ActiveMessageLayerC;
+       Receive = ActiveMessageLayerC.Receive;
+       Snoop = ActiveMessageLayerC.Snoop;
+
+       ActiveMessageLayerC.Config -> RF230ActiveMessageP;
+       ActiveMessageLayerC.AMPacket -> IEEE154PacketC;
+       ActiveMessageLayerC.SubSend -> UniqueLayerC;
+       ActiveMessageLayerC.SubReceive -> LowPowerListeningLayerC;
+
+       UniqueLayerC.Config -> RF230ActiveMessageP;
+       UniqueLayerC.SubSend -> LowPowerListeningLayerC;
+
+       LowPowerListeningLayerC.SubControl -> MessageBufferLayerC;
+       LowPowerListeningLayerC.SubSend -> MessageBufferLayerC;
+       LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
+#ifdef LOW_POWER_LISTENING
+       LowPowerListeningLayerC.PacketSleepInterval -> RF230PacketC;
+       LowPowerListeningLayerC.IEEE154Packet -> IEEE154PacketC;
+       LowPowerListeningLayerC.PacketAcknowledgements -> RF230PacketC;
+#endif
+
+       MessageBufferLayerC.Packet -> RF230PacketC;
+       MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
+       MessageBufferLayerC.RadioReceive -> UniqueLayerC;
+       MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
+
+       UniqueLayerC.SubReceive -> TrafficMonitorLayerC;
+
+       TrafficMonitorLayerC.Config -> RF230ActiveMessageP;
+       TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
+       TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC;
+       TrafficMonitorLayerC.SubState -> RF230LayerC;
+
+       CollisionAvoidanceLayerC.Config -> RF230ActiveMessageP;
+       CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC;
+       CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC;
+
+       SoftwareAckLayerC.Config -> RF230ActiveMessageP;
+       SoftwareAckLayerC.SubSend -> CsmaLayerC;
+       SoftwareAckLayerC.SubReceive -> RF230LayerC;
+
+       CsmaLayerC.Config -> RF230ActiveMessageP;
+       CsmaLayerC -> RF230LayerC.RadioSend;
+       CsmaLayerC -> RF230LayerC.RadioCCA;
+
+       RF230LayerC.RF230Config -> RF230ActiveMessageP;
+       RF230LayerC.PacketLinkQuality -> RF230PacketC.PacketLinkQuality;
+       RF230LayerC.PacketTransmitPower -> RF230PacketC.PacketTransmitPower;
+       RF230LayerC.PacketRSSI -> RF230PacketC.PacketRSSI;
+       RF230LayerC.PacketTimeStamp -> RF230PacketC.PacketTimeStamp;
+}
diff --git a/tos/chips/rf230/RF230ActiveMessageP.nc b/tos/chips/rf230/RF230ActiveMessageP.nc
new file mode 100644 (file)
index 0000000..b241ee5
--- /dev/null
@@ -0,0 +1,298 @@
+/*
+ * 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 <RF230Packet.h>
+#include <HplRF230.h>
+#include <Tasklet.h>
+
+module RF230ActiveMessageP
+{
+       provides
+       {
+               interface RF230Config;
+               interface SoftwareAckConfig;
+               interface UniqueConfig;
+               interface CsmaConfig;
+               interface TrafficMonitorConfig;
+               interface RandomCollisionConfig;
+               interface SlottedCollisionConfig;
+               interface ActiveMessageConfig;
+               interface DummyConfig;
+       }
+
+       uses
+       {
+               interface IEEE154Packet;
+               interface Packet;
+               interface RadioAlarm;
+       }
+}
+
+implementation
+{
+/*----------------- RF230Config -----------------*/
+
+       async command uint8_t RF230Config.getLength(message_t* msg)
+       {
+               return call IEEE154Packet.getLength(msg);
+       }
+
+       async command void RF230Config.setLength(message_t* msg, uint8_t len)
+       {
+               call IEEE154Packet.setLength(msg, len);
+       }
+
+       async command uint8_t* RF230Config.getPayload(message_t* msg)
+       {
+               return ((uint8_t*)(call IEEE154Packet.getHeader(msg))) + 1;
+       }
+
+       inline rf230packet_metadata_t* getMeta(message_t* msg)
+       {
+               return (rf230packet_metadata_t*)(msg->metadata);
+       }
+
+       async command uint8_t RF230Config.getHeaderLength()
+       {
+               // we need the fcf, dsn, destpan and dest
+               return 7;
+       }
+
+       async command uint8_t RF230Config.getMaxLength()
+       {
+               // note, that the ieee154_footer_t is not stored, but we should include it here
+               return sizeof(rf230packet_header_t) - 1 + TOSH_DATA_LENGTH + sizeof(ieee154_footer_t);
+       }
+
+       async command uint8_t RF230Config.getDefaultChannel()
+       {
+               return RF230_DEF_CHANNEL;
+       }
+
+       async command bool RF230Config.requiresRssiCca(message_t* msg)
+       {
+               return call IEEE154Packet.isDataFrame(msg);
+       }
+
+/*----------------- SoftwareAckConfig -----------------*/
+
+       async command bool SoftwareAckConfig.requiresAckWait(message_t* msg)
+       {
+               return call IEEE154Packet.requiresAckWait(msg);
+       }
+
+       async command bool SoftwareAckConfig.isAckPacket(message_t* msg)
+       {
+               return call IEEE154Packet.isAckFrame(msg);
+       }
+
+       async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack)
+       {
+               return call IEEE154Packet.verifyAckReply(data, ack);
+       }
+
+       async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
+       {
+               return call IEEE154Packet.requiresAckReply(msg);
+       }
+
+       async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
+       {
+               call IEEE154Packet.createAckReply(data, ack);
+       }
+
+       async command void SoftwareAckConfig.setAckReceived(message_t* msg, bool acked)
+       {
+               if( acked )
+                       getMeta(msg)->flags |= RF230PACKET_WAS_ACKED;
+               else
+                       getMeta(msg)->flags &= ~RF230PACKET_WAS_ACKED;
+       }
+
+       async command uint16_t SoftwareAckConfig.getAckTimeout()
+       {
+               return (uint16_t)(800 * RF230_ALARM_MICROSEC);
+       }
+
+       tasklet_async command void SoftwareAckConfig.reportChannelError()
+       {
+               signal TrafficMonitorConfig.channelError();
+       }
+
+/*----------------- UniqueConfig -----------------*/
+
+       async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg)
+       {
+               return call IEEE154Packet.getDSN(msg);
+       }
+
+       async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn)
+       {
+               call IEEE154Packet.setDSN(msg, dsn);
+       }
+
+       async command am_addr_t UniqueConfig.getSender(message_t* msg)
+       {
+               return call IEEE154Packet.getSrcAddr(msg);
+       }
+
+       tasklet_async command void UniqueConfig.reportChannelError()
+       {
+               signal TrafficMonitorConfig.channelError();
+       }
+
+/*----------------- ActiveMessageConfig -----------------*/
+
+       command error_t ActiveMessageConfig.checkPacket(message_t* msg)
+       {
+               // the user forgot to call clear, we should return EINVAL
+               if( ! call IEEE154Packet.isDataFrame(msg) )
+                       call Packet.clear(msg);
+
+               return SUCCESS;
+       }
+
+/*----------------- CsmaConfig -----------------*/
+
+       async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg)
+       {
+               return call IEEE154Packet.isDataFrame(msg);
+       }
+
+/*----------------- TrafficMonitorConfig -----------------*/
+
+       enum
+       {
+               TRAFFIC_UPDATE_PERIOD = 100,    // in milliseconds
+               TRAFFIC_MAX_BYTES = (uint16_t)(TRAFFIC_UPDATE_PERIOD * 1000.0 / 32),    // 3125
+       };
+
+       async command uint16_t TrafficMonitorConfig.getUpdatePeriod()
+       {
+               return TRAFFIC_UPDATE_PERIOD;
+       }
+
+       async command uint16_t TrafficMonitorConfig.getChannelTime(message_t* msg)
+       {
+               /* We count in bytes, one byte is 32 microsecond. We are conservative here.
+                *
+                * pure airtime: preable (4 bytes), SFD (1 byte), length (1 byte), payload + CRC (len bytes)
+                * frame separation: 5-10 bytes
+                * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation
+                */
+
+               uint8_t len = call IEEE154Packet.getLength(msg);
+               return call IEEE154Packet.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
+       }
+
+       async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg)
+       {
+               return call IEEE154Packet.getSrcAddr(msg);
+       }
+
+       tasklet_async command void TrafficMonitorConfig.timerTick()
+       {
+               signal SlottedCollisionConfig.timerTick();
+       }
+
+/*----------------- RandomCollisionConfig -----------------*/
+
+       /*
+        * We try to use the same values as in CC2420
+        *
+        * CC2420_MIN_BACKOFF = 10 jiffies = 320 microsec
+        * CC2420_BACKOFF_PERIOD = 10 jiffies
+        * initial backoff = 0x1F * CC2420_BACKOFF_PERIOD = 310 jiffies = 9920 microsec
+        * congestion backoff = 0x7 * CC2420_BACKOFF_PERIOD = 70 jiffies = 2240 microsec
+        */
+
+       async command uint16_t RandomCollisionConfig.getMinimumBackoff()
+       {
+               return (uint16_t)(320 * RF230_ALARM_MICROSEC);
+       }
+
+       async command uint16_t RandomCollisionConfig.getInitialBackoff(message_t* msg)
+       {
+               return (uint16_t)(9920 * RF230_ALARM_MICROSEC);
+       }
+
+       async command uint16_t RandomCollisionConfig.getCongestionBackoff(message_t* msg)
+       {
+               return (uint16_t)(2240 * RF230_ALARM_MICROSEC);
+       }
+
+       async command uint16_t RandomCollisionConfig.getTransmitBarrier(message_t* msg)
+       {
+               uint16_t time;
+
+               // TODO: maybe we should use the embedded timestamp of the message
+               time = call RadioAlarm.getNow();
+
+               // estimated response time (download the message, etc) is 5-8 bytes
+               if( call IEEE154Packet.requiresAckReply(msg) )
+                       time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RF230_ALARM_MICROSEC);
+               else
+                       time += (uint16_t)(32 * (-5 + 5) * RF230_ALARM_MICROSEC);
+
+               return time;
+       }
+
+       tasklet_async event void RadioAlarm.fired()     { }
+
+/*----------------- SlottedCollisionConfig -----------------*/
+
+       async command uint16_t SlottedCollisionConfig.getInitialDelay()
+       {
+               return 300;
+       }
+
+       async command uint8_t SlottedCollisionConfig.getScheduleExponent()
+       {
+               return 11;
+       }
+
+       async command uint16_t SlottedCollisionConfig.getTransmitTime(message_t* msg)
+       {
+               // TODO: check if the timestamp is correct
+               return getMeta(msg)->timestamp;
+       }
+
+       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 * RF230_ALARM_MICROSEC);
+       }
+
+       async command uint16_t SlottedCollisionConfig.getCollisionWindowLength(message_t* msg)
+       {
+               return (uint16_t)(2 * 7 * 32 * RF230_ALARM_MICROSEC);
+       }
+
+       default tasklet_async event void SlottedCollisionConfig.timerTick() { }
+
+/*----------------- Dummy -----------------*/
+
+       async command void DummyConfig.nothing()
+       {
+       }
+}
diff --git a/tos/chips/rf230/RF230Packet.h b/tos/chips/rf230/RF230Packet.h
new file mode 100644 (file)
index 0000000..b3b0c39
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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 __RF230PACKET_H__
+#define __RF230PACKET_H__
+
+#include <IEEE154Packet.h>
+#include <TimeSyncMessage.h>
+
+typedef ieee154_header_t rf230packet_header_t;
+
+typedef nx_struct rf230packet_footer_t
+{
+       timesync_footer_t timesync;
+} rf230packet_footer_t;
+
+typedef nx_struct rf230packet_metadata_t
+{
+       nx_uint8_t flags;
+       nx_uint8_t lqi;
+       nx_uint8_t power;                               // shared between TXPOWER and RSSI
+       nx_uint16_t timestamp;
+} rf230packet_metadata_t;
+
+enum rf230packet_metadata_flags
+{
+       RF230PACKET_WAS_ACKED = 0x01,           // PacketAcknowledgements
+       RF230PACKET_TIMESTAMP = 0x02,           // PacketTimeStamp
+       RF230PACKET_LAST_TOUCH = 0x04,  // PacketLastTouch.touch
+       RF230PACKET_TXPOWER = 0x10,             // PacketTransmitPower
+       RF230PACKET_RSSI = 0x20,                        // PacketRSSI
+
+       RF230PACKET_CLEAR_METADATA = 0x00,
+};
+
+#endif//__RF230PACKET_H__
diff --git a/tos/chips/rf230/RF230PacketC.nc b/tos/chips/rf230/RF230PacketC.nc
new file mode 100644 (file)
index 0000000..3a60a25
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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 <HplRF230.h>
+
+configuration RF230PacketC
+{
+       provides
+       {
+               interface Packet;
+               interface AMPacket;
+               interface PacketAcknowledgements;
+               interface PacketField<uint8_t> as PacketLinkQuality;
+               interface PacketField<uint8_t> as PacketTransmitPower;
+               interface PacketField<uint8_t> as PacketRSSI;
+               interface PacketField<uint16_t> as PacketSleepInterval;
+
+               interface PacketTimeStamp<TRF230, uint16_t>;
+               interface PacketLastTouch;
+
+               async event void lastTouch(message_t* msg);
+       }
+}
+
+implementation
+{
+       components RF230PacketP, IEEE154PacketC;
+
+       RF230PacketP.IEEE154Packet -> IEEE154PacketC;
+
+       Packet = RF230PacketP;
+       AMPacket = IEEE154PacketC;
+       PacketAcknowledgements = RF230PacketP;
+       PacketLinkQuality = RF230PacketP.PacketLinkQuality;
+       PacketTransmitPower = RF230PacketP.PacketTransmitPower;
+       PacketRSSI = RF230PacketP.PacketRSSI;
+       PacketSleepInterval = RF230PacketP.PacketSleepInterval;
+       PacketTimeStamp = RF230PacketP;
+
+       PacketLastTouch = RF230PacketP;
+       lastTouch = RF230PacketP;
+}
diff --git a/tos/chips/rf230/RF230PacketP.nc b/tos/chips/rf230/RF230PacketP.nc
new file mode 100644 (file)
index 0000000..4458dd8
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * 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 <RF230Packet.h>
+
+module RF230PacketP
+{
+       provides
+       {
+               interface PacketAcknowledgements;
+               interface Packet;
+               interface PacketField<uint8_t> as PacketLinkQuality;
+               interface PacketField<uint8_t> as PacketTransmitPower;
+               interface PacketField<uint8_t> as PacketRSSI;
+               interface PacketField<uint16_t> as PacketSleepInterval;
+
+               interface PacketTimeStamp<TRF230, uint16_t>;
+               interface PacketLastTouch;
+
+               async event void lastTouch(message_t* msg);
+       }
+
+       uses
+       {
+               interface IEEE154Packet;
+       }
+}
+
+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 IEEE154Packet.createDataFrame(msg);
+
+#ifdef IEEE154_6LOWPAN
+               call IEEE154Packet.set6LowPan(msg, TINYOS_6LOWPAN_NETWORK_ID);
+#endif
+
+               getMeta(msg)->flags = RF230PACKET_CLEAR_METADATA;
+       }
+
+       inline command void Packet.setPayloadLength(message_t* msg, uint8_t len) 
+       {
+               call IEEE154Packet.setLength(msg, len + PACKET_LENGTH_INCREASE);
+       }
+
+       // TODO: make Packet.payloadLength async
+       inline command uint8_t Packet.payloadLength(message_t* msg) 
+       {
+               return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE;
+       }
+
+       // TODO: make Packet.maxPayloadLength async
+       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 IEEE154Packet.setAckRequired(msg, TRUE);
+
+               return SUCCESS;
+       }
+
+       async command error_t PacketAcknowledgements.noAck(message_t* msg)
+       {
+               call IEEE154Packet.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;
+       }
+
+/*----------------- PacketTimeStamp -----------------*/
+
+       async command bool PacketTimeStamp.isSet(message_t* msg)
+       {
+               return getMeta(msg)->flags & RF230PACKET_TIMESTAMP;
+       }
+
+       async command uint16_t PacketTimeStamp.get(message_t* msg)
+       {
+               return getMeta(msg)->timestamp;
+       }
+
+       async command void PacketTimeStamp.clear(message_t* msg)
+       {
+               getMeta(msg)->flags &= ~RF230PACKET_TIMESTAMP;
+       }
+
+       async command void PacketTimeStamp.set(message_t* msg, uint16_t value)
+       {
+               getMeta(msg)->flags |= RF230PACKET_TIMESTAMP;
+               getMeta(msg)->timestamp = value;
+       }
+
+/*----------------- 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;
+       }
+
+/*----------------- Global fields -----------------*/
+
+       norace uint8_t flags;
+       enum
+       {
+               FLAG_SLEEPINT = 0x01,
+       };
+
+       // TODO: Move sleepInterval into the metadata
+       norace uint16_t sleepInterval;
+
+/*----------------- PacketSleepInterval -----------------*/
+
+       async command bool PacketSleepInterval.isSet(message_t* msg)
+       {
+               return flags & FLAG_SLEEPINT;
+       }
+
+       async command uint16_t PacketSleepInterval.get(message_t* msg)
+       {
+               return sleepInterval;
+       }
+
+       async command void PacketSleepInterval.clear(message_t* msg)
+       {
+               flags &= ~FLAG_SLEEPINT;
+       }
+
+       async command void PacketSleepInterval.set(message_t* msg, uint16_t value)
+       {
+               flags |= FLAG_SLEEPINT;
+               sleepInterval = value;
+       }
+
+/*----------------- PacketLastTouch -----------------*/
+       
+       async command void PacketLastTouch.request(message_t* msg)
+       {
+               getMeta(msg)->flags |= RF230PACKET_LAST_TOUCH;
+       }
+
+       async command void PacketLastTouch.cancel(message_t* msg)
+       {
+               getMeta(msg)->flags &= ~RF230PACKET_LAST_TOUCH;
+       }
+
+       async command bool PacketLastTouch.isPending(message_t* msg)
+       {
+               return getMeta(msg)->flags & RF230PACKET_LAST_TOUCH;
+       }
+
+       async event void lastTouch(message_t* msg)
+       {
+               if( getMeta(msg)->flags & RF230PACKET_LAST_TOUCH )
+                       signal PacketLastTouch.touch(msg);
+       }
+
+       default async event void PacketLastTouch.touch(message_t* msg)
+       {
+       }
+}
index d86fd0f999dd8505e9109c5e9a6f069d89c9847d..50fc987967a98fef87e97ea0772c544e17969f44 100644 (file)
@@ -45,7 +45,7 @@ configuration ActiveMessageC
 
 implementation
 {
-       components DefaultMacC as MAC;
+       components RF230ActiveMessageC as MAC;
 
        SplitControl = MAC;
        AMSend       = MAC;
index f966cbd58ac4fa1e9552b55493a016496e1bd52d..9bc04c4a8aff86d60dc44f1f3ee08457eeb41e9d 100644 (file)
 #ifndef PLATFORM_MESSAGE_H
 #define PLATFORM_MESSAGE_H
 
-#include <DefaultPacket.h>
+#include <RF230Packet.h>
 #include <Serial.h>
 
 typedef union message_header {
-       defpacket_header_t rf230;
+       rf230packet_header_t rf230;
        serial_header_t serial;
 } message_header_t;
 
 typedef union message_footer {
-       defpacket_footer_t rf230;
+       rf230packet_footer_t rf230;
 } message_footer_t;
 
 typedef union message_metadata {
-       defpacket_metadata_t rf230;
+       rf230packet_metadata_t rf230;
 } message_metadata_t;
 
 #endif