Added a Qt window for output

This commit is contained in:
Michael Mandl 2017-10-17 22:08:05 +02:00
parent bc7521ac95
commit 9006032f27
8 changed files with 184 additions and 36 deletions

40
source/sniffthread.cpp Normal file
View file

@ -0,0 +1,40 @@
#include "sniffthread.h"
#include <wiringPi.h>
#include "rc-switch/RCSwitch.h"
#include <sstream>
void SniffThread::run()
{
wiringPiSetup();
RCSwitch mySwitch = RCSwitch();
mySwitch.enableReceive(6);
while (true)
{
if (mySwitch.available())
{
int value = mySwitch.getReceivedValue();
if (value == 0)
{
emit dataReceived("Unknown encoding");
}
else
{
std::stringstream result;
result << "Received " << value << " / ";
result << mySwitch.getReceivedBitlength() << " bit ";
result << "Protocol: " << mySwitch.getReceivedProtocol();
emit dataReceived(result.str().c_str());
}
mySwitch.resetAvailable();
}
delay(100);
}
}