Added sender console app. Fixes #7

sender
mandlm 2017-10-19 17:17:52 +02:00
parent bbd03b56bb
commit 2dcae04869
7 changed files with 84 additions and 2 deletions

View File

@ -4,4 +4,6 @@ add_subdirectory(RCSwitch)
add_subdirectory(sniffer) add_subdirectory(sniffer)
add_subdirectory(qsniff) add_subdirectory(qsniff)
add_subdirectory(sniff) add_subdirectory(sniff)
add_subdirectory(sender)
add_subdirectory(send)

View 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
View 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;
}

View 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
View 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
View 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);
};

View File

@ -9,7 +9,5 @@ add_executable(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
sniffer sniffer
rc-switch
wiringPi
) )