Loading...
Searching...
No Matches
trickle.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2013-2014 INRIA
3 * SPDX-FileCopyrightText: 2017 HAW Hamburg
4 * SPDX-License-Identifier: LGPL-2.1-only
5 */
6
7#pragma once
8
24
25#ifdef __cplusplus
26 extern "C" {
27#endif
28
29#include "thread.h"
30#include "ztimer.h"
31
35typedef struct {
36 void (*func)(void *);
37 void *args;
39
43typedef struct {
44 uint8_t k;
45 uint8_t Imax;
47 uint16_t c;
48 uint32_t Imin;
49 uint32_t I;
50 uint32_t t;
58} trickle_t;
59
69
83void trickle_start(kernel_pid_t pid, trickle_t *trickle, uint16_t msg_type,
84 uint32_t Imin, uint8_t Imax, uint8_t k);
85
91void trickle_stop(trickle_t *trickle);
92
99
108
115
116#ifdef __cplusplus
117}
118#endif
119
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:134
void trickle_increment_counter(trickle_t *trickle)
increments the counter by one
void trickle_stop(trickle_t *trickle)
stops the trickle timer
void trickle_callback(trickle_t *trickle)
is called after the interval is over and executes callback function
void trickle_reset_timer(trickle_t *trickle)
resets the trickle timer
void trickle_interval(trickle_t *trickle)
is called after the interval is over and calculates the next interval
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
Describes a message object which can be sent between threads.
Definition msg.h:193
Trickle callback function with arguments.
Definition trickle.h:35
void * args
callback function arguments
Definition trickle.h:37
void(* func)(void *)
callback function pointer
Definition trickle.h:36
all state variables of a trickle timer
Definition trickle.h:43
uint32_t t
time within the current interval in ms
Definition trickle.h:50
msg_t msg
the msg_t to use for intervals
Definition trickle.h:55
uint32_t Imin
minimum interval size in ms
Definition trickle.h:48
uint8_t k
redundancy constant
Definition trickle.h:44
uint8_t Imax
maximum interval size, described as of Imin doublings in ms
Definition trickle.h:45
uint32_t I
current interval size in ms
Definition trickle.h:49
ztimer_t msg_timer
timer to send a msg_t to the target thread for a new interval
Definition trickle.h:56
trickle_callback_t callback
callback function and parameter that trickle calls after each interval
Definition trickle.h:53
kernel_pid_t pid
pid of trickles target thread
Definition trickle.h:52
uint16_t c
counter
Definition trickle.h:47
ztimer structure
Definition ztimer.h:316
ztimer API