2021-01-09 22:01:21 +01:00
|
|
|
#include <cmdHelper.h>
|
|
|
|
#include <logger.h>
|
2021-02-12 23:28:13 +01:00
|
|
|
#include <PontCoopScheduler.h>
|
2021-01-09 22:01:21 +01:00
|
|
|
|
|
|
|
#include <eeprom.h>
|
|
|
|
|
|
|
|
|
|
|
|
static bool globalStatsCmd(uint8_t argc, char **args) {
|
|
|
|
uint32_t uptime = HAL_GetTick() / 1000;
|
|
|
|
sendFormatString(\
|
|
|
|
"Current uptime: %ld\n\r" \
|
|
|
|
"\n\r",
|
|
|
|
uptime
|
|
|
|
);
|
|
|
|
|
|
|
|
t_deviceStats *deviceStats = getGlobalDeviceStats();
|
|
|
|
sendFormatString(\
|
|
|
|
"Global Device statistics\n\r" \
|
2021-02-12 19:10:11 +01:00
|
|
|
" Total running hours: %ld\n\r" \
|
|
|
|
" Total power cycles: %ld\n\r" \
|
|
|
|
" Total watchdog resets: %ld\n\r" \
|
2021-01-09 22:01:21 +01:00
|
|
|
"\n\r",
|
|
|
|
deviceStats->totalRunningHours, deviceStats->totalPowercycles,
|
2021-02-12 19:10:11 +01:00
|
|
|
deviceStats->totalWatchdogResets
|
2021-01-09 22:01:21 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-02-12 23:20:40 +01:00
|
|
|
static bool resetStatsCmd(uint8_t argc, char **args) {
|
|
|
|
t_deviceStats *deviceStats = getGlobalDeviceStats();
|
|
|
|
deviceStats->totalWatchdogResets = 0;
|
2021-02-12 23:28:13 +01:00
|
|
|
schAdd(eepromHourlyUpdateDeviceStats, NULL, 1, 0);
|
2021-02-12 23:20:40 +01:00
|
|
|
return true;
|
|
|
|
}
|
2021-01-09 22:01:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
const cmd_t COMMANDS[] = {
|
2021-02-12 19:10:59 +01:00
|
|
|
{ .name = "stats", .cmdFunc = globalStatsCmd,
|
2021-01-09 22:01:21 +01:00
|
|
|
.help = \
|
2021-02-12 19:10:59 +01:00
|
|
|
"stats .......................... Show the device statistics\n\r"
|
2021-01-09 22:01:21 +01:00
|
|
|
},
|
2021-02-12 23:20:40 +01:00
|
|
|
{ .name = "resetStats", .cmdFunc = resetStatsCmd,
|
|
|
|
.help = \
|
|
|
|
"resetStats ..................... Reset the device statistics\n\r"
|
|
|
|
},
|
2021-01-09 22:01:21 +01:00
|
|
|
{ .name = "END_OF_CMDS", .help = "",.cmdFunc = NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
const cmd_t *getRegularCommands() {
|
|
|
|
return COMMANDS;
|
|
|
|
}
|