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