Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp32ap beg a password #586

Open
tripod2 opened this issue Mar 8, 2023 · 2 comments
Open

esp32ap beg a password #586

tripod2 opened this issue Mar 8, 2023 · 2 comments

Comments

@tripod2
Copy link

tripod2 commented Mar 8, 2023

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
Copy link
Owner

Hieromon commented Mar 9, 2023

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
Copy link
Owner

Hieromon commented Apr 4, 2023

It may be related to espressif/arduino-esp32#4423.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants