Added a Qt window for output
This commit is contained in:
parent
bc7521ac95
commit
9006032f27
8 changed files with 184 additions and 36 deletions
40
source/sniffthread.cpp
Normal file
40
source/sniffthread.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue