49 #define LOG_MODULE "coap-timer" 50 #define LOG_LEVEL LOG_LEVEL_NONE 53 static uint8_t is_initialized;
56 add_timer(coap_timer_t *
timer)
58 coap_timer_t *n, *l, *p;
65 LOG_DBG(
"adding timer %p at %lu\n", timer,
66 (
unsigned long)timer->expiration_time);
73 for(l = NULL, n =
list_head(timer_list); n != NULL; l = n, n = n->next) {
74 if(timer->expiration_time < n->expiration_time) {
87 COAP_TIMER_DRIVER.update();
94 LOG_DBG(
"stopping timer %p\n", timer);
112 timer->expiration_time += time;
129 if(now < next->expiration_time) {
130 return next->expiration_time - now;
151 if(next->expiration_time <= now) {
152 LOG_DBG(
"timer %p expired at %lu\n", next, (
unsigned long)now);
158 next->callback(next);
162 COAP_TIMER_DRIVER.update();
183 if(COAP_TIMER_DRIVER.init) {
184 COAP_TIMER_DRIVER.init();
void list_insert(list_t list, void *previtem, void *newitem)
Insert an item after a specified item on the list.
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 ...
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.
Linked list manipulation routines.
void * list_head(list_t list)
Get a pointer to the first element of a list.
static uint64_t coap_timer_uptime(void)
Get the time since boot in milliseconds.
void list_init(list_t list)
Initialize a list.
void coap_timer_init(void)
This function initializes the CoAP timer library.
#define LIST(name)
Declare a linked list.
void coap_timer_stop(coap_timer_t *timer)
Stop a pending CoAP timer.
void coap_timer_set(coap_timer_t *timer, uint64_t time)
Set a CoAP timer to expire after the specified time.
Default definitions of C compiler quirk work-arounds.
void list_remove(list_t list, void *item)
Remove a specific element from a list.
int coap_timer_run(void)
This function must be called periodically by the CoAP timer driver to process any expired CoAP timers...