aboutsummaryrefslogtreecommitdiffstats
path: root/analysis/rtt/src/mqtt_client.h
diff options
context:
space:
mode:
Diffstat (limited to 'analysis/rtt/src/mqtt_client.h')
-rw-r--r--analysis/rtt/src/mqtt_client.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/analysis/rtt/src/mqtt_client.h b/analysis/rtt/src/mqtt_client.h
index 781e742..1faa4ad 100644
--- a/analysis/rtt/src/mqtt_client.h
+++ b/analysis/rtt/src/mqtt_client.h
@@ -1,16 +1,39 @@
1
2#ifndef MQTT_CLIENT_H 1#ifndef MQTT_CLIENT_H
3#define MQTT_CLIENT_H 2#define MQTT_CLIENT_H
4 3
5#include <mosquitto.h> 4#include <mosquitto.h>
6 5
7typedef struct { 6typedef struct {
8 struct mosquitto *mosq; 7 struct mosquitto *mosq;
9} mqtt_client_t; 8} mqtt_client_t;
10 9
10/**
11 * @brief Initialize the MQTT client, connect to the broker, and subscribe to a
12 * topic.
13 *
14 * @param client Pointer to mqtt_client_t struct.
15 * @param broker_address MQTT broker IP or hostname.
16 * @param port Broker port number.
17 * @param topic Topic to subscribe to.
18 * @return int 0 on success, 1 on failure.
19 */
11int mqtt_client_init(mqtt_client_t *client, const char *broker_address, 20int mqtt_client_init(mqtt_client_t *client, const char *broker_address,
12 int port, const char *topic); 21 int port, const char *topic);
22
23/**
24 * @brief Cleanup MQTT client resources and free associated memory.
25 *
26 * @param client Pointer to mqtt_client_t struct.
27 */
13void mqtt_client_cleanup(mqtt_client_t *client); 28void mqtt_client_cleanup(mqtt_client_t *client);
29
30/**
31 * @brief Run the MQTT client loop to process network events.
32 *
33 * This function blocks indefinitely.
34 *
35 * @param client Pointer to mqtt_client_t struct.
36 */
14void mqtt_client_loop(mqtt_client_t *client); 37void mqtt_client_loop(mqtt_client_t *client);
15 38
16#endif // MQTT_CLIENT_H 39#endif