]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
move/create RF2xxTimeSyncMessageC to avoid future changes in platforms
authormmaroti <mmaroti>
Thu, 9 Apr 2009 21:26:39 +0000 (21:26 +0000)
committermmaroti <mmaroti>
Thu, 9 Apr 2009 21:26:39 +0000 (21:26 +0000)
12 files changed:
tos/chips/rf2xx/layers/GenericTimeSyncMessage.h [deleted file]
tos/chips/rf2xx/layers/GenericTimeSyncMessageC.nc [deleted file]
tos/chips/rf2xx/layers/GenericTimeSyncMessageP.nc [deleted file]
tos/chips/rf2xx/layers/TimeSyncMessageLayer.h [new file with mode: 0644]
tos/chips/rf2xx/layers/TimeSyncMessageLayerC.nc [new file with mode: 0644]
tos/chips/rf2xx/layers/TimeSyncMessageLayerP.nc [new file with mode: 0644]
tos/chips/rf2xx/rf212/RF212DriverLayerP.nc
tos/chips/rf2xx/rf212/RF212TimeSyncMessageC.nc [new file with mode: 0644]
tos/chips/rf2xx/rf230/RF230DriverLayerP.nc
tos/chips/rf2xx/rf230/RF230TimeSyncMessageC.nc [new file with mode: 0644]
tos/platforms/iris/ActiveMessageC.nc
tos/platforms/iris/TimeSyncMessageC.nc

