// SPDX-License-Identifier: GPL-3.0-or-later
|
|
/*
|
|
* Qt mutizone MQTT thermostat
|
|
*
|
|
* Copyright (C) 2019 Richard Genoud
|
|
*
|
|
*/
|
|
|
|
#ifndef MQTTCLIENT_H
|
|
#define MQTTCLIENT_H
|
|
|
|
#include <QHostAddress>
|
|
#include <QTimer>
|
|
|
|
#include "qmqtt.h"
|
|
|
|
class MQTTClient: public QMQTT::Client
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit MQTTClient(const QHostAddress& host = QHostAddress::LocalHost,
|
|
const quint16 port = 1883,
|
|
QObject* parent = NULL);
|
|
virtual ~MQTTClient();
|
|
void publish_msg(const QString& topic, const QString& payload);
|
|
|
|
private:
|
|
QTimer m_timer;
|
|
|
|
public slots:
|
|
void onConnected();
|
|
void onSubscribed(const QString& topic);
|
|
void onReceived(const QMQTT::Message& message);
|
|
void onError(const QMQTT::ClientError error);
|
|
void onPublished(const QMQTT::Message& message, quint16 msgid);
|
|
void onDisconnected(void);
|
|
|
|
signals:
|
|
void new_temperature(int idx, double val);
|
|
void new_hygro(int idx, double val);
|
|
void new_battery(int idx, double val);
|
|
void new_availability(int idx, bool ok);
|
|
};
|
|
|
|
#endif
|
|
|
|
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */
|