Contiki-NG
|
The CoAP timer API defines a common interface for CoAP timer and time functionality. More...
Modules | |
CoAP timer for Contiki-NG | |
This is an implementation of CoAP timer for Contiki-NG. | |
Functions | |
void | coap_timer_stop (coap_timer_t *timer) |
Stop a pending CoAP timer. More... | |
void | coap_timer_set (coap_timer_t *timer, uint64_t time) |
Set a CoAP timer to expire after the specified time. More... | |
void | coap_timer_reset (coap_timer_t *timer, uint64_t time) |
Reset a CoAP timer to expire a specified time after the last expiration time. More... | |
uint64_t | coap_timer_time_to_next_expiration (void) |
Get the time until next CoAP timer expires or 0 if there already exists expired timers that have not yet been processed. More... | |
int | coap_timer_run (void) |
This function must be called periodically by the CoAP timer driver to process any expired CoAP timers. More... | |
void | coap_timer_init (void) |
This function initializes the CoAP timer library. More... | |
static uint64_t | coap_timer_uptime (void) |
Get the time since boot in milliseconds. More... | |
static uint32_t | coap_timer_seconds (void) |
Get the time since boot in seconds. More... | |
static void | coap_timer_set_callback (coap_timer_t *timer, void(*callback)(coap_timer_t *)) |
Set a callback function to be called when a CoAP timer expires. More... | |
static void * | coap_timer_get_user_data (coap_timer_t *timer) |
Get user data that has been attached to a CoAP timer. More... | |
static void | coap_timer_set_user_data (coap_timer_t *timer, void *data) |
Attach user data to a CoAP timer. More... | |
static int | coap_timer_expired (const coap_timer_t *timer) |
Check if a CoAP timer has expired. More... | |
The CoAP timer API defines a common interface for CoAP timer and time functionality.
|
inlinestatic |
Check if a CoAP timer has expired.
timer | A pointer to a CoAP timer. |
Definition at line 142 of file coap-timer.h.
References coap_timer_init(), coap_timer_reset(), coap_timer_run(), coap_timer_set(), coap_timer_stop(), coap_timer_time_to_next_expiration(), and coap_timer_uptime().
|
inlinestatic |
Get user data that has been attached to a CoAP timer.
timer | A pointer to a CoAP timer. |
Definition at line 118 of file coap-timer.h.
void coap_timer_init | ( | void | ) |
This function initializes the CoAP timer library.
It is automatically called at first use of a CoAP timer. This function is normally never called by application code.
Definition at line 176 of file coap-timer.c.
Referenced by coap_timer_expired().
void coap_timer_reset | ( | coap_timer_t * | timer, |
uint64_t | time | ||
) |
Reset a CoAP timer to expire a specified time after the last expiration time.
This function sets the CoAP timer to expire the specified time after the previous expiration time. If the new expiration time has already passed, the timer will expire as soon as possible.
If the timer has not yet expired when this function is called, the time until the timer expires will be extended by the specified time.
timer | A pointer to a CoAP timer. |
time | The time after previous expiration the timer expires. |
Definition at line 110 of file coap-timer.c.
Referenced by coap_timer_expired().
int coap_timer_run | ( | void | ) |
This function must be called periodically by the CoAP timer driver to process any expired CoAP timers.
This function is normally never called by application code.
Returns non-zero if it needs to run again to process more timers.
Definition at line 137 of file coap-timer.c.
References coap_timer_uptime(), and list_head().
Referenced by coap_timer_expired().
|
inlinestatic |
Get the time since boot in seconds.
Definition at line 93 of file coap-timer.h.
void coap_timer_set | ( | coap_timer_t * | timer, |
uint64_t | time | ||
) |
Set a CoAP timer to expire after the specified time.
timer | A pointer to a CoAP timer. |
time | The time until the timer expires. |
Definition at line 103 of file coap-timer.c.
References coap_timer_uptime().
Referenced by coap_timer_expired().
|
inlinestatic |
Set a callback function to be called when a CoAP timer expires.
timer | A pointer to a CoAP timer. |
callback | A callback function. |
Definition at line 105 of file coap-timer.h.
|
inlinestatic |
Attach user data to a CoAP timer.
timer | A pointer to a CoAP timer. |
data | An opaque pointer to user data. |
Definition at line 130 of file coap-timer.h.
void coap_timer_stop | ( | coap_timer_t * | timer | ) |
Stop a pending CoAP timer.
After this function has been called, the timer will be expired and will not call the callback function.
timer | A pointer to a CoAP timer. |
Definition at line 92 of file coap-timer.c.
Referenced by coap_timer_expired().
uint64_t coap_timer_time_to_next_expiration | ( | void | ) |
Get the time until next CoAP timer expires or 0 if there already exists expired timers that have not yet been processed.
This function is normally never called by application code.
Returns the time to next CoAP timer expires or 0 if unprocessed expired timers exists. Returns a time in the future if there are no timers pending.
Definition at line 117 of file coap-timer.c.
References list_head().
Referenced by coap_timer_expired().
|
inlinestatic |
Get the time since boot in milliseconds.
Definition at line 83 of file coap-timer.h.
Referenced by coap_timer_expired(), coap_timer_run(), and coap_timer_set().