read input and output commands
This commit is contained in:
@@ -8,7 +8,6 @@ namespace commands
|
||||
{
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::setBuzz(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
@@ -72,7 +71,6 @@ namespace commands
|
||||
response["values"]["status"] = "valid";
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::setCronJob(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
@@ -168,7 +166,6 @@ namespace commands
|
||||
response["values"]["status"] = "valid";
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::storeCronJob(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
@@ -216,7 +213,6 @@ namespace commands
|
||||
response["values"]["status"] = "valid";
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::setHeating(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
@@ -250,7 +246,6 @@ namespace commands
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
void resetZone(TimerHandle_t th)
|
||||
{
|
||||
devices_t *dev = (devices_t *)pvTimerGetTimerID(th);
|
||||
@@ -265,7 +260,6 @@ namespace commands
|
||||
c_irrigationTimerMap.at(timerName).second = NULL; // reset timer handle for this timer
|
||||
xTimerDelete(th, 0); // delete the timer on expiry
|
||||
}
|
||||
|
||||
void resetWaterPump(TimerHandle_t th)
|
||||
{
|
||||
devices_t *dev = (devices_t *)pvTimerGetTimerID(th);
|
||||
@@ -274,7 +268,6 @@ namespace commands
|
||||
s_irrigationPumpTimer = NULL;
|
||||
xTimerDelete(th, 0); // delete the timer on expiry
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::setIrrigation(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
@@ -372,7 +365,6 @@ namespace commands
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::setTimeNTP(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
@@ -415,56 +407,70 @@ namespace commands
|
||||
LOG_INFO("getHPpower -> power", pinfo.pAct, "current", pinfo.a, "voltage", pinfo.v, "energy", pinfo.whPar);
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::getInputStatus(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
LOG_WARN("Comand not yet implemented");
|
||||
response["cmd"] = "getInputStatus";
|
||||
const std::vector<bool> inStatus(dev.io.digitalInReadPort());
|
||||
if (inStatus.empty() || inStatus.size() != dev.io.getInNum()) {
|
||||
response["values"] = "invalid";
|
||||
return response;
|
||||
}
|
||||
uint8_t i(0);
|
||||
for (auto s: inStatus){
|
||||
const std::string k("DI"+std::to_string(i));
|
||||
response["values"][k.c_str()] = s;
|
||||
}
|
||||
LOG_INFO("getInputStatus ->", printBoolVec(inStatus).c_str());
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::getOutputStatus(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
LOG_WARN("Comand not yet implemented");
|
||||
response["cmd"] = "getOutputStatus";
|
||||
const std::vector<bool> inStatus(dev.io.digitalOutReadPort());
|
||||
if (inStatus.empty() || inStatus.size() != dev.io.getOutNum()) {
|
||||
response["values"] = "invalid";
|
||||
return response;
|
||||
}
|
||||
uint8_t i(0);
|
||||
for (auto s: inStatus){
|
||||
const std::string k("DO"+std::to_string(i));
|
||||
response["values"][k.c_str()] = s;
|
||||
}
|
||||
LOG_INFO("getOutputStatus ->", printBoolVec(inStatus).c_str());
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::getTemperatures(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
LOG_WARN("Comand not yet implemented");
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::getWaterInfo(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
LOG_WARN("Comand not yet implemented");
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::getTankInfo(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
LOG_WARN("Comand not yet implemented");
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::getRainInfo(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
LOG_WARN("Comand not yet implemented");
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::getIrrigation(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
LOG_WARN("Comand not yet implemented");
|
||||
return response;
|
||||
}
|
||||
|
||||
const ArduinoJson::JsonDocument Commands::getTimeDrift(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||
{
|
||||
ArduinoJson::JsonDocument response;
|
||||
|
||||
@@ -116,6 +116,9 @@ namespace commands
|
||||
{"getHPpower", Commands::getHPpower},
|
||||
{"setHeating", Commands::setHeating},
|
||||
|
||||
{"getInputStatus", Commands::getInputStatus},
|
||||
{"getOutputStatus", Commands::getOutputStatus},
|
||||
|
||||
{"getTimeDrift", Commands::getTimeDrift},
|
||||
{"setTimeNTP", Commands::setTimeNTP},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user