ESP8266 Webserver Project

Moderator: Sprite_tm

User avatar
By Cicero
#58567
bjpirt wrote:Hi Sprite_tm and others,
I've been using libesphttpd to good effect and had configured the captive portal which had been working really well until I realised how iOS devices behave. The problem I'm having is that the iPhone thinks that because it can't actually connect to the internet then it should disconnect from the AP (which is just plain annoying).

My suspicion is that they're just not going to play nicely, in which case I'd like to keep the DNS server functionality but only have it respond successfully to one address so that users don't need to type in IP addresses. I've been trying this by making it return an NXDOMAIN error for anything other than my domain but the iOS device still won't join the network.

Has anyone else made the captive portal work on iOS devices?

I'm going to keep trying to make it work, but any pointers or advice would be appreciated.
Cheers,
Ben

Just a quick FYI update related to this, and recap. The iOS captive portal doesn't work very well due to the need for them to query Apple specific addresses on the net, captive.apple.com among others for the "Success" page, http://captive.apple.com/
There are others, http://www.apple.com/library/test/success.html , see the answer here in this older list http://stackoverflow.com/questions/1905 ... -detection

As posted earlier in this thread, the Arduino crew have hacked this Success message with an auth token as well https://github.com/esp8266/Arduino/pull ... -118405249. I'm not too fond of this method, and I'm not willing to trust Apple here to keep it this way, as their track record doesn't show consistency. It also doesn't work with multiple devices afaik.

I decided I'd rather disable the captive portal auto popup page, and implemented what Ben wanted originally. I've created a whitelist of URL's I want redirected to my unit, and I ignore the rest.

Simple code addition, along the lines of this in captdns.c:
Please remember your default hostname as well in this list.
Code: Select allconst char *whitelisturl[nWHITELISTURLS] = {
   "www.setup.com",
   "www.unit.com",
   "www.letmein.com",
        "www.whateverelse.com",
        "esp.nonet"            
};

Then in captRecv() function:
Code: Select all      allowRedirect = FALSE;
      for (j=0; j<nWHITELISTURLS; j++) {
         if (strcmp(buff, whitelisturl[j]) == 0) {
            allowRedirect = TRUE;
            httpd_printf("Allowing Redirect for %s\n", buff);
            break;
         }
      }
      if (allowRedirect==FALSE) return;
      httpd_printf("DNS: Q (type 0x%X class 0x%X) for %s\n", my_ntohs(&qf->type), my_ntohs(&qf->class), buff);   


It could help a few others to reduce their frustration with iOS devices. This way the iOS device connects just fine to the AP, and the user can enter anything in the whitelist.