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

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(); 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(); xhttp.send();
} }
get("temp", "temp"); get("temp", "temp");