Contiki 3.x
test-rain.c
Go to the documentation of this file.
1 /**
2  * \file
3  * Dummy contiki application that des nothing. Literally.
4  * Might be useful for relay only nodes.
5  */
6 #include <stdbool.h>
7 #include <stdio.h>
8 #include <math.h>
9 #include "contiki.h"
10 #include "ms-io.h"
11 
12 float floor2(float x){
13  if(x>=0.0f) return (float) ((int)x);
14  else return (float) ((int)x-1);
15 }
16 
17 PROCESS(do_nothing_process, "Process that does nothing");
18 
19 AUTOSTART_PROCESSES(&do_nothing_process);
20 
21 PROCESS_THREAD(do_nothing_process, ev, data) {
22  static struct etimer sample_timer;
23  static uint32_t rain_val;
24 
25  PROCESS_BEGIN();
26 
27  ms_init();
28  ms_sense_on();
29 
30  while (true) {
31 
32  ms_get_rain(&rain_val);
33 
34  printf("Rain Count: %ld\n\n", rain_val);
35 
36  etimer_set(&sample_timer, CLOCK_SECOND * 10);
37 
39  }
40 
41  PROCESS_END();
42 }
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
Definition: etimer.c:177
#define PROCESS_END()
Define the end of a process.
Definition: process.h:131
#define PROCESS(name, strname)
Declare a process.
Definition: process.h:307
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
Definition: process.h:273
A timer.
Definition: etimer.h:76
#define CLOCK_SECOND
A second, measured in system clock time.
Definition: clock.h:82
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
Definition: process.h:141
#define PROCESS_BEGIN()
Define the beginning of a process.
Definition: process.h:120