Microchip® Advanced Software Framework

trickle-timer.h File Reference

Trickle timer library header file.

Author
George Oikonomou - oikon.nosp@m.omou.nosp@m.@user.nosp@m.s.so.nosp@m.urcef.nosp@m.orge.nosp@m..net
#include "contiki-conf.h"
#include "sys/ctimer.h"

Data Structures

struct  trickle_timer
 A trickle timer. More...
 

Macros

#define TRICKLE_TIMER_COMPENSATE_DRIFT   1
 Controls whether the library will try to compensate for time drifts caused by getting called later than scheduled. More...
 
#define TRICKLE_TIMER_ERROR_CHECKING   1
 Enables/Disables error checking. More...
 
#define TRICKLE_TIMER_MAX_IMAX_WIDTH   TRICKLE_TIMER_MAX_IMAX_GENERIC
 Selects a flavor for the 'Find maximum Imax' (max_imax) function. More...
 
#define TRICKLE_TIMER_WIDE_RAND   1
 Turns on support for 4-byte wide, unsigned random numbers. More...
 
Trickle Timer Library: Constants
#define TRICKLE_TIMER_INFINITE_REDUNDANCY   0x00
 Set as value of k to disable suppression. More...
 
#define TRICKLE_TIMER_ERROR   0
 
#define TRICKLE_TIMER_SUCCESS   1
 
#define TRICKLE_TIMER_MAX_IMAX_GENERIC   0
 Use as the value of TRICKLE_TIMER_MAX_IMAX_WIDTH to enable the generic 'Find max Imax' routine. More...
 
#define TRICKLE_TIMER_MAX_IMAX_16_BIT   1
 Use as the value of TRICKLE_TIMER_MAX_IMAX_WIDTH to enable the 16-bit 'Find max Imax' routine. More...
 
#define TRICKLE_TIMER_MAX_IMAX_32_BIT   2
 Use as the value of TRICKLE_TIMER_MAX_IMAX_WIDTH to enable the 32-bit 'Find max Imax' routine. More...
 
#define TRICKLE_TIMER_TX_SUPPRESS   0
 Constants used as values for the suppress param of trickle_timer_cb_t. More...
 
#define TRICKLE_TIMER_TX_OK   1
 
#define TRICKLE_TIMER_IS_STOPPED   0
 A trickle timer is considered 'stopped' when i_cur == TRICKLE_TIMER_IS_STOPPED. More...
 
Trickle Timer Library: Macros
#define TRICKLE_TIMER_CLOCK_MAX   ((clock_time_t)~0)
 cross-platform method to get the maximum clock_time_t value More...
 
#define TRICKLE_TIMER_SUPPRESSION_ENABLED(tt)   ((tt)->k != TRICKLE_TIMER_INFINITE_REDUNDANCY)
 Checks if the trickle timer's suppression feature is enabled. More...
 
#define TRICKLE_TIMER_SUPPRESSION_DISABLED(tt)   ((tt)->k == TRICKLE_TIMER_INFINITE_REDUNDANCY)
 Checks if the trickle timer's suppression feature is disabled. More...
 
#define TRICKLE_TIMER_PROTO_TX_ALLOW(tt)   (TRICKLE_TIMER_SUPPRESSION_DISABLED(tt) || ((tt)->c < (tt)->k))
 Determines whether the protocol must go ahead with a transmission. More...
 
#define TRICKLE_TIMER_PROTO_TX_SUPPRESS(tt)   (TRICKLE_TIMER_SUPPRESSION_ENABLED(tt) && ((tt)->c >= (tt)->k))
 Determines whether the protocol must suppress a transmission. More...
 
#define TRICKLE_TIMER_INTERVAL_MAX(tt)   ((tt)->i_max_abs)
 Returns a timer's maximum interval size (Imin << Imax) as a number of clock ticks. More...
 
#define TRICKLE_TIMER_INTERVAL_END(tt)   ((tt)->i_start + (tt)->i_cur)
 Returns the current trickle interval's end (absolute time in ticks) More...
 
#define TRICKLE_TIMER_IMIN_IS_OK(imin)   ((imin > 1) && (i_min <= (TRICKLE_TIMER_CLOCK_MAX >> 1)))
 Checks whether an Imin value is suitable considering the various restrictions imposed by our platform's clock as well as by the library itself. More...
 
#define TRICKLE_TIMER_IMIN_IS_BAD(imin)   ((imin < 2) || (i_min > (TRICKLE_TIMER_CLOCK_MAX >> 1)))
 Checks whether an Imin value is invalid considering the various restrictions imposed by our platform's clock as well as by the library itself. More...
 
#define TRICKLE_TIMER_IPAIR_IS_BAD(i_min, i_max)   ((TRICKLE_TIMER_CLOCK_MAX >> (i_max + 1)) < i_min - 1)
 Checks whether Imin << Imax is unsuitable considering the boundaries of our platform's clock_time_t. More...
 

Typedefs

Trickle Timer Library: Data Representation
typedef void(* trickle_timer_cb_t )(void *ptr, uint8_t suppress)
 typedef for a callback function to be defined in the protocol's implementation. More...
 

Trickle Timer Library: Functions called by protocol implementations

#define trickle_timer_stop(tt)
 Stop a running trickle timer. More...
 
#define trickle_timer_reset_event(tt)   trickle_timer_inconsistency(tt)
 To be called by the protocol when an external event occurs that should trigger a timer reset. More...
 
#define trickle_timer_is_running(tt)   ((tt)->i_cur != TRICKLE_TIMER_IS_STOPPED)
 To be called in order to determine whether a trickle timer is running. More...
 
uint8_t trickle_timer_config (struct trickle_timer *tt, clock_time_t i_min, uint8_t i_max, uint8_t k)
 Configure a trickle timer. More...
 
uint8_t trickle_timer_set (struct trickle_timer *tt, trickle_timer_cb_t proto_cb, void *ptr)
 Start a previously configured trickle timer. More...
 
void trickle_timer_consistency (struct trickle_timer *tt)
 To be called by the protocol when it hears a consistent transmission. More...
 
void trickle_timer_inconsistency (struct trickle_timer *tt)
 To be called by the protocol when it hears an inconsistent transmission. More...