The Contiki kernel does not provide support for timed events.
Rather, an application that wants to use timers needs to explicitly use the timer library.
The timer library provides functions for setting, resetting and restarting timers, and for checking if a timer has expired. An application must "manually" check if its timers have expired; this is not done automatically.
A timer is declared as a struct
timer
and all access to the timer is made by a pointer to the declared timer.
Data Structures | |
struct | timer |
A timer. More... | |
Files | |
file | wireless/SmartConnect_6LoWPAN/core/sys/timer.c |
Timer library implementation. | |
file | timer.h |
Timer library header file. | |
Functions | |
int | timer_expired (struct timer *t) |
Check if a timer has expired. More... | |
clock_time_t | timer_remaining (struct timer *t) |
The time until the timer expires. More... | |
void | timer_reset (struct timer *t) |
Reset the timer with the same interval. More... | |
void | timer_restart (struct timer *t) |
Restart the timer from the current point in time. More... | |
void | timer_set (struct timer *t, clock_time_t interval) |
Set a timer. More... | |
CCIF int timer_expired | ( | struct timer * | t | ) |
Check if a timer has expired.
This function tests if a timer has expired and returns true or false depending on its status.
t | A pointer to the timer |
References clock_time(), interval, and start.
Referenced by broadcast_rate_drop(), check_age(), extint_detection_callback(), input(), make_addrmap(), phase_update(), PROCESS_THREAD(), purge_registrations(), uaodv_request_route_to(), and uip_ds6_periodic().
clock_time_t timer_remaining | ( | struct timer * | t | ) |
The time until the timer expires.
This function returns the time until the timer expires.
t | A pointer to the timer |
References clock_time(), interval, and start.
Referenced by recycle().
void timer_reset | ( | struct timer * | t | ) |
Reset the timer with the same interval.
This function resets the timer with the same interval that was given to the timer_set() function. The start point of the interval is the exact time that the timer last expired. Therefore, this function will cause the timer to be stable over time, unlike the timer_restart() function.
t | A pointer to the timer. |
References interval, and start.
Referenced by etimer_reset().
void timer_restart | ( | struct timer * | t | ) |
Restart the timer from the current point in time.
This function restarts a timer with the same interval that was given to the timer_set() function. The timer will start at the current time.
t | A pointer to the timer. |
References clock_time(), and start.
Referenced by etimer_restart().
CCIF void timer_set | ( | struct timer * | t, |
clock_time_t | interval | ||
) |
Set a timer.
This function is used to set a timer for a time sometime in the future. The function timer_expired() will evaluate to true after the timer has expired.
t | A pointer to the timer |
interval | The interval before the timer expires. |
References clock_time(), interval, and start.
Referenced by broadcast_rate_drop(), button_sensor_init(), etimer_set(), extint_detection_callback(), handle_incoming_reg(), input(), ip64_addrmap_create(), ip64_addrmap_set_lifetime(), phase_update(), purge_registrations(), servreg_hack_register(), uaodv_request_route_to(), and uip_ds6_addr_add().