add inactive flag to configuration
This commit is contained in:
@ -26,6 +26,7 @@ typedef struct {
|
|||||||
const char *deviceId;
|
const char *deviceId;
|
||||||
const char *location;
|
const char *location;
|
||||||
const char *sharedSecret;
|
const char *sharedSecret;
|
||||||
|
int inactive;
|
||||||
} t_device;
|
} t_device;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -93,8 +94,13 @@ int initConfig(const char *configFilename, t_configHandle *configHandle) {
|
|||||||
logmsg(LOG_ERR, "Configured sharedsecret for device %d is too long", i);
|
logmsg(LOG_ERR, "Configured sharedsecret for device %d is too long", i);
|
||||||
return -6;
|
return -6;
|
||||||
}
|
}
|
||||||
logmsg(LOG_INFO, "Device loaded: %d %s %s %s", i,
|
if (! config_setting_lookup_bool(deviceConfig, "inactive", &(configHandle->devices[i].inactive))) {
|
||||||
|
logmsg(LOG_INFO, "no inactive flag set for device %d, consider as active", i);
|
||||||
|
configHandle->devices[i].inactive = 0;
|
||||||
|
}
|
||||||
|
logmsg(LOG_INFO, "Device loaded: %d %s %d %s %s", i,
|
||||||
configHandle->devices[i].deviceId,
|
configHandle->devices[i].deviceId,
|
||||||
|
configHandle->devices[i].inactive,
|
||||||
configHandle->devices[i].location,
|
configHandle->devices[i].location,
|
||||||
configHandle->devices[i].sharedSecret);
|
configHandle->devices[i].sharedSecret);
|
||||||
}
|
}
|
||||||
@ -293,6 +299,7 @@ int forwardMinuteBuffer(t_forwarderHandle *handle, t_minuteBuffer *buf) {
|
|||||||
buf->s.deviceId, buf->s.totalRunningHours, buf->s.totalPowercycles, buf->s.totalWatchdogResets,
|
buf->s.deviceId, buf->s.totalRunningHours, buf->s.totalPowercycles, buf->s.totalWatchdogResets,
|
||||||
buf->s.version, location);
|
buf->s.version, location);
|
||||||
|
|
||||||
|
if (device->inactive == 0) {
|
||||||
for (uint8_t j = 0; j < SECONDS_PER_MINUTE; j++) {
|
for (uint8_t j = 0; j < SECONDS_PER_MINUTE; j++) {
|
||||||
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]);
|
||||||
@ -326,6 +333,9 @@ int forwardMinuteBuffer(t_forwarderHandle *handle, t_minuteBuffer *buf) {
|
|||||||
logmsg(LOG_ERR, "%u out of bound, ignored", buf->s.frequency[j]);
|
logmsg(LOG_ERR, "%u out of bound, ignored", buf->s.frequency[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logmsg(LOG_INFO, "Inactive device, not sent to InfluxDB");
|
||||||
|
}
|
||||||
|
|
||||||
logmsg(LOG_INFO, "Successfully sent whole minute to InfluxDB");
|
logmsg(LOG_INFO, "Successfully sent whole minute to InfluxDB");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -12,6 +12,7 @@ receivePort = 20169;
|
|||||||
|
|
||||||
devices = (
|
devices = (
|
||||||
{
|
{
|
||||||
|
inactive = true;
|
||||||
deviceId = "MainsCnt01";
|
deviceId = "MainsCnt01";
|
||||||
// sharedSecret must have exactly 31 characters
|
// sharedSecret must have exactly 31 characters
|
||||||
sharedSecret = "Uj6*uKDp@8Kvfa4g5eRMLUfVsSuqjxW";
|
sharedSecret = "Uj6*uKDp@8Kvfa4g5eRMLUfVsSuqjxW";
|
||||||
|
Reference in New Issue
Block a user