device configuration prepared
This commit is contained in:
parent
24f2d0a01d
commit
0ed710e652
@ -43,7 +43,7 @@ typedef struct {
|
||||
} cmd_t;
|
||||
|
||||
|
||||
static void sendString(char *buf) {
|
||||
static void sendString(const char *buf) {
|
||||
send(CMD_SOCK, (uint8_t*)buf, strlen(buf));
|
||||
}
|
||||
|
||||
@ -163,6 +163,13 @@ static bool showConfigCmd(uint8_t argc, char **args) {
|
||||
return retCode;
|
||||
}
|
||||
|
||||
static bool restartCmd(uint8_t argc, char **args) {
|
||||
HAL_NVIC_SystemReset();
|
||||
// you want come here ...
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const static cmd_t COMMANDS[] = {
|
||||
{ .name = "globalStats", .cmdFunc = globalStatsCmd,
|
||||
.help = \
|
||||
@ -199,6 +206,11 @@ const static cmd_t CONFIG_COMMANDS[] = {
|
||||
.help = \
|
||||
"show ................................. Show the configuration\n\r"
|
||||
},
|
||||
{ .name = "restart", .cmdFunc = restartCmd,
|
||||
.help = \
|
||||
"restart .............................. Restart the system,\n\r" \
|
||||
" Required to reload config\n\r"
|
||||
},
|
||||
{ .name = "END_OF_CMDS", .help = "",.cmdFunc = NULL }
|
||||
};
|
||||
|
||||
@ -218,6 +230,13 @@ static int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetSpecialModes) {
|
||||
"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" \
|
||||
"will save changes directly to the EEPROM.\n\r" \
|
||||
"However, the system will only consider these changes after a\n\r" \
|
||||
"restart since only in this sitution the EEPROM is read.\n\r" \
|
||||
"\n\r" \
|
||||
;
|
||||
const static char GOODBYE_MSG[] = "Good bye\n\r";
|
||||
const static char OK_MSG[] = "OK\n\r";
|
||||
const static char FAILED_MSG[] = "Failed\n\r";
|
||||
@ -260,14 +279,17 @@ static int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetSpecialModes) {
|
||||
messageToSend = (uint8_t*)GOODBYE_MSG;
|
||||
retCode = -1;
|
||||
} else if (0 == strcmp(cmd, "help")) {
|
||||
send(CMD_SOCK, (uint8_t*)HELP_MSG, strlen(HELP_MSG));
|
||||
if (configMode) {
|
||||
sendString(CONFIG_INTRO_MSG);
|
||||
}
|
||||
sendString(HELP_MSG);
|
||||
uint8_t cmdIdx = 0;
|
||||
while (true) {
|
||||
cmd_t command = commands[cmdIdx];
|
||||
if (0 == strcmp("END_OF_CMDS", command.name)) {
|
||||
break;
|
||||
}
|
||||
send(CMD_SOCK, (uint8_t*)command.help, strlen(command.help));
|
||||
sendString(command.help);
|
||||
cmdIdx++;
|
||||
}
|
||||
messageToSend = NULL;
|
||||
@ -278,6 +300,7 @@ static int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetSpecialModes) {
|
||||
} else if (0 == strcmp(cmd, "disable")) {
|
||||
coloredMsg(LOG_YELLOW, true, "ch cec disable admin mode");
|
||||
adminMode = false;
|
||||
configMode = false;
|
||||
retCode = 3;
|
||||
} else if (0 == strcmp(cmd, "config")) {
|
||||
coloredMsg(LOG_YELLOW, true, "ch cec enable config mode");
|
||||
|
Loading…
x
Reference in New Issue
Block a user