From 01713bbe20d2cf5aafbe5eb32721d3e4fc5823d8 Mon Sep 17 00:00:00 2001 From: Filip Wandzio Date: Fri, 5 Sep 2025 03:30:24 +0200 Subject: 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 --- analysis/rtt/src/main.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'analysis/rtt/src/main.c') diff --git a/analysis/rtt/src/main.c b/analysis/rtt/src/main.c index 13f7716..163b5f6 100644 --- a/analysis/rtt/src/main.c +++ b/analysis/rtt/src/main.c @@ -1,4 +1,3 @@ - #include "logger.h" #include "mqtt_client.h" #include @@ -8,21 +7,26 @@ #define TOPIC "device/echo/in" #define CSV_FILE "rtt_throughput_log.csv" -int main() { - mqtt_client_t client; - - logger_init(CSV_FILE); - - if (mqtt_client_init(&client, BROKER_ADDRESS, BROKER_PORT, TOPIC) != 0) { - fprintf(stderr, "MQTT initialization error\n"); - return 1; - } - - printf("Connection established.Waiting for messages...\n"); - mqtt_client_loop(&client); - - logger_cleanup(); - mqtt_client_cleanup(&client); - - return 0; +/** + * @brief Entry point for MQTT client program. + * + * Initializes the logger and MQTT client, then enters the MQTT loop to receive + * messages. Cleans up resources on exit. + * + * @return int Exit code (0 on success, 1 on failure). + */ +int main(void) +{ + mqtt_client_t client; + logger_init(CSV_FILE); + + if (mqtt_client_init(&client, BROKER_ADDRESS, BROKER_PORT, TOPIC)) + return fprintf(stderr, "MQTT initialization error\n"), 1; + + printf("Connection established. Waiting for messages...\n"); + mqtt_client_loop(&client); + logger_cleanup(); + mqtt_client_cleanup(&client); + + return 0; } -- cgit v1.2.3