9static const char *
const TAG =
"mqtt.custom";
15 char buf[VALUE_ACCURACY_MAX_LEN];
21 int len = snprintf(buffer,
sizeof(buffer),
"%d", value);
bool publish(const std::string &topic, const std::string &payload, uint8_t qos=0, bool retain=false)
Publish an MQTT message with the given payload and QoS and retain settings.
bool is_connected()
Check whether the MQTT client is currently connected and messages can be published.
bool publish_json(const std::string &topic, const json::json_build_t &f, uint8_t qos, bool retain)
Publish a JSON-encoded MQTT message with the given Quality of Service and retain settings.
bool publish(const MQTTMessage &message)
Publish a MQTTMessage.
bool publish_json(const std::string &topic, const json::json_build_t &f, uint8_t qos=0, bool retain=false)
Construct and send a JSON MQTT message.
std::function< void(JsonObject)> json_build_t
Callback function typedef for building JsonObjects.
MQTTClientComponent * global_mqtt_client
size_t value_accuracy_to_buf(std::span< char, VALUE_ACCURACY_MAX_LEN > buf, float value, int8_t accuracy_decimals)
Format value with accuracy to buffer, returns chars written (excluding null)