diff options
author | Anton Šijanec <sijanecantonluka@gmail.com> | 2020-01-12 18:08:39 +0100 |
---|---|---|
committer | Anton Šijanec <sijanecantonluka@gmail.com> | 2020-01-12 18:08:39 +0100 |
commit | 6070b2e84adbe47ed8ff3da96d66e46160a3c51f (patch) | |
tree | 9b753099a0d1fc2cbc7c26e733e7fb0441cb1271 /f015_apihandler.ino | |
parent | vse ostalo (diff) | |
download | sijaneciot-6070b2e84adbe47ed8ff3da96d66e46160a3c51f.tar sijaneciot-6070b2e84adbe47ed8ff3da96d66e46160a3c51f.tar.gz sijaneciot-6070b2e84adbe47ed8ff3da96d66e46160a3c51f.tar.bz2 sijaneciot-6070b2e84adbe47ed8ff3da96d66e46160a3c51f.tar.lz sijaneciot-6070b2e84adbe47ed8ff3da96d66e46160a3c51f.tar.xz sijaneciot-6070b2e84adbe47ed8ff3da96d66e46160a3c51f.tar.zst sijaneciot-6070b2e84adbe47ed8ff3da96d66e46160a3c51f.zip |
Diffstat (limited to 'f015_apihandler.ino')
-rw-r--r-- | f015_apihandler.ino | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/f015_apihandler.ino b/f015_apihandler.ino index 12c9044..eeb974d 100644 --- a/f015_apihandler.ino +++ b/f015_apihandler.ino @@ -53,20 +53,23 @@ void handlePin() { server.send(400, "text/html", fihr(400, "obvezni argument: p(in) ter neobvezni: v(rednost) (0-1 za digital, 0-1023 za a) (glede na to ce je prisoten spremeni pinMode)")); return; } - if (!server.hasArg("v") && server.arg("v") != NULL) { + if (server.hasArg("v") && server.arg("v") != NULL) { pinMode(pin2gpio(server.arg("p")), OUTPUT); if(server.arg("p").substring(0, 1) == "a" || server.arg("p").substring(0, 1) == "A" || server.arg("v").toInt() > 1) { analogWrite(pin2gpio(server.arg("p")), server.arg("v").toInt()); + server.send(200, "text/html", fihr(200, "OK")); } else { - digitalWrite(pin2gpio(server.arg("p")), server.arg("v").toInt()); + digitalWrite(pin2gpio(server.arg("p")), server.arg("v").toInt());server.send(200, "text/html", fihr(200, "OK")); } } else { - pinMode(pin2gpio(server.arg("p")), OUTPUT); + pinMode(pin2gpio(server.arg("p")), INPUT); delay(1); // idk - if(server.arg("p").substring(0, 1) == "a") { - analogRead(pin2gpio(server.arg("p"))); + if(server.arg("p").substring(0, 1) == "a" || server.arg("p").substring(0, 1) == "A") { + ; + server.send(200, "text/plain", String(analogRead(pin2gpio(server.arg("p"))))); } else { - digitalRead(pin2gpio(server.arg("p"))); + server.send(200, "text/plain", String(digitalRead(pin2gpio(server.arg("p"))))); + ; } } } @@ -95,6 +98,7 @@ void handleSetAP() { writefile("/403/hostname.txt", String(server.arg("h"))); } writefile("/403/wifi-ap.txt", String(server.arg("s"))+","+String(server.arg("p"))+","+String(server.arg("c"))+","+String(readfile("/403/hostname.txt"))); + WiFi.softAPConfig(ipas, gatewayas, subnetas); WiFi.softAP(server.arg("s").c_str(), server.arg("p").c_str(), server.arg("c").toInt(), readfile("/403/hostname.txt").toInt()); server.send(200, "text/html", fihr(200, "AP nastavljena")); } |