Apps     Components     Interfaces     All Files     Source Tree     source: tos.interfaces.Timer.nc

Interface: Timer

This interface provides a generic timer that can be used to generate events at regular intervals.

Components providing this interface:
tos.system.TimerC
tos.system.TimerM

Components requiring this interface:
tos.lib.Attributes.AttrMagM
tos.lib.Attributes.AttrMicM
tos.lib.Commands.CommandSounderM
tos.lib.TinyDB.TupleRouterM
tos.system.AMStandard

Commands

Events

Commands - Details

start

result_t start(char type, uint32_t interval)

Start the timer.

Parameters:

type - The type of timer to start. Valid values include 'TIMER_REPEAT' for a timer that fires repeatedly, or 'TIMER_ONE_SHOT' for a timer that fires once.

interval - The timer interval in milliseconds. Note that the timer cannot support an arbitrary range of intervals. (Unfortunately this interface does not specify the valid range of timer intervals, which are specific to a platform.)

Returns: Returns SUCCESS if the timer could be started with the given type and interval. Returns FAIL if the type is not one of TIMER_REPEAT or TIMER_ONE_SHOT, if the timer rate is too high, or if there are too many timers currently active.

stop

result_t stop(void)

Stop the timer, preventing it from firing again. If this is a TIMER_ONE_SHOT timer and it has not fired yet, prevents it from firing.
Returns: SUCCESS if the timer could be stopped, or FAIL if the timer is not running or the timer ID is out of range.