added js code
This commit is contained in:
@@ -83,31 +83,39 @@ void setup() {
|
||||
}
|
||||
server.on("/set", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
//nutno nastavit maxima a minima
|
||||
|
||||
String repply;
|
||||
|
||||
if(THERMOSTAT){
|
||||
if (request->hasParam("increasereqtemp")) {
|
||||
reqTemp += request->getParam("increasereqtemp")->value().toFloat();
|
||||
request->send(200, "text/plain; charset=utf-8", String(reqTemp));
|
||||
repply = String(reqTemp);
|
||||
}else if (request->hasParam("decreasereqtemp")) {
|
||||
reqTemp -= request->getParam("decreasereqtemp")->value().toFloat();
|
||||
request->send(200, "text/plain; charset=utf-8", String(reqTemp));
|
||||
repply = String(reqTemp);
|
||||
}else if (request->hasParam("increaseoffset")) {
|
||||
offset += request->getParam("increaseoffset")->value().toFloat();
|
||||
request->send(200, "text/plain; charset=utf-8", String(offset));
|
||||
repply = String(offset);
|
||||
}else if (request->hasParam("decreaseoffset")) {
|
||||
offset -= request->getParam("decreaseoffset")->value().toFloat();
|
||||
request->send(200, "text/plain; charset=utf-8", String(offset));
|
||||
repply = String(offset);
|
||||
}else{
|
||||
request->send(200, "text/plain; charset=utf-8", "no known parameter");
|
||||
repply = "no known parameter";
|
||||
}
|
||||
}else{
|
||||
if (request->hasParam("relay")) {
|
||||
boolean state = request->getParam("relay")->value() == "1";
|
||||
digitalWrite(RELAY_PIN, state);
|
||||
request->send(200, "text/plain; charset=utf-8", "success");
|
||||
repply = "success";
|
||||
}else{
|
||||
request->send(200, "text/plain; charset=utf-8", "no known parameter");
|
||||
repply = "no known parameter";
|
||||
}
|
||||
}
|
||||
|
||||
AsyncWebServerResponse *response = request->beginResponse(200, "text/plain; charset=utf-8", repply);
|
||||
response->addHeader("Access-Control-Allow-Origin", "*");
|
||||
request->send(response);
|
||||
//request->send(200, "text/plain; charset=utf-8", repply);
|
||||
});
|
||||
server.on("/get", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
//nutno vyřešit dotazy na více parametrů najednou
|
||||
@@ -124,8 +132,11 @@ void setup() {
|
||||
}else{
|
||||
repply = "no known parameter";
|
||||
}
|
||||
|
||||
request->send(200, "text/plain; charset=utf-8", repply);
|
||||
|
||||
AsyncWebServerResponse *response = request->beginResponse(200, "text/plain; charset=utf-8", repply);
|
||||
response->addHeader("Access-Control-Allow-Origin", "*");
|
||||
request->send(response);
|
||||
//request->send(200, "text/plain; charset=utf-8", repply);
|
||||
});
|
||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
request->send(200, "text/plain; charset=utf-8", "ESP termostat, tady se bude posílat aplikace z flash paměti");
|
||||
|
||||
Reference in New Issue
Block a user