From bc7521ac95da29f829144155e43997c2e20b0b48 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 17 Oct 2017 16:50:20 +0200 Subject: [PATCH] Sniff 433MHz data packages using rc-switch --- .gitmodules | 3 +++ source/CMakeLists.txt | 15 ++++++++++++--- source/qSniff.cpp | 8 -------- source/qsniff.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ source/rc-switch | 1 + 5 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 .gitmodules delete mode 100644 source/qSniff.cpp create mode 100644 source/qsniff.cpp create mode 160000 source/rc-switch diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9e20115 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "source/rc-switch"] + path = source/rc-switch + url = git@github.com:sui77/rc-switch.git diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 9c108a5..48305e7 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,6 +1,15 @@ -project(qSniff) +cmake_minimum_required(VERSION 3.7) +add_definitions(-DRPI) -add_executable(${PROJECT_NAME} - qSniff.cpp +add_library(rc-switch + rc-switch/RCSwitch.cpp + rc-switch/RCSwitch.h ) + +add_executable(qSniff + qsniff.cpp +) + +target_link_libraries(qSniff rc-switch wiringPi) + diff --git a/source/qSniff.cpp b/source/qSniff.cpp deleted file mode 100644 index e4d6d7c..0000000 --- a/source/qSniff.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int main(int argc, char **argv) -{ - std::cout << "qSniff" << std::endl; - - return 0; -} diff --git a/source/qsniff.cpp b/source/qsniff.cpp new file mode 100644 index 0000000..2f12d28 --- /dev/null +++ b/source/qsniff.cpp @@ -0,0 +1,40 @@ +#include "rc-switch/RCSwitch.h" +#include +#include + +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; +} diff --git a/source/rc-switch b/source/rc-switch new file mode 160000 index 0000000..cf4b005 --- /dev/null +++ b/source/rc-switch @@ -0,0 +1 @@ +Subproject commit cf4b0053d72bbfa6831d6ff636dbd249ec385cff