Add a way to determine whether a trickle timer is running
This commit is contained in:
parent
50395666fc
commit
fa7219d0b8
1 changed files with 24 additions and 1 deletions
|
@ -111,6 +111,16 @@
|
|||
*/
|
||||
#define TRICKLE_TIMER_TX_SUPPRESS 0
|
||||
#define TRICKLE_TIMER_TX_OK 1
|
||||
|
||||
/**
|
||||
* \brief A trickle timer is considered 'stopped' when
|
||||
* i_cur == TRICKLE_TIMER_IS_STOPPED.
|
||||
*
|
||||
* trickle_timer_stop() must be used to correctly disable a trickle timer.
|
||||
* Do NOT set the value of i_cur to 0 directly, as this will fail to stop the
|
||||
* timer.
|
||||
*/
|
||||
#define TRICKLE_TIMER_IS_STOPPED 0
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -437,7 +447,10 @@ uint8_t trickle_timer_set(struct trickle_timer *tt,
|
|||
* to reset a timer manually. Instead, in response to events or inconsistencies,
|
||||
* the corresponding functions must be used
|
||||
*/
|
||||
#define trickle_timer_stop(tt) ctimer_stop(&((tt)->ct))
|
||||
#define trickle_timer_stop(tt) do { \
|
||||
ctimer_stop(&((tt)->ct)); \
|
||||
(tt)->i_cur = 0; \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* \brief To be called by the protocol when it hears a consistent
|
||||
|
@ -484,6 +497,16 @@ void trickle_timer_inconsistency(struct trickle_timer *tt);
|
|||
*/
|
||||
#define trickle_timer_reset_event(tt) trickle_timer_inconsistency(tt)
|
||||
|
||||
/**
|
||||
* \brief To be called in order to determine whether a trickle timer is
|
||||
* running
|
||||
* \param tt A pointer to a ::trickle_timer structure
|
||||
* \retval 0 The timer is stopped
|
||||
* \retval non-zero The timer is running
|
||||
*
|
||||
*/
|
||||
#define trickle_timer_is_running(tt) ((tt)->i_cur != TRICKLE_TIMER_IS_STOPPED)
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __TRICKLE_TIMER_H__ */
|
||||
|
|
Loading…
Reference in a new issue