From 035a28887455acf0c7a2f278c51613313a2f9457 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Sat, 17 Apr 2021 19:02:25 +0200 Subject: [PATCH] logging for inactive devices --- sink/sink20169.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sink/sink20169.c b/sink/sink20169.c index a4ad7fc..89cc72d 100644 --- a/sink/sink20169.c +++ b/sink/sink20169.c @@ -299,11 +299,11 @@ int forwardMinuteBuffer(t_forwarderHandle *handle, t_minuteBuffer *buf) { buf->s.deviceId, buf->s.totalRunningHours, buf->s.totalPowercycles, buf->s.totalWatchdogResets, buf->s.version, location); - if (device->inactive == 0) { - for (uint8_t j = 0; j < SECONDS_PER_MINUTE; j++) { - uint64_t timestamp = buf->s.timestamp + j; - logmsg(LOG_DEBUG, "Time: %lu, Frequency: %u", timestamp, buf->s.frequency[j]); + for (uint8_t j = 0; j < SECONDS_PER_MINUTE; j++) { + uint64_t timestamp = buf->s.timestamp + j; + logmsg(LOG_DEBUG, "Time: %lu, Frequency: %u", timestamp, buf->s.frequency[j]); + if (device->inactive == 0) { if ((buf->s.frequency[j] >= handle->lowerBound) && (buf->s.frequency[j] <= handle->upperBound)) { int frequency_before_point = buf->s.frequency[j] / 1000; int frequency_behind_point = buf->s.frequency[j] - (frequency_before_point * 1000); @@ -332,12 +332,16 @@ int forwardMinuteBuffer(t_forwarderHandle *handle, t_minuteBuffer *buf) { } else { logmsg(LOG_ERR, "%u out of bound, ignored", buf->s.frequency[j]); } + } else { + logmsg(LOG_DEBUG, "Inactive device, not sent to InfluxDB"); } - } else { - logmsg(LOG_INFO, "Inactive device, not sent to InfluxDB"); } - logmsg(LOG_INFO, "Successfully sent whole minute to InfluxDB"); + if (device->inactive == 0) { + logmsg(LOG_INFO, "Successfully sent whole minute to InfluxDB"); + } else { + logmsg(LOG_INFO, "Not sent to database, device is marked as inactive"); + } return 0; }