config
This commit is contained in:
@ -1,11 +1,62 @@
|
||||
#include <stdint.h>
|
||||
#include "sinkSender.h"
|
||||
#include "logging.h"
|
||||
#include "led.h"
|
||||
#include "sinkStruct.h"
|
||||
#include "sha256.h"
|
||||
#include "libconfig.h"
|
||||
|
||||
void sinkSenderInit() {
|
||||
|
||||
const char SINKSERVER_KEY[] = "sinkServer";
|
||||
const char DEFAULT_SINKSERVER[] = "sink.hottis.de";
|
||||
const char *sinkServer;
|
||||
const char SINKPORT_KEY[] = "sinkPort";
|
||||
const uint16_t DEFAULT_SINKPORT = 20169;
|
||||
const uint16_t sinkPort;
|
||||
const char DEVICE_ID_KEY[] = "deviceId";
|
||||
const char DEFAULT_DEVICE_ID[] = "mainscnt00";
|
||||
const char *deviceId;
|
||||
const char SHARED_SECRET_KEY[] = "sharedSecret";
|
||||
const char DEFAULT_SHARED_SECRET[] = "1234567890123456789012345678901";
|
||||
const char *sharedSecret;
|
||||
|
||||
static t_minuteBuffer minuteBuffer;
|
||||
static uint32_t secondOfMinute;
|
||||
|
||||
|
||||
void sinkSenderInit(config_t *pCfg) {
|
||||
if (! config_lookup_string(pCfg, SINKSERVER_KEY, &sinkServer)) {
|
||||
sinkServer = DEFAULT_SINKSERVER;
|
||||
}
|
||||
fprintf(stderr, "CONFIG: sinkServer=%s\n", sinkServer);
|
||||
if (! config_lookup_int(pCfg, SINKPORT_KEY, &sinkPort)) {
|
||||
sinkPort = DEFAULT_SINKPORT;
|
||||
}
|
||||
fprintf(stderr, "CONFIG: sinkPort=%u\n", sinkPort);
|
||||
if (! config_lookup_string(pCfg, DEVICE_ID_KEY, &deviceId)) {
|
||||
deviceId = DEFAULT_DEVICE_ID;
|
||||
}
|
||||
fprintf(stderr, "CONFIG: deviceId=%s\n", deviceId);
|
||||
if (! config_lookup_string(pCfg, SHARED_SECRET_KEY, &sharedSecret)) {
|
||||
sharedSecret = DEFAULT_SHARED_SECRET;
|
||||
}
|
||||
fprintf(stderr, "CONFIG: sharedSecret=%s\n", sharedSecret);
|
||||
|
||||
|
||||
secondOfMinute = 0;
|
||||
}
|
||||
|
||||
void sinkSenderPut(uint32_t seconds, uint32_t frequency) {
|
||||
led(E_GREEN, false);
|
||||
logmsg(LOG_DEBUG, "s: %lu, f: %lu", seconds, frequency);
|
||||
|
||||
if (secondOfMinute == 0) {
|
||||
minuteBuffer.s.timestamp = seconds;
|
||||
}
|
||||
minuteBuffer.s.frequency[secondOfMinute] = frequency;
|
||||
|
||||
|
||||
|
||||
|
||||
led(E_GREEN, true);
|
||||
}
|
Reference in New Issue
Block a user