forked from r10r/rcswitch-pi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
receive.cpp
51 lines (33 loc) · 1.19 KB
/
receive.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
45
46
47
48
49
50
/*
Based on https://github.com/ninjablocks/433Utils
*/
#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
/*
output PIN is hardcoded for testing purposes
see https://projects.drogon.net/raspberry-pi/wiringpi/pins/
for pin mapping of the raspberry pi GPIO connector
*/
int PIN = 3;
if (wiringPiSetup () == -1) return 1;
printf("Start \n");
RCSwitch mySwitch = RCSwitch();
mySwitch.enableReceive(PIN);
while(1) {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if (value == 0) {
printf("Unknown encoding");
} else {
//printf("Received %i\n", mySwitch.getReceivedValue() );
printf("KOD, dlugosc kodu bitowo, czas kodu, surowe dane, protokol \n");
//printf("CODE, binary code lenght, code length [ms] , raw data, protocol \n");
printf("Received %i %i %i %i %i\n", mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol() );
}
mySwitch.resetAvailable();
}
}
return 0;
}