4
votes

I have created a soft AP with ESP8266 to which I'm connecting through android 6.0 marshmallow mobile. After connecting I get a notification on mobile stating "Wifi has no internet access" if I ignore it and open a browser window to open my web server page or use a custom built app to communicate with ESP web server no request is processed by ESP8266. However everything works fine after I click on stay connected option "Yes" in that notification. I'm trying to avoid any manual operation by user thus trying to fix it programatically. Is it possible to use an ESP as a router AP without internet access and connect to it using an android app without dealing with this notification manually.

Update: If I connect to this AP via custom built app programatically, this notification does not appear and all communication to ESP remain blocked by android.

ESP code:

  WiFiServer server(80);
  WiFi.softAP("ssid", "password");
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.begin();
  delay(500); 
  Serial.println("Server started");
  Serial.println(WiFi.localIP());
1
How is the behavior with mobile connection switched off?greenapps

1 Answers

0
votes

Use Captive Portal with mDNS.

Here is the example and here are some highlights from it :

const char *softAP_ssid = "ESP_ap";
const char *softAP_password = "12345678";

/* hostname for mDNS. Should work at least on windows. Try http://esp8266.local */
const char *myHostname = "esp8266";

// Web server
ESP8266WebServer server(80);

// DNS server
const byte DNS_PORT = 53;
DNSServer dnsServer;

/* Soft AP network parameters */
IPAddress apIP(192, 168, 4, 1);
IPAddress netMsk(255, 255, 255, 0);

void setup() {
  /* Setup the DNS server redirecting all the domains to the apIP */  
  dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
  dnsServer.start(DNS_PORT, "*", apIP);

  /* Setup web pages: root, wifi config pages, SO captive portal detectors and not found. */
  server.on("/", handleRoot);
  server.on("/generate_204", handleRoot);  //Android captive portal. .
  server.on("/fwlink", handleRoot); //Microsoft captive portal. 
  server.onNotFound ( handleNotFound );
}