forked from 1000io/OregonPi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
44 lines (37 loc) · 798 Bytes
/
test.cpp
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
/* ===================================================
C code : test.cpp
* ===================================================
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include "RCSwitch.h"
#include "RcOok.h"
#include "Sensor.h"
int main(int argc, char *argv[])
{
int RXPIN = 1;
int TXPIN = 0;
if(wiringPiSetup() == -1)
return 0;
RCSwitch *rc = new RCSwitch(RXPIN,TXPIN);
while (1)
{
if (rc->OokAvailable())
{
char message[100];
rc->getOokCode(message);
printf("%s\n",message);
Sensor *s = Sensor::getRightSensor(message);
if (s!= NULL)
{
printf("Temp : %f\n",s->getTemperature());
printf("Humidity : %f\n",s->getHumidity());
printf("Channel : %d\n",s->getChannel());
}
delete s;
}
delay(1000);
}
}