show statistics on second screen

This commit is contained in:
2020-11-20 12:20:30 +01:00
parent 3807e2fa9f
commit 206e371d48
8 changed files with 72 additions and 54 deletions

View File

@ -7,6 +7,7 @@
#include <PontCoopScheduler.h>
#include <wizHelper.h>
#include <mbusComm.h>
#include <oled.h>
#include <stdint.h>
#include <stdlib.h>
@ -53,11 +54,20 @@ static void mqttStatusPublisher(void *handle) {
coloredMsg(LOG_GREEN, false, "mqsp: publishing status");
t_mbusCommStats *mbusCommStats = mbusCommGetStats();
char buf[64];
uint32_t uptime = HAL_GetTick() / 1000;
snprintf(buf, 128, "{\"uptime\":\"%ld\", \"tasks\":\"%d\", \"requests\":\"%ld\", \"errors\":\"%ld\"}",
HAL_GetTick()/1000, schTaskCnt(), mbusCommStats->requestCnt, mbusCommStats->errorCnt);
uptime, 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);
oledClear();
oledSetActiveScreen(OLED_SCREEN1);
uint8_t *addr = wizGetIPAddress();
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, "Req:%ld", mbusCommStats->requestCnt);
oledPrintf(OLED_SCREEN1, "Err:%ld", mbusCommStats->errorCnt);
}
void mqttCommHandler(void *handle) {