trickle.h
Go to the documentation of this file.
1 /*
2  * Trickle constants and prototypes
3  *
4  * Copyright (C) 2013, 2014 INRIA.
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
25 #ifndef TRICKLE_H
26 #define TRICKLE_H
27 
28 #ifdef __cplusplus
29  extern "C" {
30 #endif
31 
32 #include "xtimer.h"
33 #include "thread.h"
34 
36 typedef struct {
37  void (*func)(void *);
38  void *args;
40 
42 typedef struct {
43  uint8_t k;
44  uint8_t Imax;
45  uint16_t c;
46  uint32_t Imin;
47  uint32_t I;
48  uint32_t t;
53  uint64_t msg_interval_time;
57  uint64_t msg_callback_time;
60 } trickle_t;
61 
67 void trickle_reset_timer(trickle_t *trickle);
68 
80 void trickle_start(kernel_pid_t pid, trickle_t *trickle, uint16_t interval_msg_type,
81  uint16_t callback_msg_type, uint32_t Imin, uint8_t Imax, uint8_t k);
82 
88 void trickle_stop(trickle_t *trickle);
89 
96 
102 void trickle_interval(trickle_t *trickle);
103 
109 void trickle_callback(trickle_t *trickle);
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif /* TRICKLE_H */
116 
msg_t msg_interval
the msg_t to use for intervals
Definition: trickle.h:52
uint64_t msg_callback_time
callback interval in ms
Definition: trickle.h:57
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
uint32_t Imin
minimum interval size
Definition: trickle.h:46
all state variables for a trickle timer
Definition: trickle.h:42
xtimer_t msg_interval_timer
xtimer to send a msg_t to the target thread for a new interval
Definition: trickle.h:54
void trickle_reset_timer(trickle_t *trickle)
resets the trickle timer
void trickle_increment_counter(trickle_t *trickle)
increments the counter by one
void trickle_stop(trickle_t *trickle)
stops the trickle timer
void * args
a generic parameter for the callback function pointer
Definition: trickle.h:38
Threading API.
a generic callback function with arguments that is called by trickle periodically ...
Definition: trickle.h:36
trickle_callback_t callback
the callback function and parameter that trickle is calling after each interval
Definition: trickle.h:50
uint64_t msg_interval_time
interval in ms
Definition: trickle.h:53
xtimer interface definitions
Describes a message object which can be sent between threads.
Definition: msg.h:184
msg_t msg_callback
the msg_t to use for callbacks
Definition: trickle.h:56
void trickle_interval(trickle_t *trickle)
is called after the interval is over and calculates the next interval
uint32_t t
time within the current interval
Definition: trickle.h:48
uint8_t k
redundancy constant
Definition: trickle.h:43
uint8_t Imax
maximum interval size, described as doublings
Definition: trickle.h:44
xtimer timer structure
Definition: xtimer.h:70
kernel_pid_t pid
pid of trickles target thread
Definition: trickle.h:49
uint16_t c
counter
Definition: trickle.h:45
uint32_t I
current interval size
Definition: trickle.h:47
void trickle_start(kernel_pid_t pid, trickle_t *trickle, uint16_t interval_msg_type, uint16_t callback_msg_type, uint32_t Imin, uint8_t Imax, uint8_t k)
start the trickle timer
xtimer_t msg_callback_timer
xtimer to send a msg_t to the target thread for a callback
Definition: trickle.h:58
void trickle_callback(trickle_t *trickle)
is called after the callback interval is over and calls the callback function