one command function, to save on heap

This commit is contained in:
proddy
2026-06-10 22:06:46 +02:00
parent 5357f633d3
commit 7664d50d69
11 changed files with 62 additions and 60 deletions

View File

@@ -197,7 +197,7 @@ StateUpdateResult WebCommands::update(JsonObject root, WebCommands & webCommands
Command::add(
EMSdevice::DeviceType::COMMAND,
webCommands.commandItems.back().name,
[name = std::string(webCommands.commandItems.back().name)](const char * value, const int8_t id) {
[name = std::string(webCommands.commandItems.back().name)](const char * value, const int8_t id, JsonObject output) {
return EMSESP::webCommandService.dispatchCommand(name.c_str(), value); // value is optional
},
FL_(command_cmd),
@@ -442,7 +442,7 @@ void WebCommandService::load_test_data() {
Command::add(
EMSdevice::DeviceType::COMMAND,
item.name,
[name = std::string(item.name)](const char * value, const int8_t id) {
[name = std::string(item.name)](const char * value, const int8_t id, JsonObject output) {
return EMSESP::webCommandService.dispatchCommand(name.c_str(), value);
},
FL_(command_cmd),

View File

@@ -34,7 +34,7 @@
#define EMSESP_COMMAND_RUNNING_CORE 1
#endif
#ifndef EMSESP_COMMAND_STACKSIZE
#define EMSESP_COMMAND_STACKSIZE 8192
#define EMSESP_COMMAND_STACKSIZE 8192 // needed for TLS
#endif
#ifndef EMSESP_COMMAND_PRIORITY
#define EMSESP_COMMAND_PRIORITY 1

View File

@@ -145,8 +145,8 @@ StateUpdateResult WebCustomEntity::update(JsonObject root, WebCustomEntity & web
Command::add(
EMSdevice::DeviceType::CUSTOM,
webCustomEntity.customEntityItems.back().name,
[webCustomEntity](const char * value, const int8_t id) {
return EMSESP::webCustomEntityService.command_setvalue(value, id, webCustomEntity.customEntityItems.back().name);
[name = std::string(webCustomEntity.customEntityItems.back().name)](const char * value, const int8_t id, JsonObject output) {
return EMSESP::webCustomEntityService.command_setvalue(value, id, name.c_str());
},
FL_(entity_cmd),
CommandFlag::ADMIN_ONLY);
@@ -796,8 +796,8 @@ void WebCustomEntityService::load_test_data() {
Command::add(
EMSdevice::DeviceType::CUSTOM,
webCustomEntity.customEntityItems.back().name,
[webCustomEntity](const char * value, const int8_t id) {
return EMSESP::webCustomEntityService.command_setvalue(value, id, webCustomEntity.customEntityItems.back().name);
[name = std::string(webCustomEntity.customEntityItems.back().name)](const char * value, const int8_t id, JsonObject output) {
return EMSESP::webCustomEntityService.command_setvalue(value, id, name.c_str());
},
FL_(entity_cmd),
CommandFlag::ADMIN_ONLY);
@@ -832,8 +832,8 @@ void WebCustomEntityService::load_test_data() {
Command::add(
EMSdevice::DeviceType::CUSTOM,
webCustomEntity.customEntityItems.back().name,
[webCustomEntity](const char * value, const int8_t id) {
return EMSESP::webCustomEntityService.command_setvalue(value, id, webCustomEntity.customEntityItems.back().name);
[name = std::string(webCustomEntity.customEntityItems.back().name)](const char * value, const int8_t id, JsonObject output) {
return EMSESP::webCustomEntityService.command_setvalue(value, id, name.c_str());
},
FL_(entity_cmd),
CommandFlag::ADMIN_ONLY);
@@ -855,8 +855,8 @@ void WebCustomEntityService::load_test_data() {
Command::add(
EMSdevice::DeviceType::CUSTOM,
webCustomEntity.customEntityItems.back().name,
[webCustomEntity](const char * value, const int8_t id) {
return EMSESP::webCustomEntityService.command_setvalue(value, id, webCustomEntity.customEntityItems.back().name);
[name = std::string(webCustomEntity.customEntityItems.back().name)](const char * value, const int8_t id, JsonObject output) {
return EMSESP::webCustomEntityService.command_setvalue(value, id, name.c_str());
},
FL_(entity_cmd),
CommandFlag::ADMIN_ONLY);

View File

@@ -98,7 +98,7 @@ StateUpdateResult WebScheduler::update(JsonObject root, WebScheduler & webSchedu
Command::add(
EMSdevice::DeviceType::SCHEDULER,
webScheduler.scheduleItems.back().name,
[name = std::string(webScheduler.scheduleItems.back().name)](const char * value, const int8_t id) {
[name = std::string(webScheduler.scheduleItems.back().name)](const char * value, const int8_t id, JsonObject output) {
return EMSESP::webSchedulerService.command_setvalue(value, id, name.c_str());
},
FL_(schedule_cmd),
@@ -466,7 +466,7 @@ void WebSchedulerService::load_test_data() {
Command::add(
EMSdevice::DeviceType::SCHEDULER,
item.name,
[name = std::string(item.name)](const char * value, const int8_t id) {
[name = std::string(item.name)](const char * value, const int8_t id, JsonObject output) {
return EMSESP::webSchedulerService.command_setvalue(value, id, name.c_str());
},
FL_(schedule_cmd),