Is it possible to do what the code below does without any process? I need a timeout without surrounding it with Contiki process. Is this possible?
#include "sys/etimer.h"
PROCESS_THREAD(example_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
/* Delay 1 second */
etimer_set(&et, CLOCK_SECOND);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
/* Reset the etimer to trig again in 1 second */
etimer_reset(&et);
/* ... */
}
PROCESS_END();
}
You can use callback timers:
To get the timer started the first time, call
ctimer_set(&my_timer, CLOCK_SECOND, callback_function, NULL);
from some initialization code. It does not have to be within a process handler function.