1 /***************************************************************************** |
|
2 * Copyright (C) 2014 |
|
3 * |
|
4 * Michiel Broek <mbroek at mbse dot eu> |
|
5 * |
|
6 * This file is part of the mbsePi-apps |
|
7 * |
|
8 * This is free software; you can redistribute it and/or modify it |
|
9 * under the terms of the GNU General Public License as published by the |
|
10 * Free Software Foundation; either version 2, or (at your option) any |
|
11 * later version. |
|
12 * |
|
13 * mbsePi-apps is distributed in the hope that it will be useful, but |
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with EC-65K; see the file COPYING. If not, write to the Free |
|
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
21 *****************************************************************************/ |
|
22 |
|
23 #include "rc433.h" |
|
24 |
|
25 #ifdef HAVE_WIRINGPI_H |
|
26 |
|
27 int main(int argc, char *argv[]) { |
|
28 |
|
29 // This pin is not the first pin on the RPi GPIO header! |
|
30 // Consult https://projects.drogon.net/raspberry-pi/wiringpi/pins/ |
|
31 // for more information. |
|
32 int PIN = 2; |
|
33 |
|
34 if (wiringPiSetup() == -1) |
|
35 return 0; |
|
36 |
|
37 enableReceiveIRQ(PIN); // Receiver on inerrupt 0 => that is pin #2 |
|
38 |
|
39 while(1) { |
|
40 |
|
41 if (available()) { |
|
42 unsigned long value = getReceivedValue(); |
|
43 |
|
44 if (value == 0) { |
|
45 printf("Unknown encoding\n"); |
|
46 } else { |
|
47 printf("Protocol %d received 0x%lx\n", getReceivedProtocol(), value); |
|
48 } |
|
49 resetAvailable(); |
|
50 |
|
51 } else { |
|
52 /* |
|
53 * Don't hog the CPU |
|
54 */ |
|
55 delay(10); |
|
56 } |
|
57 } |
|
58 |
|
59 exit(0); |
|
60 } |
|
61 |
|
62 #else |
|
63 |
|
64 int main(int argc, char *argv[]) { |
|
65 fprintf(stderr, "This program does nothing without the wiringPi library\n"); |
|
66 return 0; |
|
67 } |
|
68 |
|
69 #endif |
|
70 |
|