Interface: moteiv.tos.lib.sp.cc2420.TimeStamping

interface TimeStamping<typedef precision_tag, typedef size_type>

Basic interface for setting and getting post-arbitration timestamps of a particular packet. Adapted by Moteiv Corporation from the Vanderbilt timestamping interface to support more general links with a wider range of functionality.

Author:
Joe Polastre, Moteiv Corporation <info@moteiv.com>
Miklos Maroti
Date:
January 2006

Commands
command result_t addStamp(TOS_MsgPtr msg, int8_t offset) The same as addStampAll() command, with the exception that it will only add a timestamp to "msg" when transmitted.
command result_t addStampAll(int8_t offset) Adds a time stamp to the next message sent by the radio.
command void cancel() Stop time stamping all together.
command size_type getReceiveStamp(TOS_Msg *msg) Returns the time stamp of the last received message.
command size_type getStampMsg(TOS_MsgPtr msg, int8_t offset) Convenience function to get the timestamp from a given TOSMsg instead of replicating this code all over the place.

Commands - Details

addStamp

command result_t addStamp(TOS_MsgPtr msg, int8_t offset)

The same as addStampAll() command, with the exception that it will only add a timestamp to "msg" when transmitted. No timestamps will be added to any other packets.

addStampAll

command result_t addStampAll(int8_t offset)

Adds a time stamp to the next message sent by the radio. This method must be called immediatelly after SendMsg.send() returns SUCCESS. The message must include space for the time stamp based on the size_type specified for this interface.

The offset parameter is the offset of the time stamp field in the TOS_Msg.data payload. It must be a value between 0 and (TOSH_DATA_LENGTH - sizeof(size_type)). It is advisable to put the time stamp field at the end of the message. The local time will replace the existing data in the message at the specified offset.

Returns:
SUCCESS if the offset is in the valid range, or FALSE if the message will not be time stamped.

cancel

command void cancel()

Stop time stamping all together.

getReceiveStamp

command size_type getReceiveStamp(TOS_Msg *msg)

Returns the time stamp of the last received message. This method should be called when the ReceiveMsg.receive() is fired. The returned value contains the 32-bit local time when the message was received.

getStampMsg

command size_type getStampMsg(TOS_MsgPtr msg, int8_t offset)

Convenience function to get the timestamp from a given TOSMsg instead of replicating this code all over the place.

Parameters:
msg - TOSMsg with a timestamp in it
offset - the offset of the timestamp
Returns:
a value of the timestamp at that offset