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.

49 lines
1.1 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. void publish_msg(const QString& topic, const QString& payload);
  18. static MQTTClient *getInstance(void);
  19. private:
  20. explicit MQTTClient(const QHostAddress& host = QHostAddress::LocalHost,
  21. const quint16 port = 1883,
  22. QObject* parent = NULL);
  23. virtual ~MQTTClient();
  24. static MQTTClient *_singleton;
  25. QTimer m_timer;
  26. public slots:
  27. void onConnected();
  28. void onSubscribed(const QString& topic);
  29. void onReceived(const QMQTT::Message& message);
  30. void onError(const QMQTT::ClientError error);
  31. void onPublished(const QMQTT::Message& message, quint16 msgid);
  32. void onDisconnected(void);
  33. signals:
  34. void new_temperature(int idx, double val);
  35. void new_hygro(int idx, double val);
  36. void new_battery(int idx, double val);
  37. void new_availability(int idx, bool ok);
  38. };
  39. #endif
  40. /* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */