net: contiki: etimer should call proper handler
When the timer is set, the caller needs to specify the function that is called when timer expires. Change-Id: Iae69986c6f32b789d708247b187d143e45d73828 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
9b18a6d0bb
commit
62b67666d8
9 changed files with 51 additions and 24 deletions
|
@ -832,7 +832,7 @@ PROCESS_THREAD(tcpip_process, ev, data, buf)
|
|||
#if UIP_CONF_ICMP6
|
||||
tcpip_icmp6_event = process_alloc_event();
|
||||
#endif /* UIP_CONF_ICMP6 */
|
||||
etimer_set(&periodic, CLOCK_SECOND / 2);
|
||||
etimer_set(&periodic, CLOCK_SECOND / 2, &tcpip_process);
|
||||
|
||||
uip_init();
|
||||
#ifdef UIP_FALLBACK_INTERFACE
|
||||
|
|
|
@ -121,9 +121,10 @@ uip_ds6_init(void)
|
|||
#else /* UIP_CONF_ROUTER */
|
||||
etimer_set(&uip_ds6_timer_rs,
|
||||
random_rand() % (UIP_ND6_MAX_RTR_SOLICITATION_DELAY *
|
||||
CLOCK_SECOND));
|
||||
CLOCK_SECOND),
|
||||
&tcpip_process);
|
||||
#endif /* UIP_CONF_ROUTER */
|
||||
etimer_set(&uip_ds6_timer_periodic, UIP_DS6_PERIOD);
|
||||
etimer_set(&uip_ds6_timer_periodic, UIP_DS6_PERIOD, &tcpip_process);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -707,7 +708,8 @@ uip_ds6_send_rs(struct net_buf *buf)
|
|||
uip_nd6_rs_output(buf);
|
||||
rscount++;
|
||||
etimer_set(&uip_ds6_timer_rs,
|
||||
UIP_ND6_RTR_SOLICITATION_INTERVAL * CLOCK_SECOND);
|
||||
UIP_ND6_RTR_SOLICITATION_INTERVAL * CLOCK_SECOND,
|
||||
&tcpip_process);
|
||||
} else {
|
||||
PRINTF("Router found ? (boolean): %u\n",
|
||||
(uip_ds6_defrt_choose() != NULL));
|
||||
|
|
|
@ -687,7 +687,7 @@ uip_reass(void)
|
|||
PRINTF("Starting reassembly\n");
|
||||
memcpy(FBUF, UIP_IP_BUF(buf), uip_ext_len(buf) + UIP_IPH_LEN);
|
||||
/* temporary in case we do not receive the fragment with offset 0 first */
|
||||
etimer_set(&uip_reass_timer, UIP_REASS_MAXAGE*CLOCK_SECOND);
|
||||
etimer_set(&uip_reass_timer, UIP_REASS_MAXAGE*CLOCK_SECOND, &tcpip_process);
|
||||
uip_reass_on = 1;
|
||||
uip_reassflags = 0;
|
||||
uip_id = UIP_FRAG_BUF->id;
|
||||
|
|
|
@ -71,7 +71,7 @@ PROCESS_THREAD(ctimer_process, ev, data, buf)
|
|||
PROCESS_BEGIN();
|
||||
|
||||
for(c = list_head(ctimer_list); c != NULL; c = c->next) {
|
||||
etimer_set(&c->etimer, c->etimer.timer.interval);
|
||||
etimer_set(&c->etimer, c->etimer.timer.interval, &ctimer_process);
|
||||
}
|
||||
initialized = 1;
|
||||
|
||||
|
@ -104,14 +104,15 @@ void
|
|||
ctimer_set(struct net_mbuf *buf, struct ctimer *c, clock_time_t t,
|
||||
void (*f)(struct net_mbuf *, void *), void *ptr)
|
||||
{
|
||||
PRINTF("ctimer_set %p %u\n", c, (unsigned)t);
|
||||
c->p = PROCESS_CURRENT();
|
||||
c->p = &ctimer_process;
|
||||
c->f = f;
|
||||
c->ptr = ptr;
|
||||
c->buf = buf;
|
||||
PRINTF("ctimer_set %p t %u process %p buf %p etimer %p\n",
|
||||
c, (unsigned)t, c->p, buf, &c->etimer);
|
||||
if(initialized) {
|
||||
PROCESS_CONTEXT_BEGIN(&ctimer_process);
|
||||
etimer_set(&c->etimer, t);
|
||||
etimer_set(&c->etimer, t, &ctimer_process);
|
||||
PROCESS_CONTEXT_END(&ctimer_process);
|
||||
} else {
|
||||
c->etimer.timer.interval = t;
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
static struct etimer *timerlist;
|
||||
static clock_time_t next_expiration;
|
||||
|
||||
PROCESS_NAME(ctimer_process);
|
||||
|
||||
PROCESS(etimer_process, "Event timer");
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
|
@ -97,12 +99,15 @@ PROCESS_THREAD(etimer_process, ev, data, buf)
|
|||
__FUNCTION__, __LINE__,
|
||||
t, timer_remaining(&t->timer), etimer_is_triggered(t));
|
||||
if(etimer_expired(t) && !etimer_is_triggered(t)) {
|
||||
PRINTF("%s():%d timer %p expired\n", __FUNCTION__, __LINE__, t);
|
||||
/*
|
||||
* FIXME: Fix the process thingy so that etimer can be used also
|
||||
* in other Contiki processes.
|
||||
*/
|
||||
process_post_synch(&tcpip_process, PROCESS_EVENT_TIMER, t, NULL);
|
||||
PRINTF("%s():%d timer %p expired, process %p\n",
|
||||
__FUNCTION__, __LINE__, t, t->p);
|
||||
|
||||
if (t->p == NULL) {
|
||||
PRINTF("calling tcpip_process\n");
|
||||
process_post_synch(&tcpip_process, PROCESS_EVENT_TIMER, t, NULL);
|
||||
} else {
|
||||
process_post_synch(t->p, PROCESS_EVENT_TIMER, t, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
update_time();
|
||||
|
@ -140,8 +145,9 @@ add_timer(struct etimer *timer)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
etimer_set(struct etimer *et, clock_time_t interval)
|
||||
etimer_set(struct etimer *et, clock_time_t interval, struct process *p)
|
||||
{
|
||||
et->p = p;
|
||||
timer_set(&et->timer, interval);
|
||||
add_timer(et);
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
struct etimer {
|
||||
struct timer timer;
|
||||
struct etimer *next;
|
||||
struct process *p;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -94,7 +95,8 @@ struct etimer {
|
|||
* process that called the etimer_set() function.
|
||||
*
|
||||
*/
|
||||
CCIF void etimer_set(struct etimer *et, clock_time_t interval);
|
||||
CCIF void etimer_set(struct etimer *et, clock_time_t interval,
|
||||
struct process *p);
|
||||
|
||||
/**
|
||||
* \brief Reset an event timer with the same interval as was
|
||||
|
|
|
@ -190,7 +190,7 @@ PROCESS_THREAD(rest_engine_process, ev, data, buf)
|
|||
PRINTF("Periodic: Set timer for /%s to %lu\n",
|
||||
periodic_resource->resource->url, periodic_resource->period);
|
||||
etimer_set(&periodic_resource->periodic_timer,
|
||||
periodic_resource->period);
|
||||
periodic_resource->period, &rest_engine_process);
|
||||
}
|
||||
}
|
||||
while(1) {
|
||||
|
|
|
@ -1465,7 +1465,8 @@ dtls_send_multi(dtls_context_t *ctx, dtls_peer_t *peer,
|
|||
} else {
|
||||
/* must set timer within the context of the retransmit process */
|
||||
PROCESS_CONTEXT_BEGIN(&dtls_retransmit_process);
|
||||
etimer_set(&ctx->retransmit_timer, n->timeout);
|
||||
etimer_set(&ctx->retransmit_timer, n->timeout,
|
||||
&dtls_retransmit_process);
|
||||
PROCESS_CONTEXT_END(&dtls_retransmit_process);
|
||||
#else /* WITH_CONTIKI */
|
||||
dtls_debug("copied to sendqueue\n");
|
||||
|
@ -3781,7 +3782,7 @@ dtls_new_context(void *app_data) {
|
|||
process_start(&dtls_retransmit_process, (char *)c);
|
||||
PROCESS_CONTEXT_BEGIN(&dtls_retransmit_process);
|
||||
/* the retransmit timer must be initialized to some large value */
|
||||
etimer_set(&c->retransmit_timer, 0xFFFF);
|
||||
etimer_set(&c->retransmit_timer, 0xFFFF, &dtls_retransmit_process);
|
||||
PROCESS_CONTEXT_END(&dtls_retransmit_process);
|
||||
#endif /* WITH_CONTIKI */
|
||||
|
||||
|
@ -4003,10 +4004,12 @@ PROCESS_THREAD(dtls_retransmit_process, ev, data, buf)
|
|||
|
||||
/* need to set timer to some value even if no nextpdu is available */
|
||||
if (node) {
|
||||
etimer_set(&the_dtls_context.retransmit_timer,
|
||||
node->t <= now ? 1 : node->t - now);
|
||||
etimer_set(&the_dtls_context.retransmit_timer,
|
||||
node->t <= now ? 1 : node->t - now,
|
||||
&dtls_retransmit_process);
|
||||
} else {
|
||||
etimer_set(&the_dtls_context.retransmit_timer, 0xFFFF);
|
||||
etimer_set(&the_dtls_context.retransmit_timer, 0xFFFF,
|
||||
&dtls_retransmit_process);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,6 +304,18 @@ void toggle_observation(coap_context_t *coap_ctx)
|
|||
#define WAIT_PEER TICKS_UNLIMITED
|
||||
#endif
|
||||
|
||||
PROCESS(coap_observe_client_process, "CoAP observe client process");
|
||||
PROCESS_THREAD(coap_observe_client_process, ev, data, buf)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while(1) {
|
||||
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_TIMER);
|
||||
/* Currently the timeout is handled in while loop in startup() */
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
|
||||
void startup(void)
|
||||
{
|
||||
static struct etimer et;
|
||||
|
@ -335,7 +347,8 @@ void startup(void)
|
|||
return;
|
||||
}
|
||||
|
||||
etimer_set(&et, TOGGLE_INTERVAL * sys_clock_ticks_per_sec);
|
||||
etimer_set(&et, TOGGLE_INTERVAL * sys_clock_ticks_per_sec,
|
||||
&coap_observe_client_process);
|
||||
|
||||
while (1) {
|
||||
while (!coap_context_is_connected(coap_ctx)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue