-
Notifications
You must be signed in to change notification settings - Fork 0
/
FakeSensorP.nc
49 lines (40 loc) · 1.01 KB
/
FakeSensorP.nc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Source file for implementation of module Middleware
* which provides the main logic for middleware message management
*
* @author Michele Lucio
*/
generic module FakeSensorP() {
provides interface Read<uint16_t>;
uses interface Random;
uses interface Timer<TMilli> as Timer0;
} implementation {
//***************** Boot interface ********************//
command error_t Read.read(){
call Timer0.startOneShot( 10 );
return SUCCESS;
}
uint8_t getKinematicStatus(){
uint8_t kinematicStatus = call Random.rand16() % 100;
switch(kinematicStatus){
case 0 ... 29:
return STANDING; //11
break;
case 30 ... 59:
return WALKING; //12
break;
case 60 ... 89:
return RUNNING; //13
break;
case 90 ... 99:
return FALLING; //14
break;
default:
return 0;
}
}
//***************** Timer0 interface ********************//
event void Timer0.fired() {
signal Read.readDone( SUCCESS, getKinematicStatus() );
}
}