54 typedef struct coap_timer coap_timer_t;
57 void (* callback)(coap_timer_t *);
59 uint64_t expiration_time;
64 uint64_t (* uptime)(void);
65 void (* update)(void);
66 } coap_timer_driver_t;
68 #ifndef COAP_TIMER_DRIVER 69 #ifdef COAP_TIMER_CONF_DRIVER 70 #define COAP_TIMER_DRIVER COAP_TIMER_CONF_DRIVER 72 #define COAP_TIMER_DRIVER coap_timer_default_driver 76 extern const coap_timer_driver_t COAP_TIMER_DRIVER;
82 static inline uint64_t
85 return COAP_TIMER_DRIVER.uptime();
92 static inline uint32_t
95 return (uint32_t)(COAP_TIMER_DRIVER.uptime() / 1000);
107 timer->callback = callback;
120 return timer->user_data;
132 timer->user_data = data;
static uint32_t coap_timer_seconds(void)
Get the time since boot in seconds.
static void * coap_timer_get_user_data(coap_timer_t *timer)
Get user data that has been attached to a CoAP timer.
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.
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.
static int coap_timer_expired(const coap_timer_t *timer)
Check if a CoAP timer has expired.
static uint64_t coap_timer_uptime(void)
Get the time since boot in milliseconds.
void coap_timer_init(void)
This function initializes the CoAP timer library.
static void coap_timer_set_user_data(coap_timer_t *timer, void *data)
Attach user data to a CoAP timer.
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.
int coap_timer_run(void)
This function must be called periodically by the CoAP timer driver to process any expired CoAP timers...