oprava api

master
David Zálešák 4 years ago
parent df7e413021
commit 4654bdaf5d

@ -84,24 +84,24 @@ void setup() {
server.on("/set", HTTP_GET, [](AsyncWebServerRequest *request){
//nutno nastavit maxima a minima
if(THERMOSTAT){
if (request->hasParam("increaseReqTemp")) {
reqTemp += request->getParam("increaseReqTemp")->value().toFloat();
if (request->hasParam("increasereqtemp")) {
reqTemp += request->getParam("increasereqtemp")->value().toFloat();
request->send(200, "text/plain; charset=utf-8", String(reqTemp));
}else if (request->hasParam("decreaseReqTemp")) {
reqTemp -= request->getParam("decreaseReqTemp")->value().toFloat();
}else if (request->hasParam("decreasereqtemp")) {
reqTemp -= request->getParam("decreasereqtemp")->value().toFloat();
request->send(200, "text/plain; charset=utf-8", String(reqTemp));
}else if (request->hasParam("increaseOffset")) {
offset += request->getParam("increaseOffset")->value().toFloat();
}else if (request->hasParam("increaseoffset")) {
offset += request->getParam("increaseoffset")->value().toFloat();
request->send(200, "text/plain; charset=utf-8", String(offset));
}else if (request->hasParam("decreaseOffset")) {
offset -= request->getParam("decreaseOffset")->value().toFloat();
}else if (request->hasParam("decreaseoffset")) {
offset -= request->getParam("decreaseoffset")->value().toFloat();
request->send(200, "text/plain; charset=utf-8", String(offset));
}else{
request->send(200, "text/plain; charset=utf-8", "no known parameter");
}
}else{
if (request->hasParam("relay")) {
boolean state = request->getParam("set")->value() == "1";
boolean state = request->getParam("relay")->value() == "1";
digitalWrite(RELAY_PIN, state);
request->send(200, "text/plain; charset=utf-8", "success");
}else{