diff options
| author | Filip Wandzio <contact@philw.dev> | 2025-09-05 03:30:24 +0200 |
|---|---|---|
| committer | Filip Wandzio <contact@philw.dev> | 2025-09-05 03:30:24 +0200 |
| commit | 01713bbe20d2cf5aafbe5eb32721d3e4fc5823d8 (patch) | |
| tree | 33748d0019e3939bd0daf50940407e51d4325a8f /analysis/rtt/src/mqtt_client.h | |
| parent | 1ba21da6cbc63c0c549fb92731e25bedc482eb51 (diff) | |
| download | e1-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.h | 29 |
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 | ||
| 7 | typedef struct { | 6 | typedef 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 | */ | ||
| 11 | int mqtt_client_init(mqtt_client_t *client, const char *broker_address, | 20 | int 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 | */ | ||
| 13 | void mqtt_client_cleanup(mqtt_client_t *client); | 28 | void 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 | */ | ||
| 14 | void mqtt_client_loop(mqtt_client_t *client); | 37 | void mqtt_client_loop(mqtt_client_t *client); |
| 15 | 38 | ||
| 16 | #endif // MQTT_CLIENT_H | 39 | #endif |
