more stats output

This commit is contained in:
2020-11-20 12:32:00 +01:00
parent 206e371d48
commit b1fdc04366
3 changed files with 26 additions and 11 deletions

View File

@ -8,6 +8,7 @@
#include <wizHelper.h>
#include <mbusComm.h>
#include <oled.h>
#include <eeprom.h>
#include <stdint.h>
#include <stdlib.h>
@ -53,10 +54,12 @@ static void mqttCallback(char *topic, uint8_t *payload, uint16_t payloadLength)
static void mqttStatusPublisher(void *handle) {
coloredMsg(LOG_GREEN, false, "mqsp: publishing status");
t_mbusCommStats *mbusCommStats = mbusCommGetStats();
t_deviceStats* globalDeviceStats = getGlobalDeviceStats();
char buf[64];
uint32_t uptime = HAL_GetTick() / 1000;
snprintf(buf, 128, "{\"uptime\":\"%ld\", \"tasks\":\"%d\", \"requests\":\"%ld\", \"errors\":\"%ld\"}",
uptime, schTaskCnt(), mbusCommStats->requestCnt, mbusCommStats->errorCnt);
snprintf(buf, 128, "{\"uptime\":\"%ld\", \"runningHours\":\"%ld\", \"powerCycles\":\"%ld\", \"tasks\":\"%d\", \"requests\":\"%ld\", \"errors\":\"%ld\"}",
uptime, globalDeviceStats->totalRunningHours, globalDeviceStats->totalPowercycles, schTaskCnt(), mbusCommStats->requestCnt, mbusCommStats->errorCnt);
bool res = publish(&mqttClient, StatusTopic, (const uint8_t*)buf, strlen(buf), false);
coloredMsg(LOG_GREEN, false, "mqch, publish returned %d", res);
@ -66,8 +69,11 @@ static void mqttStatusPublisher(void *handle) {
oledPrintf(OLED_SCREEN1, "Addr:%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
oledPrintf(OLED_SCREEN1, "Network available:%d", isNetworkAvailable());
oledPrintf(OLED_SCREEN1, "Uptime:%ld", uptime);
oledPrintf(OLED_SCREEN1, "RunHours:%d", globalDeviceStats->totalRunningHours);
oledPrintf(OLED_SCREEN1, "PowerCycl:%d", globalDeviceStats->totalPowercycles);
oledPrintf(OLED_SCREEN1, "Req:%ld", mbusCommStats->requestCnt);
oledPrintf(OLED_SCREEN1, "Err:%ld", mbusCommStats->errorCnt);
}
void mqttCommHandler(void *handle) {