|
|
@ -56,7 +56,7 @@ void setup() {
|
|
|
|
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
|
|
|
|
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
|
|
|
|
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
|
|
|
|
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
|
|
|
|
ArduinoOTA.begin();
|
|
|
|
ArduinoOTA.begin();
|
|
|
|
|
|
|
|
SPIFFS.begin();
|
|
|
|
//========== Pin setup ==========
|
|
|
|
//========== Pin setup ==========
|
|
|
|
|
|
|
|
|
|
|
|
pinMode(RELAY_PIN, OUTPUT);
|
|
|
|
pinMode(RELAY_PIN, OUTPUT);
|
|
|
@ -103,7 +103,7 @@ void setup() {
|
|
|
|
offset -= request->getParam("decreaseoffset")->value().toFloat();
|
|
|
|
offset -= request->getParam("decreaseoffset")->value().toFloat();
|
|
|
|
repply = String(offset);
|
|
|
|
repply = String(offset);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
repply = "no known parameter";
|
|
|
|
repply = "unknown parameter";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
if (request->hasParam("relay")) {
|
|
|
|
if (request->hasParam("relay")) {
|
|
|
@ -111,14 +111,11 @@ void setup() {
|
|
|
|
digitalWrite(RELAY_PIN, state);
|
|
|
|
digitalWrite(RELAY_PIN, state);
|
|
|
|
repply = "success";
|
|
|
|
repply = "success";
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
repply = "no known parameter";
|
|
|
|
repply = "unknown parameter";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AsyncWebServerResponse *response = request->beginResponse(200, "text/plain; charset=utf-8", repply);
|
|
|
|
request->send(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){
|
|
|
|
server.on("/get", HTTP_GET, [](AsyncWebServerRequest *request){
|
|
|
|
//nutno vyřešit dotazy na více parametrů najednou
|
|
|
|
//nutno vyřešit dotazy na více parametrů najednou
|
|
|
@ -133,18 +130,14 @@ void setup() {
|
|
|
|
}else if(THERMOSTAT && request->hasParam("offset")) {
|
|
|
|
}else if(THERMOSTAT && request->hasParam("offset")) {
|
|
|
|
repply = offset;
|
|
|
|
repply = offset;
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
repply = "no known parameter";
|
|
|
|
repply = "unknown parameter";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AsyncWebServerResponse *response = request->beginResponse(200, "text/plain; charset=utf-8", repply);
|
|
|
|
request->send(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");
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.html");
|
|
|
|
|
|
|
|
|
|
|
|
server.onNotFound(notFound);
|
|
|
|
server.onNotFound(notFound);
|
|
|
|
server.begin();
|
|
|
|
server.begin();
|
|
|
|
|
|
|
|
|
|
|
|