Added sender console app. Fixes #7
This commit is contained in:
parent
bbd03b56bb
commit
2dcae04869
7 changed files with 84 additions and 2 deletions
|
@ -4,4 +4,6 @@ add_subdirectory(RCSwitch)
|
|||
add_subdirectory(sniffer)
|
||||
add_subdirectory(qsniff)
|
||||
add_subdirectory(sniff)
|
||||
add_subdirectory(sender)
|
||||
add_subdirectory(send)
|
||||
|
||||
|
|
13
source/send/CMakeLists.txt
Normal file
13
source/send/CMakeLists.txt
Normal file
|
@ -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
|
||||
)
|
||||
|
22
source/send/send.cpp
Normal file
22
source/send/send.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "sender.h"
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
18
source/sender/CMakeLists.txt
Normal file
18
source/sender/CMakeLists.txt
Normal file
|
@ -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 .
|
||||
)
|
||||
|
14
source/sender/sender.cpp
Normal file
14
source/sender/sender.cpp
Normal file
|
@ -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);
|
||||
}
|
||||
|
15
source/sender/sender.h
Normal file
15
source/sender/sender.h
Normal file
|
@ -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);
|
||||
};
|
|
@ -9,7 +9,5 @@ add_executable(${PROJECT_NAME}
|
|||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
sniffer
|
||||
rc-switch
|
||||
wiringPi
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue