Application develop start

This commit is contained in:
Emanuele Trabattoni
2025-07-24 22:46:31 +02:00
parent bea42c9a36
commit bb0832ad4f
12 changed files with 237 additions and 123 deletions

49
src/commands.cpp Normal file
View File

@@ -0,0 +1,49 @@
#include <commands.h>
namespace commands
{
const ArduinoJson::JsonDocument Commands::setHPlimit(const devices_t &dev, const ArduinoJson::JsonDocument &params)
{
ArduinoJson::JsonDocument response;
if (!params["level"].is<std::string>())
{
LOG_ERROR("setHPlimit incorrect parameters");
return response;
}
const auto level = params["level"].as<std::string>();
if (!c_hpLimitsMap.contains(level))
{
LOG_ERROR("setHPlimit invalid level", level.c_str());
return response;
}
for (auto k : c_hpLimitsMap)
{
if (level == k.first && level != "UNLIMITED")
dev.io.digitalOutWrite(k.second, true);
else
dev.io.digitalOutWrite(k.second, false);
}
LOG_INFO("setHPlimit -> level", level.c_str());
return response;
}
const ArduinoJson::JsonDocument Commands::getHPpower(const devices_t &dev, const ArduinoJson::JsonDocument &params)
{
ArduinoJson::JsonDocument response;
const auto pinfo = dev.seneca.getAll();
response["cmd"] = "getHPpower";
auto values = response["params"].to<JsonObject>();
values["power"] = pinfo.pAct;
values["current"] = pinfo.a;
values["energy"] = pinfo.whPar;
LOG_INFO("getHPpower -> power", pinfo.pAct, "current", pinfo.a, "energy", pinfo.whPar);
return response;
}
const ArduinoJson::JsonDocument Commands::setHeating(const devices_t &dev, const ArduinoJson::JsonDocument &params)
{
ArduinoJson::JsonDocument response;
LOG_WARN("setHeating not yet implemented");
return response;
}
}