Sniff 433MHz data packages using rc-switch

This commit is contained in:
mandlm 2017-10-17 16:50:20 +02:00
parent 5072921182
commit bc7521ac95
5 changed files with 56 additions and 11 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "source/rc-switch"]
path = source/rc-switch
url = git@github.com:sui77/rc-switch.git

View File

@ -1,6 +1,15 @@
project(qSniff) cmake_minimum_required(VERSION 3.7)
add_definitions(-DRPI)
add_executable(${PROJECT_NAME} add_library(rc-switch
qSniff.cpp rc-switch/RCSwitch.cpp
rc-switch/RCSwitch.h
) )
add_executable(qSniff
qsniff.cpp
)
target_link_libraries(qSniff rc-switch wiringPi)

View File

@ -1,8 +0,0 @@
#include <iostream>
int main(int argc, char **argv)
{
std::cout << "qSniff" << std::endl;
return 0;
}

40
source/qsniff.cpp Normal file
View File

@ -0,0 +1,40 @@
#include "rc-switch/RCSwitch.h"
#include <wiringPi.h>
#include <iostream>
int main(int argc, char **argv)
{
std::cout << "qSniff" << std::endl;
wiringPiSetup();
RCSwitch mySwitch = RCSwitch();
mySwitch.enableReceive(6);
while (true)
{
if (mySwitch.available())
{
int value = mySwitch.getReceivedValue();
if (value == 0)
{
std::cout << "Unknown encoding" << std::endl;
}
else
{
std::cout << "Received " << value << " / ";
std::cout << mySwitch.getReceivedBitlength() << " bit ";
std::cout << "Protocol: " << mySwitch.getReceivedProtocol();
std::cout << std::endl;
}
mySwitch.resetAvailable();
}
delay(100);
}
return 0;
}

1
source/rc-switch Submodule

@ -0,0 +1 @@
Subproject commit cf4b0053d72bbfa6831d6ff636dbd249ec385cff