diff --git a/tos/chips/rf2xx/layers/GenericTimeSyncMessage.h b/tos/chips/rf2xx/layers/GenericTimeSyncMessage.h
deleted file mode 100644 (file)
index 6f2247f..0000000
+++ /dev/null
@@ -1,33 +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 __GENERICTIMESYNCMESSAGE_H__
-#define __GENERICTIMESYNCMESSAGE_H__
-
-// this value is sent in the air
-typedef nx_int32_t timesync_relative_t;
-
-// this value is stored in memory
-typedef uint32_t timesync_absolute_t;
-
-#endif//__GENERICTIMESYNCMESSAGE_H__
diff --git a/tos/chips/rf2xx/layers/GenericTimeSyncMessageC.nc b/tos/chips/rf2xx/layers/GenericTimeSyncMessageC.nc
deleted file mode 100644 (file)
index d684a83..0000000
+++ /dev/null
@@ -1,78 +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 <Timer.h>
-#include <AM.h>
-#include <RadioConfig.h>
-
-configuration GenericTimeSyncMessageC
-{
-       provides
-       {
-               interface SplitControl;
-
-               interface Receive[uint8_t id];
-               interface Receive as Snoop[am_id_t id];
-               interface Packet;
-               interface AMPacket;
-
-               interface TimeSyncAMSend<TRadio, uint32_t> as TimeSyncAMSendRadio[am_id_t id];
-               interface TimeSyncPacket<TRadio, uint32_t> as TimeSyncPacketRadio;
-
-               interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[am_id_t id];
-               interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
-       }
-
-       uses
-       {
-               interface PacketField<uint8_t> as PacketTimeSyncOffset;
-               interface LocalTime<TRadio> as LocalTimeRadio;
-       }
-}
-
-implementation
-{
-       components GenericTimeSyncMessageP, ActiveMessageC, LocalTimeMilliC;
-
-       TimeSyncAMSendRadio = GenericTimeSyncMessageP;
-       TimeSyncPacketRadio = GenericTimeSyncMessageP;
-
-       TimeSyncAMSendMilli = GenericTimeSyncMessageP;
-       TimeSyncPacketMilli = GenericTimeSyncMessageP;
-
-       Packet = GenericTimeSyncMessageP;
-       GenericTimeSyncMessageP.SubSend -> ActiveMessageC.AMSend;
-       GenericTimeSyncMessageP.SubPacket -> ActiveMessageC.Packet;
-
-       GenericTimeSyncMessageP.PacketTimeStampRadio -> ActiveMessageC;
-       GenericTimeSyncMessageP.PacketTimeStampMilli -> ActiveMessageC;
-       GenericTimeSyncMessageP.LocalTimeRadio = LocalTimeRadio;
-       GenericTimeSyncMessageP.LocalTimeMilli -> LocalTimeMilliC;
-
-       GenericTimeSyncMessageP.PacketTimeSyncOffset = PacketTimeSyncOffset;
-
-       SplitControl = ActiveMessageC;
-       Receive = ActiveMessageC.Receive;
-       Snoop = ActiveMessageC.Snoop;
-       AMPacket = ActiveMessageC;
-}
diff --git a/tos/chips/rf2xx/layers/GenericTimeSyncMessageP.nc b/tos/chips/rf2xx/layers/GenericTimeSyncMessageP.nc
deleted file mode 100644 (file)
index 3ebd71d..0000000
+++ /dev/null
@@ -1,187 +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 <GenericTimeSyncMessage.h>
-#include <RadioConfig.h>
-
-module GenericTimeSyncMessageP
-{
-       provides
-       {
-               interface TimeSyncAMSend<TRadio, uint32_t> as TimeSyncAMSendRadio[uint8_t id];
-               interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[uint8_t id];
-               interface Packet;
-
-               interface TimeSyncPacket<TRadio, uint32_t> as TimeSyncPacketRadio;
-               interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
-       }
-
-       uses
-       {
-               interface AMSend as SubSend[uint8_t id];
-               interface Packet as SubPacket;
-
-               interface PacketTimeStamp<TRadio, uint32_t> as PacketTimeStampRadio;
-               interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
-
-               interface LocalTime<TRadio> as LocalTimeRadio;
-               interface LocalTime<TMilli> as LocalTimeMilli;
-
-               interface PacketField<uint8_t> as PacketTimeSyncOffset;
-       }
-}
-
-implementation
-{
-       inline void* getFooter(message_t* msg)
-       {
-               // we use the payload length that we export (the smaller one)
-               return msg->data + call Packet.payloadLength(msg);
-       }
-
-/*----------------- Packet -----------------*/
-
-       command void Packet.clear(message_t* msg) 
-       {
-               call SubPacket.clear(msg);
-       }
-
-       command void Packet.setPayloadLength(message_t* msg, uint8_t len) 
-       {
-               call SubPacket.setPayloadLength(msg, len + sizeof(timesync_relative_t));
-       }
-
-       command uint8_t Packet.payloadLength(message_t* msg) 
-       {
-               return call SubPacket.payloadLength(msg) - sizeof(timesync_relative_t);
-       }
-
-       command uint8_t Packet.maxPayloadLength()
-       {
-               return call SubPacket.maxPayloadLength() - sizeof(timesync_relative_t);
-       }
-
-       command void* Packet.getPayload(message_t* msg, uint8_t len)
-       {
-               return call SubPacket.getPayload(msg, len + sizeof(timesync_relative_t));
-       }
-
-/*----------------- TimeSyncAMSendRadio -----------------*/
-
-       command error_t TimeSyncAMSendRadio.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len, uint32_t event_time)
-       {
-               *(timesync_absolute_t*)(msg->data + len) = event_time;
-
-               call PacketTimeSyncOffset.set(msg, offsetof(message_t, data) + len);
-
-               return call SubSend.send[id](addr, msg, len + sizeof(timesync_relative_t));
-       }
-
-       command error_t TimeSyncAMSendRadio.cancel[am_id_t id](message_t* msg)
-       {
-               return call SubSend.cancel[id](msg);
-       }
-
-       default event void TimeSyncAMSendRadio.sendDone[am_id_t id](message_t* msg, error_t error)
-       {
-       }
-
-       command uint8_t TimeSyncAMSendRadio.maxPayloadLength[am_id_t id]()
-       {
-               return call SubSend.maxPayloadLength[id]() - sizeof(timesync_relative_t);
-       }
-
-       command void* TimeSyncAMSendRadio.getPayload[am_id_t id](message_t* msg, uint8_t len)
-       {
-               return call SubSend.getPayload[id](msg, len + sizeof(timesync_relative_t));
-       }
-
-/*----------------- TimeSyncAMSendMilli -----------------*/
-
-       command error_t TimeSyncAMSendMilli.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len, uint32_t event_time)
-       {
-               // compute elapsed time in millisecond
-               event_time = ((int32_t)(event_time - call LocalTimeMilli.get()) << RADIO_ALARM_MILLI_EXP) + call LocalTimeRadio.get();
-
-               return call TimeSyncAMSendRadio.send[id](addr, msg, len, event_time);
-       }
-
-       command error_t TimeSyncAMSendMilli.cancel[am_id_t id](message_t* msg)
-       {
-               return call TimeSyncAMSendRadio.cancel[id](msg);
-       }
-
-       default event void TimeSyncAMSendMilli.sendDone[am_id_t id](message_t* msg, error_t error)
-       {
-       }
-
-       command uint8_t TimeSyncAMSendMilli.maxPayloadLength[am_id_t id]()
-       {
-               return call TimeSyncAMSendRadio.maxPayloadLength[id]();
-       }
-
-       command void* TimeSyncAMSendMilli.getPayload[am_id_t id](message_t* msg, uint8_t len)
-       {
-               return call TimeSyncAMSendRadio.getPayload[id](msg, len);
-       }
-
-       /*----------------- SubSend.sendDone -------------------*/
-
-       event void SubSend.sendDone[am_id_t id](message_t* msg, error_t error)
-       {
-               signal TimeSyncAMSendRadio.sendDone[id](msg, error);
-               signal TimeSyncAMSendMilli.sendDone[id](msg, error);
-       }
-
-       /*----------------- TimeSyncPacketRadio -----------------*/
-
-       command bool TimeSyncPacketRadio.isValid(message_t* msg)
-       {
-               timesync_relative_t* timesync = getFooter(msg);
-
-               return call PacketTimeStampRadio.isValid(msg) && *timesync != 0x80000000L;
-       }
-
-       command uint32_t TimeSyncPacketRadio.eventTime(message_t* msg)
-       {
-               timesync_relative_t* timesync = getFooter(msg);
-
-               return (*timesync) + call PacketTimeStampRadio.timestamp(msg);
-       }
-
-       /*----------------- TimeSyncPacketMilli -----------------*/
-
-       command bool TimeSyncPacketMilli.isValid(message_t* msg)
-       {
-               timesync_relative_t* timesync = getFooter(msg);
-
-               return call PacketTimeStampMilli.isValid(msg) && *timesync != 0x80000000L;
-       }
-
-       command uint32_t TimeSyncPacketMilli.eventTime(message_t* msg)
-       {
-               timesync_relative_t* timesync = getFooter(msg);
-
-               return ((int32_t)(*timesync) >> RADIO_ALARM_MILLI_EXP) + call PacketTimeStampMilli.timestamp(msg);
-       }
-}
diff --git a/tos/chips/rf2xx/layers/TimeSyncMessageLayer.h b/tos/chips/rf2xx/layers/TimeSyncMessageLayer.h
new file mode 100644 (file)
index 0000000..51e3842
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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 __TIMESYNCMESSAGELAYER_H__
+#define __TIMESYNCMESSAGELAYER_H__
+
+// this value is sent in the air
+typedef nx_int32_t timesync_relative_t;
+
+// this value is stored in memory
+typedef uint32_t timesync_absolute_t;
+
+#endif//__TIMESYNCMESSAGELAYER_H__
diff --git a/tos/chips/rf2xx/layers/TimeSyncMessageLayerC.nc b/tos/chips/rf2xx/layers/TimeSyncMessageLayerC.nc
new file mode 100644 (file)
index 0000000..808e0ab
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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 <Timer.h>
+#include <AM.h>
+#include <RadioConfig.h>
+
+configuration TimeSyncMessageLayerC
+{
+       provides
+       {
+               interface Packet;
+
+               interface TimeSyncAMSend<TRadio, uint32_t> as TimeSyncAMSendRadio[am_id_t id];
+               interface TimeSyncPacket<TRadio, uint32_t> as TimeSyncPacketRadio;
+
+               interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[am_id_t id];
+               interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
+       }
+
+       uses
+       {
+               interface PacketTimeStamp<TRadio, uint32_t> as PacketTimeStampRadio;
+               interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+
+               interface LocalTime<TRadio> as LocalTimeRadio;
+               interface PacketField<uint8_t> as PacketTimeSyncOffset;
+
+               interface AMSend as SubSend[am_id_t id];
+               interface Packet as SubPacket;
+       }
+}
+
+implementation
+{
+       components TimeSyncMessageLayerP, LocalTimeMilliC;
+
+       Packet = TimeSyncMessageLayerP;
+
+       TimeSyncAMSendRadio = TimeSyncMessageLayerP;
+       TimeSyncPacketRadio = TimeSyncMessageLayerP;
+
+       TimeSyncAMSendMilli = TimeSyncMessageLayerP;
+       TimeSyncPacketMilli = TimeSyncMessageLayerP;
+
+       SubSend = TimeSyncMessageLayerP;
+       SubPacket = TimeSyncMessageLayerP;
+
+       PacketTimeStampRadio = TimeSyncMessageLayerP;
+       PacketTimeStampMilli = TimeSyncMessageLayerP;
+       
+       TimeSyncMessageLayerP.LocalTimeMilli -> LocalTimeMilliC;
+       LocalTimeRadio = TimeSyncMessageLayerP;
+       PacketTimeSyncOffset = TimeSyncMessageLayerP;
+}
diff --git a/tos/chips/rf2xx/layers/TimeSyncMessageLayerP.nc b/tos/chips/rf2xx/layers/TimeSyncMessageLayerP.nc
new file mode 100644 (file)
index 0000000..e615331
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * 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 <TimeSyncMessageLayer.h>
+
+module TimeSyncMessageLayerP
+{
+       provides
+       {
+               interface TimeSyncAMSend<TRadio, uint32_t> as TimeSyncAMSendRadio[uint8_t id];
+               interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[uint8_t id];
+               interface Packet;
+
+               interface TimeSyncPacket<TRadio, uint32_t> as TimeSyncPacketRadio;
+               interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
+       }
+
+       uses
+       {
+               interface AMSend as SubSend[uint8_t id];
+               interface Packet as SubPacket;
+
+               interface PacketTimeStamp<TRadio, uint32_t> as PacketTimeStampRadio;
+               interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+
+               interface LocalTime<TRadio> as LocalTimeRadio;
+               interface LocalTime<TMilli> as LocalTimeMilli;
+
+               interface PacketField<uint8_t> as PacketTimeSyncOffset;
+       }
+}
+
+implementation
+{
+       inline void* getFooter(message_t* msg)
+       {
+               // we use the payload length that we export (the smaller one)
+               return msg->data + call Packet.payloadLength(msg);
+       }
+
+/*----------------- Packet -----------------*/
+
+       command void Packet.clear(message_t* msg) 
+       {
+               call SubPacket.clear(msg);
+       }
+
+       command void Packet.setPayloadLength(message_t* msg, uint8_t len) 
+       {
+               call SubPacket.setPayloadLength(msg, len + sizeof(timesync_relative_t));
+       }
+
+       command uint8_t Packet.payloadLength(message_t* msg) 
+       {
+               return call SubPacket.payloadLength(msg) - sizeof(timesync_relative_t);
+       }
+
+       command uint8_t Packet.maxPayloadLength()
+       {
+               return call SubPacket.maxPayloadLength() - sizeof(timesync_relative_t);
+       }
+
+       command void* Packet.getPayload(message_t* msg, uint8_t len)
+       {
+               return call SubPacket.getPayload(msg, len + sizeof(timesync_relative_t));
+       }
+
+/*----------------- TimeSyncAMSendRadio -----------------*/
+
+       command error_t TimeSyncAMSendRadio.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len, uint32_t event_time)
+       {
+               *(timesync_absolute_t*)(msg->data + len) = event_time;
+
+               call PacketTimeSyncOffset.set(msg, offsetof(message_t, data) + len);
+
+               return call SubSend.send[id](addr, msg, len + sizeof(timesync_relative_t));
+       }
+
+       command error_t TimeSyncAMSendRadio.cancel[am_id_t id](message_t* msg)
+       {
+               return call SubSend.cancel[id](msg);
+       }
+
+       default event void TimeSyncAMSendRadio.sendDone[am_id_t id](message_t* msg, error_t error)
+       {
+       }
+
+       command uint8_t TimeSyncAMSendRadio.maxPayloadLength[am_id_t id]()
+       {
+               return call SubSend.maxPayloadLength[id]() - sizeof(timesync_relative_t);
+       }
+
+       command void* TimeSyncAMSendRadio.getPayload[am_id_t id](message_t* msg, uint8_t len)
+       {
+               return call SubSend.getPayload[id](msg, len + sizeof(timesync_relative_t));
+       }
+
+/*----------------- TimeSyncAMSendMilli -----------------*/
+
+       command error_t TimeSyncAMSendMilli.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len, uint32_t event_time)
+       {
+               // compute elapsed time in millisecond
+               event_time = ((int32_t)(event_time - call LocalTimeMilli.get()) << RADIO_ALARM_MILLI_EXP) + call LocalTimeRadio.get();
+
+               return call TimeSyncAMSendRadio.send[id](addr, msg, len, event_time);
+       }
+
+       command error_t TimeSyncAMSendMilli.cancel[am_id_t id](message_t* msg)
+       {
+               return call TimeSyncAMSendRadio.cancel[id](msg);
+       }
+
+       default event void TimeSyncAMSendMilli.sendDone[am_id_t id](message_t* msg, error_t error)
+       {
+       }
+
+       command uint8_t TimeSyncAMSendMilli.maxPayloadLength[am_id_t id]()
+       {
+               return call TimeSyncAMSendRadio.maxPayloadLength[id]();
+       }
+
+       command void* TimeSyncAMSendMilli.getPayload[am_id_t id](message_t* msg, uint8_t len)
+       {
+               return call TimeSyncAMSendRadio.getPayload[id](msg, len);
+       }
+
+       /*----------------- SubSend.sendDone -------------------*/
+
+       event void SubSend.sendDone[am_id_t id](message_t* msg, error_t error)
+       {
+               signal TimeSyncAMSendRadio.sendDone[id](msg, error);
+               signal TimeSyncAMSendMilli.sendDone[id](msg, error);
+       }
+
+       /*----------------- TimeSyncPacketRadio -----------------*/
+
+       command bool TimeSyncPacketRadio.isValid(message_t* msg)
+       {
+               timesync_relative_t* timesync = getFooter(msg);
+
+               return call PacketTimeStampRadio.isValid(msg) && *timesync != 0x80000000L;
+       }
+
+       command uint32_t TimeSyncPacketRadio.eventTime(message_t* msg)
+       {
+               timesync_relative_t* timesync = getFooter(msg);
+
+               return (*timesync) + call PacketTimeStampRadio.timestamp(msg);
+       }
+
+       /*----------------- TimeSyncPacketMilli -----------------*/
+
+       command bool TimeSyncPacketMilli.isValid(message_t* msg)
+       {
+               timesync_relative_t* timesync = getFooter(msg);
+
+               return call PacketTimeStampMilli.isValid(msg) && *timesync != 0x80000000L;
+       }
+
+       command uint32_t TimeSyncPacketMilli.eventTime(message_t* msg)
+       {
+               timesync_relative_t* timesync = getFooter(msg);
+
+               return ((int32_t)(*timesync) >> RADIO_ALARM_MILLI_EXP) + call PacketTimeStampMilli.timestamp(msg);
+       }
+}
index 616292dfd2920433839be253df1d9d23bb812298..d76e1628fc9096953961a5c20252d48795997308 100644 (file)
@@ -24,7 +24,7 @@
 #include <RF212DriverLayer.h>
 #include <Tasklet.h>
 #include <RadioAssert.h>
