move js app to SPIFFS

master
David Zálešák 4 years ago
parent 72a0df2444
commit 2180f3ae01

@ -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();

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -27,7 +27,7 @@ function set(co, jak) {
}
}
};
xhttp.open("GET", "http://10.22.128.209/set?" + co + "=" + jak, true);
xhttp.open("GET", "/set?" + co + "=" + jak, true);
xhttp.send();
}
@ -48,7 +48,7 @@ function get(x, y) {
}
}
};
xhttp.open("GET", "http://10.22.128.209/get?" + x, true);
xhttp.open("GET", "/get?" + x, true);
xhttp.send();
}
get("temp", "temp");