sinkserver/sink/sink20169.c

43 lines
917 B
C
Raw Normal View History

2021-02-08 14:53:49 +01:00
#include <stdio.h>
2021-02-09 18:37:11 +01:00
#include <stdlib.h>
2021-02-08 15:41:06 +01:00
2021-02-08 18:07:17 +01:00
#include <sinkStruct.h>
2021-02-09 18:32:58 +01:00
#include <logging.h>
#include <libconfig.h>
2021-02-08 18:07:17 +01:00
typedef struct {
char deviceId[sizeof(((t_configBlock*)0)->deviceId)];
char sharedSecret[sizeof(((t_configBlock*)0)->sharedSecret)];
} t_device;
const t_device devices[] = {
{ .deviceId = "MainsCnt01", .sharedSecret = "sharedSecretGanzGeheim" },
2021-02-08 18:13:30 +01:00
{ .deviceId = "", .sharedSecret = "" }
2021-02-08 18:07:17 +01:00
};
2021-02-09 18:32:58 +01:00
config_t cfg;
2021-02-08 18:07:17 +01:00
2021-02-08 14:53:49 +01:00
2021-02-09 18:37:11 +01:00
int readConfig() {
2021-02-09 18:32:58 +01:00
config_init(&cfg);
if (! config_read_file(&cfg, "/etc/sink20169.cfg")) {
logmsg(LOG_ERR, "failed to read config file: %s:%d - %s\n",
config_error_file(&cfg), config_error_line(&cfg),
config_error_text(&cfg));
config_destroy(&cfg);
exit(-1);
}
}
2021-02-08 18:07:17 +01:00
2021-02-09 18:32:58 +01:00
int main() {
readConfig();
int res = receiver(cfg);
if (res < 0) {
logmsg(LOG_ERR, "receiver failed to start, error: ", res);
2021-02-08 15:41:06 +01:00
}
2021-02-09 18:37:11 +01:00
config_destroy(&cfg);
2021-02-08 16:00:36 +01:00
}