-#include <GenericTimeSyncMessage.h>
+#include <TimeSyncMessageLayer.h>
 #include <RadioConfig.h>
 
 module RF212DriverLayerP
diff --git a/tos/chips/rf2xx/rf212/RF212TimeSyncMessageC.nc b/tos/chips/rf2xx/rf212/RF212TimeSyncMessageC.nc
new file mode 100644 (file)
index 0000000..c066441
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2007, Vanderbilt University
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Author: Miklos Maroti
+ */
+
+#include <RadioConfig.h>
+
+configuration RF212TimeSyncMessageC
+{
+       provides
+       {
+               interface SplitControl;
+               interface Receive[uint8_t id];
+               interface Receive as Snoop[am_id_t id];
+               interface AMPacket;
+
+               interface Packet;
+
+               interface TimeSyncAMSend<TRadio, uint32_t> as TimeSyncAMSendRadio[am_id_t id];
+               interface TimeSyncPacket<TRadio, uint32_t> as TimeSyncPacketRadio;
+
+               interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[am_id_t id];
+               interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
+       }
+}
+
+implementation
+{
+       components RF212DriverLayerC, RF212ActiveMessageC, TimeSyncMessageLayerC;
+  
+       SplitControl    = RF212ActiveMessageC;
+       Receive         = RF212ActiveMessageC.Receive;
+       Snoop           = RF212ActiveMessageC.Snoop;
+       AMPacket        = RF212ActiveMessageC;
+       Packet          = TimeSyncMessageLayerC;
+
+       TimeSyncAMSendRadio     = TimeSyncMessageLayerC;
+       TimeSyncPacketRadio     = TimeSyncMessageLayerC;
+       TimeSyncAMSendMilli     = TimeSyncMessageLayerC;
+       TimeSyncPacketMilli     = TimeSyncMessageLayerC;
+
+       TimeSyncMessageLayerC.SubSend -> RF212ActiveMessageC;
+       TimeSyncMessageLayerC.SubPacket -> RF212ActiveMessageC;
+
+       TimeSyncMessageLayerC.PacketTimeStampRadio -> RF212ActiveMessageC;
+       TimeSyncMessageLayerC.PacketTimeStampMilli -> RF212ActiveMessageC;
+
+       TimeSyncMessageLayerC.LocalTimeRadio -> RF212DriverLayerC;
+       TimeSyncMessageLayerC.PacketTimeSyncOffset -> RF212DriverLayerC.PacketTimeSyncOffset;
+}
index 6f74fb16c394beb2a6339ddd2bf559bd754605ff..662b5a413664b92aba3186698e76ff3fd7ea7a71 100644 (file)
@@ -24,7 +24,7 @@
 #include <RF230DriverLayer.h>
 #include <Tasklet.h>
 #include <RadioAssert.h>
