fix console commands

This commit is contained in:
proddy
2021-06-08 18:21:53 +02:00
parent 8dd18aa24d
commit a84ae9e7cc

View File

@@ -88,9 +88,9 @@ bool Command::call(const uint8_t device_type, const char * cmd, const char * val
if (cf->cmdfunction_json_) { if (cf->cmdfunction_json_) {
return ((cf->cmdfunction_json_)(value, id_new, json)); return ((cf->cmdfunction_json_)(value, id_new, json));
} else { } else {
if (value == nullptr || strlen(value) == 0 || strcmp(value, "?") == 0 || strcmp(value, "*") == 0) { // if (value == nullptr || strlen(value) == 0 || strcmp(value, "?") == 0 || strcmp(value, "*") == 0) {
return EMSESP::get_device_value_info(json, cmd_new, id_new, device_type); // return EMSESP::get_device_value_info(json, cmd_new, id_new, device_type);
} // }
return ((cf->cmdfunction_)(value, id_new)); return ((cf->cmdfunction_)(value, id_new));
} }
} }
@@ -101,9 +101,8 @@ Command::CmdFunction * Command::find_command(const uint8_t device_type, char * c
if (id == 0) { if (id == 0) {
return nullptr; return nullptr;
} }
// empty command is info with id0 or info_short // empty command is info with id0
if (cmd[0] == '\0') { if (cmd[0] == '\0') {
// strcpy(cmd, "info_short");
strcpy(cmd, "info"); strcpy(cmd, "info");
id = 0; id = 0;
} }
@@ -222,14 +221,10 @@ bool Command::list(const uint8_t device_type, JsonObject & json) {
for (auto & cl : sorted_cmds) { for (auto & cl : sorted_cmds) {
for (const auto & cf : cmdfunctions_) { for (const auto & cf : cmdfunctions_) {
if ((cf.device_type_ == device_type) && !cf.hidden_ && cf.description_ && (cl == uuid::read_flash_string(cf.cmd_))) { if ((cf.device_type_ == device_type) && !cf.hidden_ && cf.description_ && (cl == uuid::read_flash_string(cf.cmd_))) {
if (cf.flag_ == FLAG_WW) {
json[cl] = EMSdevice::tag_to_string(TAG_DEVICE_DATA_WW) + " " + uuid::read_flash_string(cf.description_);
} else {
json[cl] = cf.description_; json[cl] = cf.description_;
} }
} }
} }
}
return true; return true;
} }
@@ -281,10 +276,6 @@ void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbo
shell.print(' '); shell.print(' ');
} }
shell.print(COLOR_BRIGHT_CYAN); shell.print(COLOR_BRIGHT_CYAN);
if (cf.flag_ == FLAG_WW) {
shell.print(EMSdevice::tag_to_string(TAG_DEVICE_DATA_WW));
shell.print(' ');
}
shell.print(uuid::read_flash_string(cf.description_)); shell.print(uuid::read_flash_string(cf.description_));
shell.print(COLOR_RESET); shell.print(COLOR_RESET);
} }