diff options
-rw-r--r-- | data/www/1.html | 2 | ||||
-rw-r--r-- | f000_sijaneciot.ino | 4 | ||||
-rw-r--r-- | f015_apihandler.ino | 16 | ||||
-rw-r--r-- | f020_setup.ino | 6 |
4 files changed, 15 insertions, 13 deletions
diff --git a/data/www/1.html b/data/www/1.html index c75f0b3..d708f5f 100644 --- a/data/www/1.html +++ b/data/www/1.html @@ -81,7 +81,7 @@ spoofan mac naslov ESP-čipa (neobvezno): <input type=text maxlength=12 name=m p </tr> <tr> <td>7<br><br> -<form action="/api/pin" method="GET" target="zadnjaiframe"> +<form action="/api/gid" method="GET" target="zadnjaiframe"> <select name=k> <option value="s">MAC kot klient neke druge dost.točke</option> <option value="a">MAC kot dostopna točka</option> diff --git a/f000_sijaneciot.ino b/f000_sijaneciot.ino index 0e6e5ee..7d98b88 100644 --- a/f000_sijaneciot.ino +++ b/f000_sijaneciot.ino @@ -1,5 +1,4 @@ #include <ESP8266WiFi.h> -#include <ESP8266mDNS.h> #include <ESP8266WebServer.h> #include <WiFiClient.h> #include "FS.h" @@ -10,6 +9,9 @@ extern "C" { #include <user_interface.h> } + IPAddress ipas(10, 82, 66, 1); + IPAddress gatewayas(10, 82, 66, 1); + IPAddress subnetas(255, 255, 255, 0); const int verzija[3] = {0, 0, 0}; const char* program_ime = "sijaneciot"; String dostopnatocka[2]; 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")); } diff --git a/f020_setup.ino b/f020_setup.ino index 28de3b5..8e50af7 100644 --- a/f020_setup.ino +++ b/f020_setup.ino @@ -29,13 +29,9 @@ void setup() { } Serial.print("nastavljam dostopno tocko. SSID: " + String(dostopnatocka[0]) + " geslo: " + String(dostopnatocka[1]) + " ... "); WiFi.mode(WIFI_AP); + WiFi.softAPConfig(ipas, gatewayas, subnetas); WiFi.softAP(dostopnatocka[0].c_str(), dostopnatocka[1].c_str(), dostopnatocka[2].toInt(), dostopnatocka[3].toInt()); if (razhroscevanje) Serial.println("(razhroscevanje): wifi.softap --> IPv4 " + String(WiFi.softAPIP().toString())); - if (MDNS.begin(readfile("/403/hostname.txt"))) { // Start the mDNS responder for esp8266.local - if (razhroscevanje) Serial.println("(razhroscevanje): mDNS dela, " + readfile("/403/hostname.txt")); - } else { - if (razhroscevanje) Serial.println("(razhroscevanje): mDNS fejl"); - } ftpSrv.begin(program_ime, readfile("/403/webgeslo.txt")); setSyncProvider(getNtpTime); |