cleanup and made it working!

This commit is contained in:
2020-04-18 19:57:47 +02:00
parent b3d250dd43
commit 4544a38175
6 changed files with 548 additions and 488 deletions

4
.gitignore vendored
View File

@@ -1,4 +1,5 @@
<<<<<<< HEAD
build-*
# ---> C++
# Prerequisites
*.d
@@ -32,7 +33,6 @@
*.exe
*.out
*.app
=======
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##

View File

@@ -4,6 +4,8 @@
#TARGET = TS_WIFILED
TEMPLATE = lib
QT += core network
CONFIG += c++14
HEADERS = \
$$PWD/include/teamlog/logtypes.h \
@@ -14,10 +16,12 @@ HEADERS = \
$$PWD/include/teamspeak/public_rare_definitions.h \
$$PWD/include/plugin_definitions.h \
$$PWD/include/ts3_functions.h \
$$PWD/src/plugin.h
$$PWD/src/plugin.h \ \
src/ledhandler.h
SOURCES = \
$$PWD/src/plugin.c
$$PWD/src/plugin.cpp \
src/ledhandler.cpp
INCLUDEPATH = \
$$PWD/include \

59
src/ledhandler.cpp Normal file
View File

@@ -0,0 +1,59 @@
#include "ledhandler.h"
LEDHandler::LEDHandler(QUdpSocket* sock, TS3Functions ts3Functions)
{
mSock = sock;
mTs3Functions = ts3Functions;
connect(mSock, &QUdpSocket::connected, this, &LEDHandler::connected);
connect(mSock, &QUdpSocket::disconnected, this, &LEDHandler::disconnected);
connect(mSock, &QUdpSocket::hostFound, this, &LEDHandler::hostFound);
}
void LEDHandler::talkingStarted()
{
printf("started\n");
sendColor(0, 0, 255, 255, 255);
}
void LEDHandler::talkingEnded()
{
printf("stopped\n");
sendColor(0, 0, 0, 0, 0);
}
void LEDHandler::sendColor(int R, int G, int B, int W, int t)
{
QByteArray msg;
msg[0] = 3; // protocol: DRGBW
msg[1] = t; // timeout
msg[2] = R; // R
msg[2] = B; // G
msg[2] = G; // B
msg[2] = W; // W
mSock->write(msg);
}
void LEDHandler::connected()
{
mTs3Functions.logMessage("CONNECTED", LogLevel_INFO, "Plugin", 0);
printf("CONNECTED\n");
}
void LEDHandler::disconnected()
{
mTs3Functions.logMessage("DISCONNECTED", LogLevel_INFO, "Plugin", 0);
printf("DISCONNECTED\n");
}
void LEDHandler::hostFound()
{
mTs3Functions.logMessage("HOST FOUND", LogLevel_INFO, "Plugin", 0);
printf("HOST FOUND\n");
}
//const char* LED_URL_SAVE = "http://10.0.0.222/win&PS=16&NN";
//const char* LED_URL_ON = "http://10.0.0.222/win&T=1&FX=0&R=0&B=255&G=0&W=0&A=255&NN";
//const char* LED_URL_OFF= "http://10.0.0.222/win&PL=16&NN";
//const char* LED_URL_POKE = "http://10.0.0.222/win&PL=15&NN";

30
src/ledhandler.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef LEDHANDLER_H
#define LEDHANDLER_H
#include <QUdpSocket>
#include <ts3_functions.h>
class LEDHandler : public QObject
{
public:
QString cURL = "10.0.0.222";
int cPORT = 21324;
LEDHandler(QUdpSocket* sock, TS3Functions ts3Functions);
void talkingEnded();
void talkingStarted();
public slots:
void connected();
void disconnected();
void hostFound();
private:
QUdpSocket* mSock;
TS3Functions mTs3Functions;
void sendColor(int R, int G, int B, int W, int t);
};
#endif // LEDHANDLER_H

File diff suppressed because it is too large Load Diff

View File

@@ -7,16 +7,30 @@
#ifndef PLUGIN_H
#define PLUGIN_H
#include <QUdpSocket>
#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32)
#include <Windows.h>
#define PLUGINS_EXPORTDLL __declspec(dllexport)
#else
#define PLUGINS_EXPORTDLL __attribute__ ((visibility("default")))
#endif
#include "ledhandler.h"
#include "ts3_functions.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#ifdef __cplusplus
extern "C" {
#endif
QUdpSocket *mUdpSock;
LEDHandler *mLedHandler;
/* Required functions */
PLUGINS_EXPORTDLL const char* ts3plugin_name();
PLUGINS_EXPORTDLL const char* ts3plugin_version();