|
|
|
@ -56,7 +56,7 @@ void setup() {
|
|
|
|
|
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
|
|
|
|
|
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
|
|
|
|
|
ArduinoOTA.begin();
|
|
|
|
|
|
|
|
|
|
SPIFFS.begin();
|
|
|
|
|
//========== Pin setup ==========
|
|
|
|
|
|
|
|
|
|
pinMode(RELAY_PIN, OUTPUT);
|
|
|
|
@ -103,7 +103,7 @@ void setup() {
|
|
|
|
|
offset -= request->getParam("decreaseoffset")->value().toFloat();
|
|
|
|
|
repply = String(offset);
|
|
|
|
|
}else{
|
|
|
|
|
repply = "no known parameter";
|
|
|
|
|
repply = "unknown parameter";
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if (request->hasParam("relay")) {
|
|
|
|
@ -111,14 +111,11 @@ void setup() {
|
|
|
|
|
digitalWrite(RELAY_PIN, state);
|
|
|
|
|
repply = "success";
|
|
|
|
|
}else{
|
|
|
|
|
repply = "no known parameter";
|
|
|
|
|
repply = "unknown 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);
|
|
|
|
|
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
|
|
|
|
@ -133,18 +130,14 @@ void setup() {
|
|
|
|
|
}else if(THERMOSTAT && request->hasParam("offset")) {
|
|
|
|
|
repply = offset;
|
|
|
|
|
}else{
|
|
|
|
|
repply = "no known parameter";
|
|
|
|
|
repply = "unknown 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("/", HTTP_GET, [](AsyncWebServerRequest *request){
|
|
|
|
|
request->send(200, "text/plain; charset=utf-8", "ESP termostat, tady se bude posílat aplikace z flash paměti");
|
|
|
|
|
request->send(200, "text/plain; charset=utf-8", repply);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.html");
|
|
|
|
|
|
|
|
|
|
server.onNotFound(notFound);
|
|
|
|
|
server.begin();
|
|
|
|
|
|
|
|
|
|