stats in transmission
This commit is contained in:
@ -9,6 +9,9 @@
|
|||||||
typedef struct __attribute__((__packed__)) {
|
typedef struct __attribute__((__packed__)) {
|
||||||
char deviceId[sizeof(((t_configBlock*)0)->deviceId)];
|
char deviceId[sizeof(((t_configBlock*)0)->deviceId)];
|
||||||
uint8_t hash[SHA256_BLOCK_SIZE];
|
uint8_t hash[SHA256_BLOCK_SIZE];
|
||||||
|
uint32_t totalRunningHours;
|
||||||
|
uint32_t totalPowercycles;
|
||||||
|
uint32_t totalWatchdogResets;
|
||||||
uint64_t timestamp;
|
uint64_t timestamp;
|
||||||
uint32_t frequency[SECONDS_PER_MINUTE];
|
uint32_t frequency[SECONDS_PER_MINUTE];
|
||||||
} t_minuteStruct;
|
} t_minuteStruct;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <socket.h>
|
#include <socket.h>
|
||||||
#include <sinkStruct.h>
|
#include <sinkStruct.h>
|
||||||
#include <sha256.h>
|
#include <sha256.h>
|
||||||
|
#include <eeprom.h>
|
||||||
|
|
||||||
|
|
||||||
const uint32_t COUNTER_FREQUENCY = 1.0e6;
|
const uint32_t COUNTER_FREQUENCY = 1.0e6;
|
||||||
@ -25,6 +25,7 @@ volatile static uint32_t mainsCntSum = 0;
|
|||||||
volatile static uint32_t mainsCntCnt = 0;
|
volatile static uint32_t mainsCntCnt = 0;
|
||||||
|
|
||||||
static t_seconds *seconds;
|
static t_seconds *seconds;
|
||||||
|
static t_deviceStats *deviceStats;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -69,6 +70,11 @@ void counterMinuteTick(void *handle) {
|
|||||||
|
|
||||||
if (minuteBufferReady[minuteBufferIdx] == 1) {
|
if (minuteBufferReady[minuteBufferIdx] == 1) {
|
||||||
coloredMsg(LOG_BLUE, "cmt, buffer %d is done, handle it", minuteBufferIdx);
|
coloredMsg(LOG_BLUE, "cmt, buffer %d is done, handle it", minuteBufferIdx);
|
||||||
|
|
||||||
|
minuteBuffer->s.totalRunningHours = deviceStats->totalRunningHours;
|
||||||
|
minuteBuffer->s.totalPowercycles = deviceStats->totalPowercycles;
|
||||||
|
minuteBuffer->s.totalWatchdogResets = deviceStats->totalWatchdogResets;
|
||||||
|
|
||||||
memset(minuteBuffer->s.deviceId, 0, sizeof(minuteBuffer->s.deviceId));
|
memset(minuteBuffer->s.deviceId, 0, sizeof(minuteBuffer->s.deviceId));
|
||||||
strcpy(minuteBuffer->s.deviceId, config->deviceId);
|
strcpy(minuteBuffer->s.deviceId, config->deviceId);
|
||||||
|
|
||||||
@ -190,6 +196,8 @@ void mainsCntsInputCaptureCallback(TIM_HandleTypeDef *htim) {
|
|||||||
|
|
||||||
|
|
||||||
void counterInit() {
|
void counterInit() {
|
||||||
|
deviceStats = getGlobalDeviceStats();
|
||||||
|
|
||||||
seconds = wizGetSeconds();
|
seconds = wizGetSeconds();
|
||||||
for (uint8_t i = 0; i < NUM_OF_MINUTE_BUFFERS; i++) {
|
for (uint8_t i = 0; i < NUM_OF_MINUTE_BUFFERS; i++) {
|
||||||
minuteBufferReady[i] = false;
|
minuteBufferReady[i] = false;
|
||||||
|
@ -270,7 +270,9 @@ int httpPostRequest(char *url, const char *user, const char *pass, char *payload
|
|||||||
}
|
}
|
||||||
|
|
||||||
int forwardMinuteBuffer(t_forwarderHandle *handle, t_minuteBuffer *buf) {
|
int forwardMinuteBuffer(t_forwarderHandle *handle, t_minuteBuffer *buf) {
|
||||||
logmsg(LOG_INFO, "DeviceId: %s", buf->s.deviceId);
|
logmsg(LOG_INFO, "DeviceId: %s, RunningHours: %u, Powercycles: %u, WatchdogResets: %u",
|
||||||
|
buf->s.deviceId, buf->s.totalRunningHours, buf->s.totalPowercycles, buf->s.totalWatchdogResets);
|
||||||
|
|
||||||
t_device *device = findDevice(handle->configHandle, buf->s.deviceId);
|
t_device *device = findDevice(handle->configHandle, buf->s.deviceId);
|
||||||
const char *location = device->location;
|
const char *location = device->location;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user