So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Peter1234
#62546 I did the sample code using the ESP as access point. You can join the WiFi with your mobile but its required to browse to a certain IP address.
Is it possible to skip this? E.g. in some free WiFi networks a starting page is displayed, regardless to the desired webpage. Is this possible with ESP8266?
I did not find anything yet, maybe I used the wrong keywords.

Thank you
Peter
User avatar
By jeffas
#62704 This sort of behaviour (in Internet cafes and so on) is usually done in the router/firewall, which transparently redirects all port-80 (HTTP) connections from unrecognised MAC addresses to the cafe's own server so that you can register (and pay any necessary fee).
When the ESP is in AP mode, it is acting as router. It will see all packets, so it should be able to do what you want. But you need to be lower down in the TCP/IP stack than you are when you're running a web server. I don't know if there's any existing library to help you with that. You may have to look at using the ESP SDK calls directly.
User avatar
By rudy
#62709 Search for Captive Portal. It is easy to do. But there are problems. Different types of devices sometimes need special handling. A universal solution is more difficult.

https://github.com/esp8266/Arduino/blob ... Portal.ino

viewtopic.php?f=32&t=3618

https://www.hackster.io/rayburne/esp826 ... tal-5798ff

https://github.com/idolpx/mobile-rr
User avatar
By xl97
#62718 rudy is correct.

captive portal is what you are looking for.. (and those links will get you there)

what I did was have several different devices 'connect' and the output the info/request to the serial monitor of the Arduino IDE. (debug = on)

I then made note to use these in specific handlers in my code.. (along with my own custom requests/handlers)

* in my project I served up my own little HTML & in-line CSS to make a gui (interface) to send 'commands' from the connected mobile phone to the ESP/Arduino (which was a pro-micro acting as an HID device (ie: keyboard/mouse) and have it execute those actions on the connected PC.


example:
Code: Select all//main page request (serve up my HTML gui)
  my_server.on("/", my_html_page); 
   
  //iOS handlers
  my_server.on("/hotspot-detect.html", handle_iphone);
  my_server.on("/bag", handle_ipad);
 
  //android handlers
  my_server.on("/generate_204", my_html_page);  //Android captive portal
 
  //custom (app specific) handlers (requests sent from HTML page)
 
  //mouse
  my_server.on("/mouse", handle_mouse);
 
  //keyboard
  my_server.on("/keyboard", handle_keyboard);
 
  //preset link/action handlers
  my_server.on("/preset", handle_preset);


etc..etc

all the:
handle_iphone, handle_ipad, my_html_page...etc.. are all functions that you create to do/handle (whatever you want)

I also recall a 'tip' that the HTML page/code you serve up needs to have 'success' in the title or something for iOS devices.. (been a while since I worked on things though)..


tip 2:

the ip address you assign the ESP8266 module matters when trying to be a captive portal/AP..

I have found that my project would not let iOS devices connect when I use an internal LAN IP such as 192.168.1.x or 192.168.0.x etc..etc

when I used 10.10.0.1 it worked.

tip 3:
I found that even when my phone/ipad would connect to the captive portal/network.. when I opened my browser and requested a web page (a legit one)..

I was expecting it to not matter what url I typed in there.. (as it should only serve up the captive portal page/html)

but if I typed in a site my phone/browser had been to before, it seemed to try and load the page from cache and fail.

if I requested a never before visited page it was fine.. or requesting things like abc123.com..etc worked as well..



good luck.