Files
system-control/firmware/components/heimdall/src/action_manager.cpp
T
mars3142 32ea23906f dynamic menu
- also component renaming

Signed-off-by: Peter Siegmund <developer@mars3142.org>
2026-03-28 16:57:15 +01:00

36 lines
888 B
C++

#include "heimdall/action_manager.h"
#include <esp_log.h>
#include <string>
#include <unordered_map>
static const char *TAG = "ActionMgr";
static std::unordered_map<std::string, action_callback_t> s_actions;
extern "C" void action_manager_register(const char *action_name, action_callback_t callback)
{
if (action_name && callback)
{
s_actions[action_name] = callback;
ESP_LOGD(TAG, "Action registered: %s", action_name);
}
}
extern "C" void action_manager_execute(const char *action_name, const char *value)
{
if (!action_name)
return;
auto it = s_actions.find(action_name);
if (it != s_actions.end())
{
ESP_LOGI(TAG, "Executing action: %s (value: %s)", action_name, value ? value : "NULL");
it->second(value ? value : "");
}
else
{
ESP_LOGW(TAG, "Action not found: %s", action_name);
}
}