From d8e4a5b71da218293214acc9c9b6be2ccb095271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20L=2E=20=C5=A0ijanec?= Date: Thu, 16 Apr 2020 21:37:16 +0200 Subject: weather station + http time --- f015_apihandler.ino | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'f015_apihandler.ino') diff --git a/f015_apihandler.ino b/f015_apihandler.ino index eeb974d..add1088 100644 --- a/f015_apihandler.ino +++ b/f015_apihandler.ino @@ -27,6 +27,7 @@ void handleRename() { server.send(500, "text/html", fihr(500, "premikanje ni uspelo!")); } } + void handleTms() { // timeset if (!preveriprijavo()) return; if (!server.hasArg("s") || server.arg("s") == NULL) { @@ -123,13 +124,15 @@ void handleSetSTA() { void handleGetID() { if (!preveriprijavo()) return; if (!server.hasArg("k") || server.arg("k") == NULL) { - server.send(400, "text/html", fihr(400, "obvezni argument: k(aj s(ta MAC)/a(p MAC)/i(p)/c(hipId)/h(ostname)). prebere ID, za pisanje MACa glejte /api/sta in /api/ap")); + server.send(400, "text/html", fihr(400, "obvezni argument: k(aj s(ta MAC)/a(p MAC)/i(p)/c(hipId)/h(ostname/u(ra))). prebere ID, za pisanje MACa glejte /api/sta in /api/ap")); return; } if(server.arg("k").startsWith("s")) { server.send(200, "text/plain", String(WiFi.macAddress())); } else if (server.arg("k").startsWith("a")) { server.send(200, "text/plain", String(WiFi.softAPmacAddress())); + } else if (server.arg("k").startsWith("u")) { + server.send(200, "text/plain", String(now())); } else if (server.arg("k").startsWith("i")) { server.send(200, "text/plain", WiFi.localIP().toString()); } else if (server.arg("k").startsWith("c")) { @@ -197,6 +200,12 @@ void handleNewPassword() { } writefile("/403/webgeslo.txt", String(server.arg("g"))); } + +void handleForcedTimeUpdate() { + setTime(timeSyncProvider()); + server.send(200, "text/html", fihr(200, "ok")); +} + void handleFileUpload() { if (!preveriprijavo()) return; HTTPUpload& upload = server.upload(); @@ -219,11 +228,22 @@ void handleFileUpload() { } } } + +void handleFile() { + if (!preveriprijavo()) return; + if (!server.hasArg("i") || server.arg("i") == NULL || !server.hasArg("v")) { + server.send(400, "text/html", fihr(400, "obvezena argumenta: i(me), v(sebina)")); + return; + } + writefile(String(server.arg("i")), String(server.arg("v"))); + server.send(200, "text/html", fihr(200, "ok")); +} + bool handleFileRead(String path) { // send the right file to the client (if it exists) if (!preveriprijavo()) return false; // Serial.println("handleFileRead: " + path); // 2hc if (path.endsWith("/")) path += "index.html"; // If a folder is requested, send the index file - if(path.indexOf("/403/") >= 0) { + if(path.indexOf("/403/") >= 0 && DISALLOW_403) { server.send(403, "text/html", fihr(403, "prepovedano")); return true; } -- cgit v1.2.3