Added console application, Fixes #5
This commit is contained in:
parent
7143900c22
commit
d12eb36ffe
5 changed files with 76 additions and 24 deletions
|
@ -1,37 +1,20 @@
|
|||
#include "sniffthread.h"
|
||||
#include <wiringPi.h>
|
||||
#include "rc-switch/RCSwitch.h"
|
||||
#include "sniffer.h"
|
||||
#include <sstream>
|
||||
|
||||
void SniffThread::run()
|
||||
{
|
||||
wiringPiSetup();
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
|
||||
mySwitch.enableReceive(6);
|
||||
Sniffer sniffer(6);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (mySwitch.available())
|
||||
unsigned int data = sniffer.receive();
|
||||
if (data != 0)
|
||||
{
|
||||
int value = mySwitch.getReceivedValue();
|
||||
std::stringstream dataStream;
|
||||
dataStream << data;
|
||||
|
||||
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();
|
||||
emit dataReceived(dataStream.str().c_str());
|
||||
}
|
||||
|
||||
delay(100);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue