From 3cbccf5d2326167bc21ec338a676b6cc467f1f21 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Thu, 18 Apr 2024 16:14:48 +0200 Subject: [PATCH] add integration config integration for heartbeat config --- src/kds_s2000w_heartbeat.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/kds_s2000w_heartbeat.c b/src/kds_s2000w_heartbeat.c index 04241e4..80b2ee7 100644 --- a/src/kds_s2000w_heartbeat.c +++ b/src/kds_s2000w_heartbeat.c @@ -1,15 +1,31 @@ #include #include +#include "config.h" +#include "kds_s2000w_config.h" #include "kds_s2000w_heartbeat.h" +program_config heartbeat_config; pthread_t pwait; void* _wait_thread(void *args) { - sleep(2); + sleep(heartbeat_config.heartbeat); return NULL; } +void _load_config() +{ + if (heartbeat_config.heartbeat != 0) + return; + + const char* config_file = CONFIG_FILE; + char* config_stream = read_config_file(config_file); + if (config_stream == NULL) + return; + + load_config(&heartbeat_config, config_stream); +} + void join_thread() { pthread_join(pwait, NULL); @@ -17,5 +33,6 @@ void join_thread() void wait_a_second() { + _load_config(); pthread_create(&pwait, NULL, _wait_thread, NULL); } \ No newline at end of file -- 2.39.5