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 |
|
26 #ifdef HAVE_WIRINGPI_H |
|
27 |
|
28 int main(int argc, char *argv[]) { |
|
29 |
|
30 /* |
|
31 input PIN is hardcoded for testing purposes |
|
32 see https://projects.drogon.net/raspberry-pi/wiringpi/pins/ |
|
33 for pin mapping of the raspberry pi GPIO connector |
|
34 */ |
|
35 int PIN = 2; |
|
36 |
|
37 if (wiringPiSetup () ) |
|
38 return 1; |
|
39 |
|
40 enableReceiveIRQ(PIN); |
|
41 |
|
42 while (1) { |
|
43 if (available()) { |
|
44 |
|
45 unsigned long int value = getReceivedValue(); |
|
46 int bitlen = getReceivedBitlength(); |
|
47 |
|
48 if (value == 0) { |
|
49 printf("Unknown encoding\n"); |
|
50 } else { |
|
51 if (bitlen == 24) { |
|
52 printf("Received 0x%06lx/24 bit %s Protocol: %d", value, dec2binWzerofill(value, bitlen), getReceivedProtocol() ); |
|
53 if ((value & 0x00000000000003f0) == 0x0000000000000150) { |
|
54 printf(" Type A "); |
|
55 printf("%c%c%c%c%c ", (value & 0xc00000) ? '0' : '1', (value & 0x300000) ? '0' : '1', (value & 0x0c0000) ? '0' : '1', (value & 0x030000) ? '0' : '1', (value & 0x00c000) ? '0' : '1'); |
|
56 printf("%c%c%c%c%c ", (value & 0x003000) ? '0' : '1', (value & 0x000c00) ? '0' : '1', (value & 0x000300) ? '0' : '1', (value & 0x0000c0) ? '0' : '1', (value & 0x000030) ? '0' : '1'); |
|
57 } |
|
58 if ((value & 0x000000000000001c) == 0x0000000000000000) { |
|
59 printf(" Type E"); |
|
60 } |
|
61 printf("\n"); |
|
62 } else { |
|
63 printf("Received 0x%lx/%d bit %s Protocol: %d\n", value, bitlen, dec2binWzerofill(value, bitlen), getReceivedProtocol() ); |
|
64 } |
|
65 } |
|
66 |
|
67 resetAvailable(); |
|
68 } else { |
|
69 /* |
|
70 * Don't hog the CPU. |
|
71 */ |
|
72 delay(10); |
|
73 } |
|
74 } |
|
75 |
|
76 return 0; |
|
77 } |
|
78 |
|
79 #else |
|
80 |
|
81 int main(int argc, char *argv[]) { |
|
82 fprintf(stderr, "This program does nothing without the wiringPi library\n"); |
|
83 return 0; |
|
84 } |
|
85 |
|
86 #endif |
|
87 |
|