Fork of the espurna firmware for `mhsw` switches
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.

71 lines
2.0 KiB

  1. /*
  2. MQTT MODULE
  3. Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
  4. Updated secure client support by Niek van der Maas < mail at niekvandermaas dot nl>
  5. */
  6. #pragma once
  7. #include "espurna.h"
  8. #include <WString.h>
  9. #include <utility>
  10. #include <functional>
  11. using mqtt_callback_f = std::function<void(unsigned int type, const char * topic, char * payload)>;
  12. using mqtt_msg_t = std::pair<String, String>; // topic, payload
  13. #if MQTT_SUPPORT
  14. void mqttRegister(mqtt_callback_f callback);
  15. String mqttTopic(const char * magnitude, bool is_set);
  16. String mqttTopic(const char * magnitude, unsigned int index, bool is_set);
  17. String mqttMagnitude(const char* topic);
  18. bool mqttSendRaw(const char * topic, const char * message, bool retain);
  19. bool mqttSendRaw(const char * topic, const char * message);
  20. void mqttSend(const char * topic, const char * message, bool force, bool retain);
  21. void mqttSend(const char * topic, const char * message, bool force);
  22. void mqttSend(const char * topic, const char * message);
  23. void mqttSend(const char * topic, unsigned int index, const char * message, bool force, bool retain);
  24. void mqttSend(const char * topic, unsigned int index, const char * message, bool force);
  25. void mqttSend(const char * topic, unsigned int index, const char * message);
  26. void mqttSendStatus();
  27. void mqttFlush();
  28. int8_t mqttEnqueue(const char * topic, const char * message, unsigned char parent);
  29. int8_t mqttEnqueue(const char * topic, const char * message);
  30. const String& mqttPayloadOnline();
  31. const String& mqttPayloadOffline();
  32. const char* mqttPayloadStatus(bool status);
  33. void mqttSetBroker(IPAddress ip, uint16_t port);
  34. void mqttSetBrokerIfNone(IPAddress ip, uint16_t port);
  35. void mqttSubscribeRaw(const char * topic);
  36. void mqttSubscribe(const char * topic);
  37. void mqttUnsubscribeRaw(const char * topic);
  38. void mqttUnsubscribe(const char * topic);
  39. void mqttEnabled(bool status);
  40. bool mqttEnabled();
  41. bool mqttForward();
  42. bool mqttConnected();
  43. void mqttDisconnect();
  44. void mqttSetup();
  45. #endif // MQTT_SUPPORT == 1