prepare buffer
This commit is contained in:
@ -5,8 +5,8 @@ LDFLAGS=-lwiringPi -lconfig
|
||||
|
||||
INST_DIR=/opt/sbin
|
||||
|
||||
REFCNT:=$(shell git rev-list --all --count)
|
||||
VERSION:=$(shell cat VERSION)
|
||||
REFCNT := $(shell git rev-list --all --count)
|
||||
VERSION := $(shell git rev-parse --short=8 HEAD)
|
||||
|
||||
.PHONY: all
|
||||
all: counter
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "sinkSender.h"
|
||||
#include "logging.h"
|
||||
#include "led.h"
|
||||
@ -23,6 +24,8 @@ const char *sharedSecret;
|
||||
static t_minuteBuffer minuteBuffer;
|
||||
static uint32_t secondOfMinute;
|
||||
|
||||
extern char VERSION[];
|
||||
|
||||
|
||||
void sinkSenderInit(config_t *pCfg) {
|
||||
if (! config_lookup_string(pCfg, SINKSERVER_KEY, &sinkServer)) {
|
||||
@ -54,8 +57,28 @@ void sinkSenderPut(uint32_t seconds, uint32_t frequency) {
|
||||
minuteBuffer.s.timestamp = seconds;
|
||||
}
|
||||
minuteBuffer.s.frequency[secondOfMinute] = frequency;
|
||||
secondOfMinute += 1;
|
||||
|
||||
if (secondOfMinute == SECONDS_PER_MINUTE) {
|
||||
logmsg(LOG_DEBUG, "minute is full");
|
||||
|
||||
minuteBuffer->s.totalRunningHours = 0;
|
||||
minuteBuffer->s.totalPowercycles = 0;
|
||||
minuteBuffer->s.totalWatchdogResets = 0;
|
||||
minuteBuffer->s.version = strtol(VERSION, NULL, 16);
|
||||
|
||||
memset(minuteBuffer->s.deviceId, 0, sizeof(minuteBuffer->s.deviceId));
|
||||
strcpy(minuteBuffer->s.deviceId, config->deviceId);
|
||||
|
||||
memcpy(minuteBuffer->s.hash, config->sharedSecret, SHA256_BLOCK_SIZE);
|
||||
SHA256_CTX ctx;
|
||||
sha256_init(&ctx);
|
||||
sha256_update(&ctx, minuteBuffer->b, sizeof(minuteBuffer->b));
|
||||
sha256_final(&ctx, minuteBuffer->s.hash);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
led(E_GREEN, true);
|
||||
|
Reference in New Issue
Block a user