]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add integration config integration for heartbeat config
authorBastian Dehn <hhaalo@arcor.de>
Thu, 18 Apr 2024 14:14:48 +0000 (16:14 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 18 Apr 2024 14:14:48 +0000 (16:14 +0200)
src/kds_s2000w_heartbeat.c

index 04241e4fca669c09a990664faac669f374e7d948..80b2ee754a9bdc3c490b27cdc49dc81149308ee6 100644 (file)
@@ -1,15 +1,31 @@
 #include <unistd.h>
 #include <pthread.h>
+#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