lower and upper bound
This commit is contained in:
@ -41,6 +41,8 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
t_configHandle *configHandle;
|
t_configHandle *configHandle;
|
||||||
|
uint32_t lowerBound;
|
||||||
|
uint32_t upperBound;
|
||||||
const char *influxUser;
|
const char *influxUser;
|
||||||
const char *influxPass;
|
const char *influxPass;
|
||||||
const char *influxServer;
|
const char *influxServer;
|
||||||
@ -236,6 +238,14 @@ int initForwarder(t_configHandle *configHandle, t_forwarderHandle *handle) {
|
|||||||
}
|
}
|
||||||
logmsg(LOG_INFO, "influxUrl is %s", handle->influxUrl);
|
logmsg(LOG_INFO, "influxUrl is %s", handle->influxUrl);
|
||||||
|
|
||||||
|
uint32_t lowerBound = 45000;
|
||||||
|
config_lookup_int(&(configHandle->cfg), "lowerBound", &lowerBound);
|
||||||
|
handle->lowerBound = lowerBound;
|
||||||
|
uint32_t upperBound = 55000;
|
||||||
|
config_lookup_int(&(configHandle->cfg), "upperBound", &upperBound);
|
||||||
|
handle->upperBound = upperBound;
|
||||||
|
logmsg(LOG_INFO, "lowerBound: %u, upperBound: %u", lowerBound, upperBound);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,6 +291,7 @@ int forwardMinuteBuffer(t_forwarderHandle *handle, t_minuteBuffer *buf) {
|
|||||||
uint64_t timestamp = buf->s.timestamp + j;
|
uint64_t timestamp = buf->s.timestamp + j;
|
||||||
logmsg(LOG_DEBUG, "Time: %lu, Frequency: %u", timestamp, buf->s.frequency[j]);
|
logmsg(LOG_DEBUG, "Time: %lu, Frequency: %u", timestamp, buf->s.frequency[j]);
|
||||||
|
|
||||||
|
if ((buf->s.frequency[j] >= handle->lowerBound) && (buf->s.frequency[j] <= handle->upperBound)) {
|
||||||
int frequency_before_point = buf->s.frequency[j] / 1000;
|
int frequency_before_point = buf->s.frequency[j] / 1000;
|
||||||
int frequency_behind_point = buf->s.frequency[j] - (frequency_before_point * 1000);
|
int frequency_behind_point = buf->s.frequency[j] - (frequency_before_point * 1000);
|
||||||
|
|
||||||
@ -305,6 +316,9 @@ int forwardMinuteBuffer(t_forwarderHandle *handle, t_minuteBuffer *buf) {
|
|||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
logmsg(LOG_DEBUG, "Successfully sent to InfluxDB");
|
logmsg(LOG_DEBUG, "Successfully sent to InfluxDB");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logmsg(LOG_ERR, "%u out of bound", buf->s.frequency[j]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logmsg(LOG_INFO, "Successfully sent whole minute to InfluxDB");
|
logmsg(LOG_INFO, "Successfully sent whole minute to InfluxDB");
|
||||||
|
@ -5,6 +5,9 @@ influxPort = 8086;
|
|||||||
influxDatabase = "smarthome2";
|
influxDatabase = "smarthome2";
|
||||||
influxMeasurement = "mainsfrequency";
|
influxMeasurement = "mainsfrequency";
|
||||||
|
|
||||||
|
lowerBound = 45000;
|
||||||
|
upperBound = 55000;
|
||||||
|
|
||||||
receivePort = 20169;
|
receivePort = 20169;
|
||||||
|
|
||||||
devices = (
|
devices = (
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sha256.h>
|
#include <sha256.h>
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#define SECONDS_PER_MINUTE 60
|
#define SECONDS_PER_MINUTE 60
|
||||||
typedef struct __attribute__((__packed__)) {
|
typedef struct __attribute__((__packed__)) {
|
||||||
char deviceId[sizeof(((t_configBlock*)0)->deviceId)];
|
char deviceId[16];
|
||||||
uint8_t hash[SHA256_BLOCK_SIZE];
|
uint8_t hash[SHA256_BLOCK_SIZE];
|
||||||
uint32_t totalRunningHours;
|
uint32_t totalRunningHours;
|
||||||
uint32_t totalPowercycles;
|
uint32_t totalPowercycles;
|
||||||
|
Reference in New Issue
Block a user