aboutsummaryrefslogtreecommitdiffstats
path: root/analysis/rtt/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'analysis/rtt/src/main.c')
-rw-r--r--analysis/rtt/src/main.c40
1 files changed, 22 insertions, 18 deletions
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 @@
1
2#include "logger.h" 1#include "logger.h"
3#include "mqtt_client.h" 2#include "mqtt_client.h"
4#include <stdio.h> 3#include <stdio.h>
@@ -8,21 +7,26 @@
8#define TOPIC "device/echo/in" 7#define TOPIC "device/echo/in"
9#define CSV_FILE "rtt_throughput_log.csv" 8#define CSV_FILE "rtt_throughput_log.csv"
10 9
11int main() { 10/**
12 mqtt_client_t client; 11 * @brief Entry point for MQTT client program.
13 12 *
14 logger_init(CSV_FILE); 13 * Initializes the logger and MQTT client, then enters the MQTT loop to receive
15 14 * messages. Cleans up resources on exit.
16 if (mqtt_client_init(&client, BROKER_ADDRESS, BROKER_PORT, TOPIC) != 0) { 15 *
17 fprintf(stderr, "MQTT initialization error\n"); 16 * @return int Exit code (0 on success, 1 on failure).
18 return 1; 17 */
19 } 18int main(void)
20 19{
21 printf("Connection established.Waiting for messages...\n"); 20 mqtt_client_t client;
22 mqtt_client_loop(&client); 21 logger_init(CSV_FILE);
23 22
24 logger_cleanup(); 23 if (mqtt_client_init(&client, BROKER_ADDRESS, BROKER_PORT, TOPIC))
25 mqtt_client_cleanup(&client); 24 return fprintf(stderr, "MQTT initialization error\n"), 1;
26 25
27 return 0; 26 printf("Connection established. Waiting for messages...\n");
27 mqtt_client_loop(&client);
28 logger_cleanup();
29 mqtt_client_cleanup(&client);
30
31 return 0;
28} 32}