I’ve got this code:
#include <WiFi.h>
#include <DNSServer.h>
#include "gateway.h"
#include <HTTPClient.h>
// Variables for Server
const byte DNS_PORT = 53;
IPAddress apIP(8, 8, 4, 4); // The default android DNS
DNSServer dnsServer;
WiFiServer server(80);
int counter=0;
String currentIP = "192.168.0.100";
String responseHTML = getHTML();
const char *serialNum;
const char *ipAddr;
String sNumForHTML = "";
String ipForHTML = "";
int incomingByte = 0;
// Function for starting server
void setup() {
Serial.begin(115200);
Serial.println("Starting AP and connecting to WiFi network");
// Start AP mode
WiFi.mode(WIFI_AP_STA);
WiFi.softAP("Gateway_server");
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
// Start DNS Server
dnsServer.start(DNS_PORT, "*", apIP);
// Start web server
server.begin();
}
// Function which get cast one time of each frame
void loop() {
if (Serial.available() > 0) {
// read the incoming byte:
String value = Serial.readString();
Serial.print("incoming Value: ");
Serial.println(value);
}
dnsServer.processNextRequest();
WiFiClient client = server.available(); // listen for incoming clients
if (client) {
// send data only when you receive data:
String currentLine = "";
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == 'n') {
if (currentLine.length() == 0) {
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println();
client.print(responseHTML);
break;
} else {
currentLine = "";
}
} else if (c != 'r') {
currentLine += c;
}
}
}
client.stop();
}
}
It creates a Captive Portal-Server on my ESP32 how can i send Data (like a IP-String) which i insert in a textfield on the captive portal webview (Response HTML) to this arduino code to manage it?
I know how i can get the input of a text field in HTML using JS but how can i send it to the ardunio code which upload the webview?
Or is it even possible?
THX for helping.
I tried to solve this problem using serial or http requests but it didn’t work.