summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 677f1d6)
raw | patch | inline | side by side (parent: 677f1d6)
author | Florian Forster <octo@collectd.org> | |
Thu, 20 Nov 2014 17:26:02 +0000 (18:26 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 6 Jul 2015 12:07:10 +0000 (14:07 +0200) |
src/mqtt.c | patch | blob | history |
diff --git a/src/mqtt.c b/src/mqtt.c
index ef46e529375c9d3171562f5c1332c9541aa19dbb..fffa8fadd3115bff298ba97c23f16e8030847bf9 100644 (file)
--- a/src/mqtt.c
+++ b/src/mqtt.c
return (0);
} /* mqtt_reconnect_broker */
-static int mqtt_publish_message (mqtt_client_conf_t *conf, char *topic,
+static int publish (mqtt_client_conf_t *conf, char const *topic,
void const *payload, size_t payload_len)
{
- char errbuf[1024];
+ int const qos = 0; /* TODO: Config option */
int status;
pthread_mutex_lock (&conf->lock);
}
status = mosquitto_publish(conf->mosq,
- /* message id */ NULL,
- topic,
- (int) payload_len,
- payload,
- /* qos */ 0,
- /* retain */ false);
+ /* message id */ NULL,
+ topic,
+ (uint32_t) payload_len, payload,
+ /* qos */ qos,
+ /* retain */ false);
if (status != MOSQ_ERR_SUCCESS)
{
+ char errbuf[1024];
c_complain (LOG_ERR,
- &conf->complaint_cantpublish,
- "plugin mqtt: mosquitto_publish failed: %s",
- status == MOSQ_ERR_ERRNO ?
- sstrerror(errno, errbuf, sizeof (errbuf)) :
+ &conf->complaint_cantpublish,
+ "plugin mqtt: mosquitto_publish failed: %s",
+ status == MOSQ_ERR_ERRNO ?
+ sstrerror(errno, errbuf, sizeof (errbuf)) :
mosquitto_strerror(status));
- /*
- Mark our connection "down" regardless of the error as a safety measure;
- we will try to reconnect the next time we have to publish a message
- */
+ /* Mark our connection "down" regardless of the error as a safety
+ * measure; we will try to reconnect the next time we have to publish a
+ * message */
conf->connected = false;
pthread_mutex_unlock (&conf->lock);
pthread_mutex_unlock (&conf->lock);
return (0);
-} /* mqtt_publish_message */
+} /* int publish */
static int format_topic (char *buf, size_t buf_len,
data_set_t const *ds, value_list_t const *vl,