diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 482771d..266508b 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -4,4 +4,6 @@ add_subdirectory(RCSwitch) add_subdirectory(sniffer) add_subdirectory(qsniff) add_subdirectory(sniff) +add_subdirectory(sender) +add_subdirectory(send) diff --git a/source/send/CMakeLists.txt b/source/send/CMakeLists.txt new file mode 100644 index 0000000..b512c24 --- /dev/null +++ b/source/send/CMakeLists.txt @@ -0,0 +1,13 @@ +project(Send) +cmake_minimum_required(VERSION 3.6) + +set(CMAKE_CXX_STANDARD 11) + +add_executable(${PROJECT_NAME} + send.cpp +) + +target_link_libraries(${PROJECT_NAME} + sender +) + diff --git a/source/send/send.cpp b/source/send/send.cpp new file mode 100644 index 0000000..4ead73b --- /dev/null +++ b/source/send/send.cpp @@ -0,0 +1,22 @@ +#include "sender.h" +#include + +int main(int argc, char **argv) +{ + std::cout << "Send" << std::endl; + + Sender sender(27); + + while (true) + { + unsigned int data = 23; + + std::cout << "Sending: " << data << std::endl; + + sender.send(data); + + delay(1000); + } + + return 0; +} diff --git a/source/sender/CMakeLists.txt b/source/sender/CMakeLists.txt new file mode 100644 index 0000000..ea2a65c --- /dev/null +++ b/source/sender/CMakeLists.txt @@ -0,0 +1,18 @@ +project(sender) +cmake_minimum_required(VERSION 3.6) + +set(CMAKE_CXX_STANDARD 11) + +add_library(${PROJECT_NAME} + sender.cpp + sender.h +) + +target_link_libraries(${PROJECT_NAME} + rc-switch +) + +target_include_directories(${PROJECT_NAME} + PUBLIC . +) + diff --git a/source/sender/sender.cpp b/source/sender/sender.cpp new file mode 100644 index 0000000..b4b3a54 --- /dev/null +++ b/source/sender/sender.cpp @@ -0,0 +1,14 @@ +#include "sender.h" + +Sender::Sender(unsigned int pin) +{ + wiringPiSetup(); + + m_switch.enableTransmit(pin); +} + +void Sender::send(unsigned int data) +{ + m_switch.send(data, 32); +} + diff --git a/source/sender/sender.h b/source/sender/sender.h new file mode 100644 index 0000000..eaab164 --- /dev/null +++ b/source/sender/sender.h @@ -0,0 +1,15 @@ +#pragma once + +#include "RCSwitch.h" + +class Sender +{ + private: + RCSwitch m_switch; + + public: + Sender() = delete; + Sender(unsigned int pin); + + void send(unsigned int data); +}; diff --git a/source/sniff/CMakeLists.txt b/source/sniff/CMakeLists.txt index f0f24f7..31e9fa4 100644 --- a/source/sniff/CMakeLists.txt +++ b/source/sniff/CMakeLists.txt @@ -9,7 +9,5 @@ add_executable(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} sniffer - rc-switch - wiringPi )