]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/rf230/RF230PacketP.nc
rename the TRF230 timer to TRadio
[tinyos-2.x.git] / tos / chips / rf230 / RF230PacketP.nc
index 6bfb2c2d903cde59f684b3ddad7ee526c6f618b6..7a8d117ad2d6b5a70d7540b992bf7dafba65f71c 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <RF230Packet.h>
+#include <TimeSyncMessage.h>
 
 module RF230PacketP
 {
@@ -35,7 +36,7 @@ module RF230PacketP
                interface PacketField<uint16_t> as PacketSleepInterval;
                interface PacketField<uint8_t> as PacketTimeSyncOffset;
 
-               interface PacketTimeStamp<TRF230, uint32_t> as PacketTimeStampRadio;
+               interface PacketTimeStamp<TRadio, uint32_t> as PacketTimeStampRadio;
                interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
        }
 
@@ -43,7 +44,7 @@ module RF230PacketP
        {
                interface IEEE154Packet;
 
-               interface LocalTime<TRF230> as LocalTimeRadio;
+               interface LocalTime<TRadio> as LocalTimeRadio;
                interface LocalTime<TMilli> as LocalTimeMilli;
        }
 }
@@ -54,7 +55,7 @@ implementation
        {
                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
+                       + sizeof(ieee154_footer_t),             // the CRC is not stored in memory
        };
 
        inline rf230packet_metadata_t* getMeta(message_t* msg)
@@ -68,10 +69,6 @@ implementation
        {
                call IEEE154Packet.createDataFrame(msg);
 
-#ifdef IEEE154_6LOWPAN
-               call IEEE154Packet.set6LowPan(msg, TINYOS_6LOWPAN_NETWORK_ID);
-#endif
-
                getMeta(msg)->flags = RF230PACKET_CLEAR_METADATA;
        }
 
@@ -80,13 +77,11 @@ implementation
                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;
@@ -250,7 +245,7 @@ implementation
 
        async command uint8_t PacketTimeSyncOffset.get(message_t* msg)
        {
-               return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_footer_t);
+               return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t);
        }
 
        async command void PacketTimeSyncOffset.clear(message_t* msg)
@@ -264,37 +259,33 @@ implementation
                getMeta(msg)->flags |= RF230PACKET_TIMESYNC;
        }
 
-/*----------------- 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;
+               return getMeta(msg)->flags & RF230PACKET_LPL_SLEEPINT;
        }
 
        async command uint16_t PacketSleepInterval.get(message_t* msg)
        {
-               return sleepInterval;
+#ifdef LOW_POWER_LISTENING
+               return getMeta(msg)->lpl_sleepint;
+#else
+               return 0;
+#endif
        }
 
        async command void PacketSleepInterval.clear(message_t* msg)
        {
-               flags &= ~FLAG_SLEEPINT;
+               getMeta(msg)->flags &= ~RF230PACKET_LPL_SLEEPINT;
        }
 
        async command void PacketSleepInterval.set(message_t* msg, uint16_t value)
        {
-               flags |= FLAG_SLEEPINT;
-               sleepInterval = value;
+               getMeta(msg)->flags |= RF230PACKET_LPL_SLEEPINT;
+
+#ifdef LOW_POWER_LISTENING
+               getMeta(msg)->lpl_sleepint = value;
+#endif
        }
 }