diff --git a/interface/src/project/EMSESPSettingsForm.tsx b/interface/src/project/EMSESPSettingsForm.tsx index 21b49eed8..48b38998e 100644 --- a/interface/src/project/EMSESPSettingsForm.tsx +++ b/interface/src/project/EMSESPSettingsForm.tsx @@ -422,7 +422,7 @@ class EMSESPSettingsForm extends Component { value="notoken_api" /> } - label="Bypass Access Token authorization on API calls" + label="Bypass Access Token authorization on API calls (warning! security vulnerability)" /> = TAG_HC1 && tag <= TAG_HC4) { - Command::add(device_type_, name[0], f, name[1], FLAG_HC); - } else if (tag >= TAG_WWC1 && tag <= TAG_WWC4) { - Command::add(device_type_, name[0], f, name[1], FLAG_WWC); - } else { - Command::add(device_type_, name[0], f, name[1], 0); - } + + // add a new command if it has a function attached + if (f == nullptr) { + return; + } + + if (tag >= TAG_HC1 && tag <= TAG_HC4) { + Command::add(device_type_, name[0], f, name[1], CommandFlag::MQTT_SUB_FLAG_HC | CommandFlag::ADMIN_ONLY); + } else if (tag >= TAG_WWC1 && tag <= TAG_WWC4) { + Command::add(device_type_, name[0], f, name[1], CommandFlag::MQTT_SUB_FLAG_WWC | CommandFlag::ADMIN_ONLY); + } else { + Command::add(device_type_, name[0], f, name[1], CommandFlag::MQTT_SUB_FLAG_NORMAL | CommandFlag::ADMIN_ONLY); } } diff --git a/src/emsesp.cpp b/src/emsesp.cpp index ebc25c244..b856d1d8e 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -982,18 +982,18 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std:: return true; } - Command::add_with_json( + Command::add_returns_json( device_type, F_(info), [device_type](const char * value, const int8_t id, JsonObject & json) { return command_info(device_type, json, id, true); }, F_(info_cmd)); - Command::add_with_json( + Command::add_returns_json( device_type, F("info_short"), [device_type](const char * value, const int8_t id, JsonObject & json) { return command_info(device_type, json, id, false); }, nullptr, - true); // this command is hidden - Command::add_with_json( + CommandFlag::HIDDEN); // this command is hidden + Command::add_returns_json( device_type, F_(commands), [device_type](const char * value, const int8_t id, JsonObject & json) { return command_commands(device_type, json, id); }, diff --git a/src/emsesp.h b/src/emsesp.h index aefa08f5b..791652a8f 100644 --- a/src/emsesp.h +++ b/src/emsesp.h @@ -65,8 +65,8 @@ #define EMSESP_JSON_SIZE_XXLARGE_DYN 8192 // for extra very very large json docs, using DynamicJsonDocument // helpers for callback functions -#define MAKE_PF_CB(__f) [&](std::shared_ptr t) { __f(t); } // for process function callbacks to register_telegram_type() -#define MAKE_CF_CB(__f) [&](const char * value, const int8_t id) { return __f(value, id); } // for command function callbacks to register_mqtt_cmd() +#define MAKE_PF_CB(__f) [&](std::shared_ptr t) { __f(t); } // for Process Function callbacks to EMSDevice::process_function_p +#define MAKE_CF_CB(__f) [&](const char * value, const int8_t id) { return __f(value, id); } // for Command Function callbacks Command::cmdfunction_p namespace emsesp {