trickle.h
Go to the documentation of this file.
1 /*
2  * Trickle constants and prototypes
3  *
4  * Copyright (C) 2013, 2014 INRIA.
5  * 2017 HAW Hamburg
6  *
7  * This file is subject to the terms and conditions of the GNU Lesser
8  * General Public License v2.1. See the file LICENSE in the top level
9  * directory for more details.
10  */
11 
28 #ifndef TRICKLE_H
29 #define TRICKLE_H
30 
31 #ifdef __cplusplus
32  extern "C" {
33 #endif
34 
35 #include "xtimer.h"
36 #include "thread.h"
37 
41 typedef struct {
42  void (*func)(void *);
43  void *args;
45 
49 typedef struct {
50  uint8_t k;
51  uint8_t Imax;
53  uint16_t c;
54  uint32_t Imin;
55  uint32_t I;
56  uint32_t t;
61  uint64_t msg_time;
64 } trickle_t;
65 
74 void trickle_reset_timer(trickle_t *trickle);
75 
89 void trickle_start(kernel_pid_t pid, trickle_t *trickle, uint16_t msg_type,
90  uint32_t Imin, uint8_t Imax, uint8_t k);
91 
97 void trickle_stop(trickle_t *trickle);
98 
104 void trickle_increment_counter(trickle_t *trickle);
105 
113 void trickle_interval(trickle_t *trickle);
114 
120 void trickle_callback(trickle_t *trickle);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif /* TRICKLE_H */
127 
xtimer_t msg_timer
xtimer to send a msg_t to the target thread for a new interval
Definition: trickle.h:62
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
uint32_t Imin
minimum interval size
Definition: trickle.h:54
all state variables of a trickle timer
Definition: trickle.h:49
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 trickle_start(kernel_pid_t pid, trickle_t *trickle, uint16_t msg_type, uint32_t Imin, uint8_t Imax, uint8_t k)
start the trickle timer
void * args
callback function arguments
Definition: trickle.h:43
Threading API.
Trickle callback function with arguments.
Definition: trickle.h:41
trickle_callback_t callback
callback function and parameter that trickle calls after each interval
Definition: trickle.h:58
xtimer interface definitions
Describes a message object which can be sent between threads.
Definition: msg.h:184
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:56
uint8_t k
redundancy constant
Definition: trickle.h:50
uint8_t Imax
maximum interval size, described as of Imin doublings
Definition: trickle.h:51
xtimer timer structure
Definition: xtimer.h:70
kernel_pid_t pid
pid of trickles target thread
Definition: trickle.h:57
uint16_t c
counter
Definition: trickle.h:53
uint32_t I
current interval size
Definition: trickle.h:55
uint64_t msg_time
interval in ms
Definition: trickle.h:61
msg_t msg
the msg_t to use for intervals
Definition: trickle.h:60
void trickle_callback(trickle_t *trickle)
is called after the interval is over and executes callback function