esp32AP getrequest

mehrdadco
Posts: 8
Joined: Tue Jun 11, 2019 8:53 am

esp32AP getrequest

Postby mehrdadco » Tue Jun 11, 2019 9:15 am

I started a project that requires communication between esp32 as an AP and pc client. I send the HTML code but there is no idea to receive an answer .looking for any clue or example to receive a data and can see it in the serial monitor.
it's my HTML code

Code: Untitled.c Select all


const char *ssid = "MyESP";
const char HTML[] PROGMEM = "<script language=\"JavaScript\">function formToJson(form){var pass=form.pass.value;var ssid=form.ssid.value;var jsonFormInfo=JSON.stringify({pass:pass, ssid: ssid});window.alert('OK');}</script> <form onSubmit=\"event.preventDefault(); formToJson(this);\"> <label class=\"label\">Network Name</label> <input type=\"text\" name=\"ssid\"/> <label>Password</label> <input type=\"text\" name=\pass/> <input type=\"submit\" value=\"Submit\"></form>";

AsyncWebServer server(80);
void setup() {
Serial.begin(115200);
WiFi.softAP(ssid);
Serial.println();
Serial.print("IP address: ");
Serial.println(WiFi.softAPIP());
server.on("/Cfig", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/html", HTML);});
server.begin();
HTTPClient http;
http.begin("http://192.168.1.87");
http.addHeader("Content-Type", "text/plain");
int httpResponseCode = http.POST("POSTING from ESP32");
if (httpResponseCode > 0) {
String response = http.getString();
Serial.println(httpResponse);
Serial.println(response); }
else {Serial.print("Error on sending POST: ");
Serial.println(httpResponse);}
http.end();}
iwant to save ssid ,pass in esp32
Last edited by mehrdadco on Tue Jun 11, 2019 2:02 pm, edited 2 times in total.

Sprite
Espressif staff
Espressif staff
Posts: 10636
Joined: Thu Nov 26, 2015 4:08 am

Re: esp32AP getrequest

Postby Sprite » Tue Jun 11, 2019 9:16 am

Moved to Arduino, as it seems to be for the webserver for that platform.

Who is online

Users browsing this forum: No registered users and 2 guests