-#include <GenericTimeSyncMessage.h>
+#include <TimeSyncMessageLayer.h>
 #include <RadioConfig.h>
 
 module RF230DriverLayerP
diff --git a/tos/chips/rf2xx/rf230/RF230TimeSyncMessageC.nc b/tos/chips/rf2xx/rf230/RF230TimeSyncMessageC.nc
new file mode 100644 (file)
index 0000000..2d7f495
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2007, Vanderbilt University
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Author: Miklos Maroti
+ */
+
+#include <RadioConfig.h>
+
+configuration RF230TimeSyncMessageC
+{
+       provides
+       {
+               interface SplitControl;
+               interface Receive[uint8_t id];
+               interface Receive as Snoop[am_id_t id];
+               interface AMPacket;
+
+               interface Packet;
+
+               interface TimeSyncAMSend<TRadio, uint32_t> as TimeSyncAMSendRadio[am_id_t id];
+               interface TimeSyncPacket<TRadio, uint32_t> as TimeSyncPacketRadio;
+
+               interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[am_id_t id];
+               interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
+       }
+}
+
+implementation
+{
+       components RF230DriverLayerC, RF230ActiveMessageC, TimeSyncMessageLayerC;
+  
+       SplitControl    = RF230ActiveMessageC;
+       Receive         = RF230ActiveMessageC.Receive;
+       Snoop           = RF230ActiveMessageC.Snoop;
+       AMPacket        = RF230ActiveMessageC;
+       Packet          = TimeSyncMessageLayerC;
+
+       TimeSyncAMSendRadio     = TimeSyncMessageLayerC;
+       TimeSyncPacketRadio     = TimeSyncMessageLayerC;
+       TimeSyncAMSendMilli     = TimeSyncMessageLayerC;
+       TimeSyncPacketMilli     = TimeSyncMessageLayerC;
+
+       TimeSyncMessageLayerC.SubSend -> RF230ActiveMessageC;
+       TimeSyncMessageLayerC.SubPacket -> RF230ActiveMessageC;
+
+       TimeSyncMessageLayerC.PacketTimeStampRadio -> RF230ActiveMessageC;
+       TimeSyncMessageLayerC.PacketTimeStampMilli -> RF230ActiveMessageC;
+
+       TimeSyncMessageLayerC.LocalTimeRadio -> RF230DriverLayerC;
+       TimeSyncMessageLayerC.PacketTimeSyncOffset -> RF230DriverLayerC.PacketTimeSyncOffset;
+}
index 649ae6f312eb5094007d9a120cabd8bbf655b7e1..39f07fa252f2a495cceea721303b6857d946156e 100644 (file)
@@ -35,6 +35,9 @@ configuration ActiveMessageC
 
                interface PacketAcknowledgements;
                interface LowPowerListening;
+#ifdef PACKET_LINK
+               interface PacketLink;
+#endif
 
                interface PacketTimeStamp<TMicro, uint32_t> as PacketTimeStampMicro;
                interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
@@ -45,12 +48,15 @@ implementation
 {
        components RF230ActiveMessageC as MAC;
 
-       SplitControl = MAC;
-       AMSend       = MAC;
-       Receive      = MAC.Receive;
-       Snoop        = MAC.Snoop;
-       Packet       = MAC;
-       AMPacket     = MAC;
+       SplitControl    = MAC;
+       AMSend          = MAC;
+       Receive         = MAC.Receive;
+       Snoop           = MAC.Snoop;
+       Packet          = MAC;
+       AMPacket        = MAC;
+#ifdef PACKET_LINK
+       PacketLink      = MAC;
+#endif
 
        PacketAcknowledgements  = MAC;
        LowPowerListening       = MAC;
index 04a764e873e09dc507baa1540c95b1738074b82e..e39b4929cdde5f3b62f23ed3b1f9096682a7dafc 100644 (file)
@@ -44,7 +44,7 @@ configuration TimeSyncMessageC
 
 implementation
 {
-       components GenericTimeSyncMessageC as MAC, LocalTimeMicroC, RF230DriverLayerC;
+       components RF230TimeSyncMessageC as MAC;
   
        SplitControl    = MAC;
        Receive         = MAC.Receive;
@@ -56,7 +56,4 @@ implementation
        TimeSyncPacketRadio     = MAC;
        TimeSyncAMSendMilli     = MAC;
        TimeSyncPacketMilli     = MAC;
-
-       MAC.PacketTimeSyncOffset -> RF230DriverLayerC.PacketTimeSyncOffset;
-       MAC.LocalTimeRadio -> LocalTimeMicroC;
 }