#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);
void wait_a_second()
{
+ _load_config();
pthread_create(&pwait, NULL, _wait_thread, NULL);
}
\ No newline at end of file