Thermostat pour piloter jusqu'à 4 radiateurs avec fil pilote
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.0 KiB

  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. /*
  3. * Qt mutizone MQTT thermostat
  4. *
  5. * Copyright (C) 2019 Richard Genoud
  6. *
  7. */
  8. #ifndef MQTTCLIENT_H
  9. #define MQTTCLIENT_H
  10. #include <QHostAddress>
  11. #include <QTimer>
  12. #include "qmqtt.h"
  13. class MQTTClient: public QMQTT::Client
  14. {
  15. Q_OBJECT
  16. public:
  17. explicit MQTTClient(const QHostAddress& host = QHostAddress::LocalHost,
  18. const quint16 port = 1883,
  19. QObject* parent = NULL);
  20. virtual ~MQTTClient();
  21. void publish_msg(const QString& topic, const QString& payload);
  22. private:
  23. QTimer m_timer;
  24. public slots:
  25. void onConnected();
  26. void onSubscribed(const QString& topic);
  27. void onReceived(const QMQTT::Message& message);
  28. void onError(const QMQTT::ClientError error);
  29. void onPublished(const QMQTT::Message& message, quint16 msgid);
  30. void onDisconnected(void);
  31. signals:
  32. void new_temperature(int idx, double val);
  33. void new_hygro(int idx, double val);
  34. void new_battery(int idx, double val);
  35. void new_availability(int idx, bool ok);
  36. };
  37. #endif
  38. /* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */