Interface: moteiv.tos.lib.sp.SPUtil

interface SPUtil

Utility functions for SP's primary operations, including link quality support and time stamping support.

Author:
Joe Polastre, Moteiv Corporation <info@moteiv.com>

Commands
command uint16_t getQuality(sp_neighbor_t *n, TOS_Msg *msg) Get the link quality of a neighbor, n, based on a received message, msg.
command uint32_t getReceiveTimestamp(TOS_MsgPtr msg) When any packet is received, get the time that the packet was received.
command uint32_t getSenderTimestamp(TOS_MsgPtr msg, int8_t offset) If a message is sent with the SP_FLAG_C_TIMESTAMP flag set, the sender will append a timestamp to the end of the message with the sender's local time.

Commands - Details

getQuality

command uint16_t getQuality(sp_neighbor_t *n, TOS_Msg *msg)

Get the link quality of a neighbor, n, based on a received message, msg. The link quality is an ETX value for the neighbor, where lower values indicate a better link. There is no maximum bound for the return value. Values along a path may be added together for the path quality, when using retransmissions, or multiplied together, when not using retransmissions.

Parameters:
n - Neighbor whose link quality should be adjusted
msg - Incoming message used for adjusting current link quality
Returns:
new link quality based on the above requirements

getReceiveTimestamp

command uint32_t getReceiveTimestamp(TOS_MsgPtr msg)

When any packet is received, get the time that the packet was received. The time returned is a 32-bit value based on a 32.768kHz clock signal. The time is acquired from the same source as LocalTimeC.

Parameters:
msg - Received message
Returns:
32-bit 32.768kHz timestamp

getSenderTimestamp

command uint32_t getSenderTimestamp(TOS_MsgPtr msg, int8_t offset)

If a message is sent with the SP_FLAG_C_TIMESTAMP flag set, the sender will append a timestamp to the end of the message with the sender's local time. This time may be extracted from a received message by passing it to the getSenderTimestamp function and specifying the location of the timestamp. Usually, the timestamp is the last 4 bytes of the data message.

Parameters:
msg - Received message
Returns:
32-bit 32.768kHz timestamp