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.

57 lines
1.6 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 <WString.h>
  8. #include <utility>
  9. #include <functional>
  10. using mqtt_callback_f = std::function<void(unsigned int type, const char * topic, char * payload)>;
  11. using mqtt_msg_t = std::pair<String, String>; // topic, payload
  12. // TODO: need this prototype for .ino
  13. class AsyncMqttClientMessageProperties;
  14. #if MQTT_SUPPORT
  15. #if MQTT_LIBRARY == MQTT_LIBRARY_ASYNCMQTTCLIENT
  16. #include <ESPAsyncTCP.h>
  17. #include <AsyncMqttClient.h>
  18. #elif MQTT_LIBRARY == MQTT_LIBRARY_ARDUINOMQTT
  19. #include <MQTTClient.h>
  20. #elif MQTT_LIBRARY == MQTT_LIBRARY_PUBSUBCLIENT
  21. #include <PubSubClient.h>
  22. #endif
  23. void mqttRegister(mqtt_callback_f callback);
  24. String mqttTopic(const char * magnitude, bool is_set);
  25. String mqttTopic(const char * magnitude, unsigned int index, bool is_set);
  26. String mqttMagnitude(char * topic);
  27. bool mqttSendRaw(const char * topic, const char * message, bool retain);
  28. bool mqttSendRaw(const char * topic, const char * message);
  29. void mqttSend(const char * topic, const char * message, bool force, bool retain);
  30. void mqttSend(const char * topic, const char * message, bool force);
  31. void mqttSend(const char * topic, const char * message);
  32. void mqttSend(const char * topic, unsigned int index, const char * message, bool force);
  33. void mqttSend(const char * topic, unsigned int index, const char * message);
  34. const String& mqttPayloadOnline();
  35. const String& mqttPayloadOffline();
  36. const char* mqttPayloadStatus(bool status);
  37. void mqttSendStatus();
  38. #endif // MQTT_SUPPORT == 1