Files
UvosSmartHomeInterface/src/broadcast.h
Carl Klemm b0b4a985e9 ocupancy sensor now uses libnl to collect connected devices
fixed regulator saving values as int instead of double
2020-02-13 19:22:14 +01:00

54 lines
944 B
C++

#ifndef BROADCAST_H
#define BROADCAST_H
#include <QIODevice>
#include <QObject>
#include <QString>
#include <QJsonObject>
#include "sensors/sensor.h"
class BroadCast: public QObject
{
Q_OBJECT
private:
bool master_;
static constexpr uint8_t MODE_PREPACKET = 0;
static constexpr uint8_t MODE_PACKET = 1;
QByteArray buffer_;
QIODevice* const iodevice_;
void write(const char * const buffer, const size_t length);
void write(const QByteArray& buffer);
void decode();
void decodeMaster();
private slots:
void readyRead();
public slots:
void requestJson();
signals:
void jsonRequested();
void gotJson(QJsonObject json);
void gotSensorState(Sensor sensor);
public:
BroadCast(QIODevice* const iodevice = nullptr, bool master = true);
void sendJson(const QJsonObject& json);
void sendMessage(const QString& title, const QString& body);
};
#endif // BROADCAST_H