watchdog
This commit is contained in:
@ -1,26 +0,0 @@
|
||||
#include <cmdHelper.h>
|
||||
#include <logger.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
// clear statistics
|
||||
static bool clearCmd(uint8_t argc, char **args) {
|
||||
coloredMsg(LOG_YELLOW, "ch cc global statistics cleared");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const cmd_t ADMIN_COMMANDS[] = {
|
||||
{ .name = "clear", .cmdFunc = clearCmd,
|
||||
.help = \
|
||||
"clear ................................ Clears the global statistics\n\r"
|
||||
},
|
||||
{ .name = "END_OF_CMDS", .help = "",.cmdFunc = NULL }
|
||||
};
|
||||
|
||||
|
||||
|
||||
const cmd_t *getAdminCommands() {
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
@ -59,9 +59,7 @@ static int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetSpecialModes) {
|
||||
"\n\r" \
|
||||
"help ................................. Show this help page\n\r" \
|
||||
"quit ................................. Terminate the console session\n\r" \
|
||||
"enable ............................... Enable admin mode\n\r" \
|
||||
"config ............................... Enter configuration mode\n\r" \
|
||||
"disable .............................. Disable admin/config mode\n\r" \
|
||||
;
|
||||
const static char CONFIG_INTRO_MSG[] = \
|
||||
"In configuration mode each command changing the configuration\n\r" \
|
||||
@ -76,18 +74,14 @@ static int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetSpecialModes) {
|
||||
const static char UNKNOWN_COMMAND[] = "Unknown command\n\r";
|
||||
uint8_t *messageToSend = NULL;
|
||||
|
||||
static bool adminMode = false;
|
||||
static bool configMode = false;
|
||||
|
||||
if (resetSpecialModes) {
|
||||
adminMode = false;
|
||||
configMode = false;
|
||||
}
|
||||
|
||||
cmd_t const * commands = getRegularCommands();
|
||||
if (adminMode) {
|
||||
commands = getAdminCommands();
|
||||
} else if (configMode) {
|
||||
if (configMode) {
|
||||
commands = getConfigCommands();
|
||||
}
|
||||
|
||||
@ -127,15 +121,6 @@ static int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetSpecialModes) {
|
||||
cmdIdx++;
|
||||
}
|
||||
messageToSend = NULL;
|
||||
} else if (0 == strcmp(cmd, "enable")) {
|
||||
coloredMsg(LOG_YELLOW, "ch cec enable admin mode");
|
||||
adminMode = true;
|
||||
retCode = 1;
|
||||
} else if (0 == strcmp(cmd, "disable")) {
|
||||
coloredMsg(LOG_YELLOW, "ch cec disable admin mode");
|
||||
adminMode = false;
|
||||
configMode = false;
|
||||
retCode = 3;
|
||||
} else if (0 == strcmp(cmd, "config")) {
|
||||
coloredMsg(LOG_YELLOW, "ch cec enable config mode");
|
||||
configMode = true;
|
||||
@ -177,7 +162,6 @@ static void cmdHandlerEngine(void *handle) {
|
||||
|
||||
static char *prompt;
|
||||
static char defaultPrompt[] = " > ";
|
||||
static char adminPrompt[] = " (admin) # ";
|
||||
static char configPrompt[] = " (config) $ ";
|
||||
|
||||
|
||||
@ -291,10 +275,6 @@ static void cmdHandlerEngine(void *handle) {
|
||||
case -1:
|
||||
state = CH_DISCONNECT;
|
||||
break;
|
||||
case 1:
|
||||
prompt = adminPrompt;
|
||||
state = CH_PROMPT;
|
||||
break;
|
||||
case 2:
|
||||
prompt = configPrompt;
|
||||
state = CH_PROMPT;
|
||||
@ -303,6 +283,9 @@ static void cmdHandlerEngine(void *handle) {
|
||||
prompt = defaultPrompt;
|
||||
state = CH_PROMPT;
|
||||
break;
|
||||
default:
|
||||
state = CH_DISCONNECT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <dns.h>
|
||||
#include <sntp.h>
|
||||
#include <config.h>
|
||||
|
||||
#include <iwdg.h>
|
||||
|
||||
|
||||
static t_configBlock *config;
|
||||
@ -185,6 +185,7 @@ static void wizSNTPHandler(void *handle) {
|
||||
|
||||
static void wizSecondsHandler(void *handle) {
|
||||
seconds.seconds += 1;
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user