aboutsummaryrefslogtreecommitdiffstats
path: root/analysis/rtt/src/mqtt_client.h
diff options
context:
space:
mode:
authorFilip Wandzio <contact@philw.dev>2025-09-05 03:30:24 +0200
committerFilip Wandzio <contact@philw.dev>2025-09-05 03:30:24 +0200
commit01713bbe20d2cf5aafbe5eb32721d3e4fc5823d8 (patch)
tree33748d0019e3939bd0daf50940407e51d4325a8f /analysis/rtt/src/mqtt_client.h
parent1ba21da6cbc63c0c549fb92731e25bedc482eb51 (diff)
downloade1-01713bbe20d2cf5aafbe5eb32721d3e4fc5823d8.tar.gz
e1-01713bbe20d2cf5aafbe5eb32721d3e4fc5823d8.zip
Standarize the project directory for monorepo-like developer experience
Move the clang formatter to the root of the three so all nested projects could use it Provide README for all other projects Refactor the code in rtt agregator Signed-off-by: Filip Wandzio <contact@philw.dev>
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