pws2mqtt-qt/pws2mqtt.h
2024-09-10 20:34:16 +02:00

53 lines
1.2 KiB
C++

#ifndef PWS2MQTT_H
#define PWS2MQTT_H
#include <QString>
#include <QByteArray>
#include <QObject>
#include <QtMqtt>
#include <QtMqtt/QMqttClient>
#define RED "\e[31m"
#define GREEN "\e[32m"
#define BLUE "\e[94m"
#define ORANGE "\e[33m"
#define NORMAL "\e[0m"
#define DEBUG 16 // => 16
#define INFO 1 // => 1
#define NOTICE 2 // => 2
#define WARNING 4 // => 4
#define ERROR 8 // => 8
#define ALERT 32
#define ALL DEBUG | INFO | NOTICE | WARNING | ERROR | ALERT
#define DEBUGMACRO QString(__FILE__) + ": " + QString::number(__LINE__) + " -> " + QString(Q_FUNC_INFO)
void debug(QString debugHeader, QString msg, uint8_t level=ALL, QByteArray value="");
QString addValue(QByteArray value);
class Pws2mqtt : public QObject
{
Q_OBJECT
public:
Pws2mqtt();
~Pws2mqtt();
QString ProcName = "pws2mqtt"; // name of the proceesus in ps, top, pstree, ...;
FILE * logFh = nullptr;
QString listenHost = "0.0.0.0";
uint listenPort = 5000;
int sockfd;
int newsockfd;
QList <QString> deviceProperties =
{
"ieeeAddress", "type", "dateutc", "softwaretype", "action", "realtime", "freq", "wh65batt", "wh25batt", "runtime"
};
void init();
void listeningHttp();
void parseData(QByteArray data);
};
#endif // PWS2MQTT_H