Hieromon / AutoConnect

An Arduino library for ESP8266/ESP32 WLAN configuration at runtime with the Web interface
https://hieromon.github.io/AutoConnect/
MIT License
889 stars 185 forks source link

esp32ap beg a password #586

Open tripod2 opened 1 year ago

tripod2 commented 1 year ago

using android and esp32-s2/esp32cam i see the esp32ap on smartphone and when i connect it beg password using 123456789 output wrong password https://github.com/Hieromon/AutoConnect/tree/master/examples)/WebCamServer/ https://github.com/Hieromon/AutoConnect/tree/master/examples)/FetchLED/

Hieromon commented 1 year ago

This could be a problem known as captive portal limitation on some android platforms, which may be avoided by adjusting the IP address of the DNS activated in SoftAP for android.

Try AutoConnectConfig::apip with 8.8.4.4.

Also, You can take advantage of the following verification sketch to make sure your android device is compliant. This is a captive portal demonstration that the ESP32 Arduino core has included as an example for the DNS Server library, with the addition of password authentication.

#include <Arduino.h>
#include <WiFi.h>
#include <DNSServer.h>

const byte DNS_PORT = 53;
IPAddress apIP(8,8,4,4);
DNSServer dnsServer;
WiFiServer server(80);

String responseHTML = ""
  "<!DOCTYPE html><html><head><title>CaptivePortal</title></head><body>"
  "<h1>Hello World!</h1><p>This is a captive portal example. All requests will "
  "be redirected here.</p></body></html>";

void setup() {
  delay(1000);
  Serial.begin(115200);
  Serial.println();

  WiFi.mode(WIFI_AP);
  WiFi.softAP("esp32ap", "12345678");
  WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));

  // if DNSServer is started with "*" for domain name, it will reply with
  // provided IP to all DNS request
  dnsServer.start(DNS_PORT, "*", apIP);

  server.begin();

  Serial.println("Server started");
}

void loop() {
  dnsServer.processNextRequest();
  WiFiClient client = server.available();   // listen for incoming clients

  if (client) {
    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();
  }
}

Combine this sketch with your android device and open esp32ap. The password is 12345678. If the issue reproduces, the SoftAP IP address is not compatible with the Android platform.

Hieromon commented 1 year ago

It may be related to https://github.com/espressif/arduino-esp32/issues/4423.