[GH-ISSUE #1284] Hello Could someone take a look at my #1101

Closed
opened 2026-02-28 01:28:31 +03:00 by kerem · 1 comment
Owner

Originally created by @Moriscoc on GitHub (Aug 26, 2021).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1284

Hello
Could someone take a look at my code where is the error of my project with Esp8266 which is crashing in the wifiMonager configuration web when I near the wifi password configuration button
here the program to send data through the serial port.
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager

                                        // Defina o número da porta do servidor web para 80

WiFiServer server(80);
// Variável para armazenar a solicitação HTTP
String header;
void setup() {
Serial.begin(9600);

// WiFiManager
// Inicialização local. Uma vez que seu negócio esteja concluído, não há necessidade de mantê-lo por perto
WiFiManager wifiManager;
wifiManager.autoConnect("AutoConnectAP");
Serial.println("Connected.");
server.begin();
initWifi();
}
void loop(){
}
void initWifi() {
WiFiClient client = server.available(); // Listen for incoming clients

if (client) { // If a new client connects,
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
header += c;
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();

        // Web Page Heading
        client.println("<body><h1>ESP8266 Web Server</h1>");
        // The HTTP response ends with another blank line
        client.println();
        // Break out of the while loop
        break;
      } else { // if you got a newline, then clear currentLine
        currentLine = "";
      }
    } else if (c != '\r') {  // if you got anything else but a carriage return character,
      currentLine += c;      // add it to the end of the currentLine
    }
  }
}
// Clear the header variable
header = "";
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");

}
}

Originally created by @Moriscoc on GitHub (Aug 26, 2021). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1284 Hello Could someone take a look at my code where is the error of my project with Esp8266 which is crashing in the wifiMonager configuration web when I near the wifi password configuration button here the program to send data through the serial port. #include <ESP8266WiFi.h> #include <DNSServer.h> #include <ESP8266WebServer.h> #include <WiFiManager.h> // https://github.com/tzapu/WiFiManager // Defina o número da porta do servidor web para 80 WiFiServer server(80); // Variável para armazenar a solicitação HTTP String header; void setup() { Serial.begin(9600); // WiFiManager // Inicialização local. Uma vez que seu negócio esteja concluído, não há necessidade de mantê-lo por perto WiFiManager wifiManager; wifiManager.autoConnect("AutoConnectAP"); Serial.println("Connected."); server.begin(); initWifi(); } void loop(){ } void initWifi() { WiFiClient client = server.available(); // Listen for incoming clients if (client) { // If a new client connects, Serial.println("New Client."); // print a message out in the serial port String currentLine = ""; // make a String to hold incoming data from the client while (client.connected()) { // loop while the client's connected if (client.available()) { // if there's bytes to read from the client, char c = client.read(); // read a byte, then Serial.write(c); // print it out the serial monitor header += c; if (c == '\n') { // if the byte is a newline character // if the current line is blank, you got two newline characters in a row. // that's the end of the client HTTP request, so send a response: if (currentLine.length() == 0) { // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) // and a content-type so the client knows what's coming, then a blank line: client.println("HTTP/1.1 200 OK"); client.println("Content-type:text/html"); client.println("Connection: close"); client.println(); // Web Page Heading client.println("<body><h1>ESP8266 Web Server</h1>"); // The HTTP response ends with another blank line client.println(); // Break out of the while loop break; } else { // if you got a newline, then clear currentLine currentLine = ""; } } else if (c != '\r') { // if you got anything else but a carriage return character, currentLine += c; // add it to the end of the currentLine } } } // Clear the header variable header = ""; // Close the connection client.stop(); Serial.println("Client disconnected."); Serial.println(""); } }
kerem closed this issue 2026-02-28 01:28:31 +03:00
Author
Owner

@Moriscoc commented on GitHub (Aug 26, 2021):

Hello
Could someone take a look at my

<!-- gh-comment-id:906772208 --> @Moriscoc commented on GitHub (Aug 26, 2021): Hello Could someone take a look at my
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1101
No description provided.