Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
code style
  • Loading branch information
chrisEff committed Apr 19, 2020
commit 47e9beec8bbfb453ff15832140f62dd66651e5bc
71 changes: 30 additions & 41 deletions RPi_utils/RFSniffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,43 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>


RCSwitch mySwitch;


RCSwitch mySwitch;

int main(int argc, char *argv[]) {

// This pin is not the first pin on the RPi GPIO header!
// Consult https://projects.drogon.net/raspberry-pi/wiringpi/pins/
// for more information.
int PIN = 2;

if(wiringPiSetup() == -1) {
printf("wiringPiSetup failed, exiting...");
return 0;
}

int pulseLength = 0;
if (argv[1] != NULL) pulseLength = atoi(argv[1]);
// This pin is not the first pin on the RPi GPIO header!
// Consult https://projects.drogon.net/raspberry-pi/wiringpi/pins/
// for more information.
int PIN = 2;

mySwitch = RCSwitch();
if (pulseLength != 0) mySwitch.setPulseLength(pulseLength);
mySwitch.enableReceive(PIN); // Receiver on interrupt 0 => that is pin #2


while(1) {

if (mySwitch.available()) {

int value = mySwitch.getReceivedValue();

if (value == 0) {
printf("Unknown encoding\n");
} else {

printf("Received %i\n", mySwitch.getReceivedValue() );
}

fflush(stdout);
mySwitch.resetAvailable();
}
usleep(100);

}
if (wiringPiSetup() == -1) {
printf("wiringPiSetup failed, exiting...");
return 0;
}

exit(0);
int pulseLength = 0;
if (argv[1] != NULL) pulseLength = atoi(argv[1]);

mySwitch = RCSwitch();
if (pulseLength != 0) mySwitch.setPulseLength(pulseLength);
mySwitch.enableReceive(PIN); // Receiver on interrupt 0 => that is pin #2

while (1) {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();

if (value == 0) {
printf("Unknown encoding\n");
} else {
printf("Received %i\n", mySwitch.getReceivedValue());
}

fflush(stdout);
mySwitch.resetAvailable();
}
usleep(100);
}
exit(0);
}