Merge pull request #359 from g-oikonomou/trickle-timer-stop
Add a method to stop running trickle timers
This commit is contained in:
commit
1698c439c5
|
@ -276,7 +276,9 @@ fire(void *ptr)
|
||||||
loctt->cb(loctt->cb_arg, TRICKLE_TIMER_PROTO_TX_ALLOW(loctt));
|
loctt->cb(loctt->cb_arg, TRICKLE_TIMER_PROTO_TX_ALLOW(loctt));
|
||||||
}
|
}
|
||||||
|
|
||||||
schedule_for_end(loctt);
|
if(trickle_timer_is_running(loctt)) {
|
||||||
|
schedule_for_end(loctt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* New trickle interval, either due to a newly set trickle timer or due to an
|
/* New trickle interval, either due to a newly set trickle timer or due to an
|
||||||
|
|
|
@ -111,6 +111,16 @@
|
||||||
*/
|
*/
|
||||||
#define TRICKLE_TIMER_TX_SUPPRESS 0
|
#define TRICKLE_TIMER_TX_SUPPRESS 0
|
||||||
#define TRICKLE_TIMER_TX_OK 1
|
#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,
|
* to reset a timer manually. Instead, in response to events or inconsistencies,
|
||||||
* the corresponding functions must be used
|
* 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 = TRICKLE_TIMER_IS_STOPPED; \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief To be called by the protocol when it hears a consistent
|
* \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)
|
#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__ */
|
#endif /* __TRICKLE_TIMER_H__ */
|
||||||
|
|
Loading…
Reference in a new issue