fix call commands from console

This commit is contained in:
MichaelDvP
2020-11-24 14:37:19 +01:00
committed by GitHub
parent fc475c50df
commit ec06442b85

View File

@@ -65,7 +65,7 @@ bool Command::call(const uint8_t device_type, const char * cmd, const char * val
#endif #endif
auto cf = find_command(device_type, cmd); auto cf = find_command(device_type, cmd);
if ((cf == nullptr) || (!cf->cmdfunction_json_)) { if (cf == nullptr) {
return false; // command not found or not json return false; // command not found or not json
} }
@@ -75,8 +75,12 @@ bool Command::call(const uint8_t device_type, const char * cmd, const char * val
return false; return false;
} }
if (!cf->cmdfunction_json_) {
return ((cf->cmdfunction_)(value, id));
} else {
return ((cf->cmdfunction_json_)(value, id, json)); return ((cf->cmdfunction_json_)(value, id, json));
} }
}
// add a command to the list, which does not return json // add a command to the list, which does not return json
void Command::add(const uint8_t device_type, const uint8_t device_id, const __FlashStringHelper * cmd, cmdfunction_p cb) { void Command::add(const uint8_t device_type, const uint8_t device_id, const __FlashStringHelper * cmd, cmdfunction_p cb) {